Browse Source

Add first bunch of ipv6 api scripts, thanks to www.madeit.be

Raphael Schneeberger 5 years ago
parent
commit
294723250a

+ 94 - 0
bin/v-add-firewall-ipv6-rule

@@ -0,0 +1,94 @@
+#!/bin/bash
+# info: add firewall rule
+# options: ACTION IPV6 PORT [PROTOCOL] [COMMENT] [RULE]
+#
+# The function adds new rule to system firewall
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Argument definition
+action=$(echo $1|tr '[:lower:]' '[:upper:]')
+ipv6=$2
+port_ext=$3
+protocol=${4-TCP}
+protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]')
+comment=$5
+rule=$6
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/HESTIA.conf
+
+# Get next firewall rule id
+get_next_fw_rule() {
+    if [ -z "$rule" ]; then
+        curr_str=$(grep "RULE=" $HESTIA/data/firewallv6/rules.conf |\
+         cut -f 2 -d \' | sort -n | tail -n1)
+        rule="$((curr_str +1))"
+    fi
+}
+
+sort_fw_rules() {
+    cat $HESTIA/data/firewallv6/rules.conf |\
+        sort -n -k 2 -t \' > $HESTIA/data/firewallv6/rules.conf.tmp
+    mv -f $HESTIA/data/firewallv6/rules.conf.tmp \
+        $HESTIA/data/firewallv6/rules.conf
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'ACTION IPV6 PORT [PROTOCOL] [COMMENT] [RULE]'
+is_format_valid 'action' 'protocol' 'port_ext' 'ipv6'
+is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
+get_next_fw_rule
+is_format_valid 'rule'
+is_object_new '../../data/firewallv6/rules' 'RULE' "$rule"
+if [ ! -z "$comment" ]; then
+    is_format_valid 'comment'
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Generating timestamp
+time_n_date=$(date +'%T %F')
+time=$(echo "$time_n_date" |cut -f 1 -d \ )
+date=$(echo "$time_n_date" |cut -f 2 -d \ )
+
+# Concatenating rule
+str="RULE='$rule' ACTION='$action' PROTOCOL='$protocol' PORT='$port_ext'"
+str="$str IP6='$ipv6' COMMENT='$comment' SUSPENDED='no'"
+str="$str TIME='$time' DATE='$date'"
+
+# Adding to config
+echo "$str" >> $HESTIA/data/firewallv6/rules.conf
+
+# Changing permissions
+chmod 660 $HESTIA/data/firewallv6/rules.conf
+
+# Sorting firewall rules by id number
+sort_fw_rules
+
+# Updating system firewall
+$BIN/v-update-firewall-ipv6
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 181 - 0
bin/v-add-sys-ipv6

@@ -0,0 +1,181 @@
+#!/bin/bash
+# info: add system ip address
+# options: IPV6 NETMASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME]
+#
+# The function adds ipv6 address into a system. It also creates rc scripts. You
+# can specify ipv6 name which will be used as root domain for temporary aliases.
+# For example, if you set a1.myhosting.com as name, each new domain created on
+# this ipv6 will automatically receive alias $domain.a1.myhosting.com. Of course
+# you must have wildcard record *.a1.myhosting.com pointed to ipv6. This feature 
+# is very handy when customer wants to test domain before dns migration.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+ipv6=${1// /}
+netmask=$2
+interface="${3-eth0}"
+user="${4-admin}"
+ip_status="${5-shared}"
+ip_name=$6
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/ipv6.sh
+source $HESTIA/func/domain.sh
+source $HESTIA/conf/hestia.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'IPV6 NETMASK [INTERFACE] [USER] [STATUS] [NAME]'
+is_format_valid 'ipv6' 'netmaskv6' 'interface' 'user' 'ip_status'
+is_ipv6_free
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+if [ ! -z "$ip_name" ] ; then
+    is_format_valid 'ip_name'
+fi
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+iface=$(get_ipv6_iface)
+#cidr=$(convert_netmaskv6 $netmask)
+cidr=$netmask
+
+sys_ip_check=$(/sbin/ip -6 addr | grep "$ipv6")
+if [ -z "$sys_ip_check" ]; then
+    # Adding sys ip
+    /sbin/ip addr add $ipv6/$cidr dev $interface
+
+    # Adding RHEL/CentOS/Fedora startup script
+    if [ -e "/etc/redhat-release" ]; then
+        sys_ip="# Added by hestia"
+        sys_ip="$sys_ip\nIPV6INIT=yes"
+        sys_ip="$sys_ip\nIPV6ADDR=$ipv6/$cidr"
+        sys_ip="$sys_ip\nIPV6_DEFAULTGW=$interface"
+        sys_ip="$sys_ip\nIPV6_AUTOCONF=no"
+        #sys_ip="$sys_ip\nIPV6ADDR_SECONDARIES="""
+        echo -e $sys_ip > /etc/sysconfig/network-scripts/ifcfg-$interface
+    fi
+
+    # Adding Debian/Ubuntu startup script
+    if [ -e "/etc/debian_version" ]; then
+        sys_ip="\n# Added by hestia"
+        sys_ip="$sys_ip\niface $interface inet6 static"
+        sys_ip="$sys_ip\naddress $ipv6"
+        sys_ip="$sys_ip\nnetmask $cidr"
+        echo -e $sys_ip >> /etc/network/interfaces
+    fi
+fi
+
+# Generating timestamp
+time_n_date=$(date +'%T %F')
+time=$(echo "$time_n_date" |cut -f 1 -d \ )
+date=$(echo "$time_n_date" |cut -f 2 -d \ )
+
+# Adding hestia ip
+echo "OWNER='$user'
+STATUS='$ip_status'
+NAME='$ip_name'
+U_SYS_USERS=''
+U_WEB_DOMAINS='0'
+INTERFACE='$interface'
+NETMASK='$netmask'
+NAT=''
+TIME='$time'
+DATE='$date'
+VERSION='6'" > $HESTIA/data/ips/$ipv6
+chmod 660 $HESTIA/data/ips/$ipv6
+
+# WEB support
+if [ ! -z "$WEB_SYSTEM" ]; then
+    web_conf="/etc/$WEB_SYSTEM/conf.d/$ipv6.conf"
+    rm -f $web_conf
+
+    if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
+        if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
+            echo "NameVirtualHost [$ipv6]:$WEB_PORT" >  $web_conf
+        fi
+        echo "Listen [$ipv6]:$WEB_PORT" >> $web_conf
+    fi
+
+    if [ "$WEB_SSL" = 'mod_ssl' ]; then
+        if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
+            echo "NameVirtualHost [$ipv6]:$WEB_SSL_PORT" >> $web_conf
+        fi
+        echo "Listen [$ipv6]:$WEB_SSL_PORT" >> $web_conf
+    fi
+fi
+
+# Proxy support
+if [ ! -z "$PROXY_SYSTEM" ]; then
+    cat $WEBTPL/$PROXY_SYSTEM/proxy_ip.tpl |\
+        sed -e "s/%ip%/[$ipv6]/g" \
+            -e "s/%web_port%/$WEB_PORT/g" \
+            -e "s/%proxy_port%/$PROXY_PORT/g" \
+        > /etc/$PROXY_SYSTEM/conf.d/$ipv6.conf
+
+    # mod_rpaf
+    rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
+    if [ -e "$rpaf_conf" ]; then
+        rpaf_str=$(grep RPAFproxy_ips $rpaf_conf)
+        rpaf_str="$rpaf_str $ipv6"
+        sed -i "s/.*RPAFproxy_ips.*/$rpaf_str/" $rpaf_conf
+    fi
+
+    #mod_remoteip
+    remoteip_conf="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
+    if [ -e "$remoteip_conf" ]; then
+        if [ $( grep -ic "$ipv6" $remoteip_conf ) -eq 0 ]; then
+            sed -i "s/<\/IfModule>/RemoteIPInternalProxy $ipv6\n<\/IfModule>/g" $remoteip_conf
+        fi
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Updating user counters
+increase_user_value "$user" '$IPV6_OWNED'
+if [ "$user" = 'admin' ]; then
+    if [ "$ip_status" = 'shared' ]; then
+        for user in $(ls $HESTIA/data/users); do
+            increase_user_value "$user" '$IPV6_AVAIL'
+        done
+    else
+        increase_user_value 'admin' '$IPV6_AVAIL'
+    fi
+else
+    increase_user_value "$user" '$IPV6_AVAIL'
+    increase_user_value 'admin' '$IPV6_AVAIL'
+fi
+
+# Restarting web server
+$BIN/v-restart-web
+check_result $? "Web restart failed" >/dev/null
+
+# Restarting proxy server
+if [ ! -z "$PROXY_SYSTEM" ]; then
+    $BIN/v-restart-proxy
+    check_result $? "Proxy restart failed" >/dev/null
+fi
+
+# Restarting firewall
+if [ ! -z "$FIREWALL_SYSTEM" ]; then
+    $BIN/v-update-firewall
+fi
+
+# Logging
+log_history "added system ipv6 address $ipv6" '' 'admin'
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 120 - 0
bin/v-change-dns-domain-ipv6

@@ -0,0 +1,120 @@
+#!/bin/bash
+# info: change dns domain ip address
+# options: USER DOMAIN IPV6
+#
+# The function for changing the main ipv6 of DNS zone.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$2
+domain_idn=$2
+ipv6=$3
+restart=$4
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/ipv6.sh
+source $HESTIA/func/domain.sh
+source $HESTIA/conf/hestia.conf
+
+# Additional argument formatting
+format_domain
+format_domain_idn
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'USER DOMAIN IPV6'
+is_format_valid 'user' 'domain'
+is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'dns' 'DOMAIN' "$domain"
+is_object_unsuspended 'dns' 'DOMAIN' "$domain"
+
+if [ "$ipv6" != "no" ]; then
+    is_format_valid 'ipv6'
+fi
+if [ "$ipv6" != "no" ]; then
+    is_ipv6_valid "$ipv6" "$user"
+else
+    ipv6=''
+fi
+
+# Get old ip
+get_domain_values 'dns'
+if [ -z @"$ipv6" ] && [ -z "$IP" ]; then
+    check_result $E_INVALID "IP or IPv6 is required"
+fi
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+old=$IP6
+
+if [ -z "$old" ]; then
+    #Create new
+    # Generating timestamp
+    time_n_date=$(date +'%T %F')
+    time=$(echo "$time_n_date" |cut -f 1 -d \ )
+    date=$(echo "$time_n_date" |cut -f 2 -d \ )
+    ip=""
+    add_dns_config_records
+else
+    if [ ! -z "$ipv6" ]; then
+        # Changing records
+        sed -i "s/$old/$ipv6/g" $USER_DATA/dns/$domain.conf
+    else
+        #Delete configs
+        ipv6=""
+        ip=$IP
+        remove_dns_config_records
+    fi
+fi
+
+# Changing ip
+update_object_value 'dns' 'DOMAIN' "$domain" '$IP6' "$ipv6"
+
+#update counters
+records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
+update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
+records=$(wc -l $USER_DATA/dns/*.conf | cut -f 1 -d ' ')
+update_user_value "$user" '$U_DNS_RECORDS' "$records"
+
+# Updating zone
+if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
+    update_domain_zone
+fi
+
+# Updating dns-cluster queue
+if [ ! -z "$DNS_CLUSTER" ]; then
+    # Check for first sync
+    dlock=$(grep "domain $user $domain" $HESTIA/data/queue/dns-cluster.pipe)
+    if [ -z "$dlock" ]; then
+        cmd="$BIN/v-add-remote-dns-domain $user $domain domain yes"
+        echo "$cmd" >> $HESTIA/data/queue/dns-cluster.pipe
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+# Restarting named
+$BIN/v-restart-dns $restart
+check_result $? "DNS restart failed" >/dev/null
+
+# Logging
+log_history "changed dns ipv6 for $domain to $ipv6"
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 85 - 0
bin/v-change-firewall-ipv6-rule

@@ -0,0 +1,85 @@
+#!/bin/bash
+# info: change firewall rule
+# options: RULE ACTION IPV6 PORT [PROTOCOL] [COMMENT]
+#
+# The function is used for changing existing firewall rule.
+# It fully replace rule with new one but keeps same id.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Argument definition
+rule=$1
+action=$(echo $2|tr '[:lower:]' '[:upper:]')
+ipv6=$3
+port_ext=$4
+protocol=${5-TCP}
+protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]')
+comment=$6
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/HESTIA.conf
+
+# Sort function
+sort_fw_rules() {
+    cat $HESTIA/data/firewallv6/rules.conf |\
+        sort -n -k 2 -t \' > $HESTIA/data/firewallv6/rules.conf.tmp
+    mv -f $HESTIA/data/firewallv6/rules.conf.tmp \
+        $HESTIA/data/firewallv6/rules.conf
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '5' "$#" 'RULE ACTION IPV6  PORT [PROTOCOL] [COMMENT]'
+is_format_valid 'rule' 'action' 'protocol' 'port_ext' 'ipv6'
+if [ ! -z "$comment" ]; then
+    is_format_valid 'comment'
+fi
+is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
+is_object_valid '../../data/firewallv6/rules' 'RULE' "$rule"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Generating timestamp
+time_n_date=$(date +'%T %F')
+time=$(echo "$time_n_date" |cut -f 1 -d \ )
+date=$(echo "$time_n_date" |cut -f 2 -d \ )
+
+# Concatenating firewall rule
+str="RULE='$rule' ACTION='$action' PROTOCOL='$protocol' PORT='$port_ext'"
+str="$str IP6='$ipv6' COMMENT='$comment' SUSPENDED='no'"
+str="$str TIME='$time' DATE='$date'"
+
+# Deleting old rule
+sed -i "/RULE='$rule' /d" $HESTIA/data/firewallv6/rules.conf
+
+# Adding new
+echo "$str" >> $HESTIA/data/firewallv6/rules.conf
+
+# Sorting firewall rules by id number
+sort_fw_rules
+
+# Updating system firewall
+$BIN/v-update-firewall-ipv6
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 48 - 0
bin/v-change-sys-ipv6-name

@@ -0,0 +1,48 @@
+#!/bin/bash
+# info: change ip name
+# options: IPV6 NAME
+#
+# The function for changing the name of the ip.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+ipv6=$1
+ip_name=$2
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/ipv6.sh
+source $HESTIA/conf/hestia.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'IPV6 IP_NAME'
+is_format_valid 'ipv6'
+is_format_valid 'ip_name'
+is_ipv6_valid "$ipv6"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Changing ip name
+update_ipv6_value '$NAME' "$ip_name"
+
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Logging
+log_history "changed associated name of $ipv6 to $ip_name" '' 'admin'
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 48 - 0
bin/v-change-sys-ipv6-owner

@@ -0,0 +1,48 @@
+#!/bin/bash
+# info: change ip name
+# options: IPV6 NAME
+#
+# The function for changing the name of the ip.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+ipv6=$1
+ip_name=$2
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/ipv6.sh
+source $HESTIA/conf/hestia.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'IPV6 IP_NAME'
+is_format_valid 'ipv6'
+is_format_valid 'ip_name'
+is_ipv6_valid "$ipv6"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Changing ip name
+update_ipv6_value '$NAME' "$ip_name"
+
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Logging
+log_history "changed associated name of $ipv6 to $ip_name" '' 'admin'
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 56 - 0
bin/v-change-sys-ipv6-status

@@ -0,0 +1,56 @@
+#!/bin/bash
+# info: change ip status
+# options: IPV6 IP_STATUS
+#
+# The function of changing an ip address's status.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+ipv6=$1
+ip_status=$2
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/ipv6.sh
+source $HESTIA/conf/hestia.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'IPV6 IP_STATUS'
+is_format_valid 'ipv6' 'ip_status'
+is_ipv6_valid "$ipv6"
+if [ "$ip_status" = "$(get_ipv6_value '$STATUS')" ]; then
+    check_result "$E_EXISTS" "status $ip_status is already set"
+fi
+web_domains=$(get_ipv6_value '$U_WEB_DOMAINS')
+sys_user=$(get_ipv6_value '$U_SYS_USERS')
+ip_owner=$(get_ipv6_value '$OWNER')
+if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
+    check_result "$E_INUSE" "ip $ipv6 is used"
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Changing ip name
+update_ipv6_value '$STATUS' "$ip_status"
+
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Logging
+log_history "changed $ipv6 status to $ip_status" '' 'admin'
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 120 - 0
bin/v-change-web-domain-ipv6

@@ -0,0 +1,120 @@
+#!/bin/bash
+# info: change dns domain ip address
+# options: USER DOMAIN IPV6
+#
+# The function for changing the main ipv6 of DNS zone.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$2
+domain_idn=$2
+ipv6=$3
+restart=$4
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/ipv6.sh
+source $HESTIA/func/domain.sh
+source $HESTIA/conf/hestia.conf
+
+# Additional argument formatting
+format_domain
+format_domain_idn
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'USER DOMAIN IPV6'
+is_format_valid 'user' 'domain'
+is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'dns' 'DOMAIN' "$domain"
+is_object_unsuspended 'dns' 'DOMAIN' "$domain"
+
+if [ "$ipv6" != "no" ]; then
+    is_format_valid 'ipv6'
+fi
+if [ "$ipv6" != "no" ]; then
+    is_ipv6_valid "$ipv6" "$user"
+else
+    ipv6=''
+fi
+
+# Get old ip
+get_domain_values 'dns'
+if [ -z @"$ipv6" ] && [ -z "$IP" ]; then
+    check_result $E_INVALID "IP or IPv6 is required"
+fi
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+old=$IP6
+
+if [ -z "$old" ]; then
+    #Create new
+    # Generating timestamp
+    time_n_date=$(date +'%T %F')
+    time=$(echo "$time_n_date" |cut -f 1 -d \ )
+    date=$(echo "$time_n_date" |cut -f 2 -d \ )
+    ip=""
+    add_dns_config_records
+else
+    if [ ! -z "$ipv6" ]; then
+        # Changing records
+        sed -i "s/$old/$ipv6/g" $USER_DATA/dns/$domain.conf
+    else
+        #Delete configs
+        ipv6=""
+        ip=$IP
+        remove_dns_config_records
+    fi
+fi
+
+# Changing ip
+update_object_value 'dns' 'DOMAIN' "$domain" '$IP6' "$ipv6"
+
+#update counters
+records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
+update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
+records=$(wc -l $USER_DATA/dns/*.conf | cut -f 1 -d ' ')
+update_user_value "$user" '$U_DNS_RECORDS' "$records"
+
+# Updating zone
+if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
+    update_domain_zone
+fi
+
+# Updating dns-cluster queue
+if [ ! -z "$DNS_CLUSTER" ]; then
+    # Check for first sync
+    dlock=$(grep "domain $user $domain" $HESTIA/data/queue/dns-cluster.pipe)
+    if [ -z "$dlock" ]; then
+        cmd="$BIN/v-add-remote-dns-domain $user $domain domain yes"
+        echo "$cmd" >> $HESTIA/data/queue/dns-cluster.pipe
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+# Restarting named
+$BIN/v-restart-dns $restart
+check_result $? "DNS restart failed" >/dev/null
+
+# Logging
+log_history "changed dns ipv6 for $domain to $ipv6"
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 51 - 0
bin/v-delete-firewall-ipv6-rule

@@ -0,0 +1,51 @@
+#!/bin/bash
+# info: delete firewall rule
+# options: RULE
+#
+# The function deletes firewall rule.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Argument definition
+rule=$1
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/HESTIA.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'RULE'
+is_format_valid 'rule'
+is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
+is_object_valid '../../data/firewallv6/rules' 'RULE' "$rule"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Deleting rule
+sed -i "/RULE='$rule' /d" $HESTIA/data/firewallv6/rules.conf
+
+# Updating system firewall
+$BIN/v-update-firewall-ipv6
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 149 - 0
bin/v-delete-sys-ipv6

@@ -0,0 +1,149 @@
+#!/bin/bash
+# info: delete system ipv6
+# options: IPV6
+#
+# The function for deleting a system ip. It does not allow to delete first ip
+# on interface and do not allow to delete ip which is used by a web domain.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+ipv6=$1
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/ipv6.sh
+source $HESTIA/func/domain.sh
+source $HESTIA/conf/hestia.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'IPV6'
+is_format_valid 'ipv6'
+is_ip_valid "$ipv6"
+is_ip_key_empty '$U_WEB_DOMAINS'
+is_ip_key_empty '$U_SYS_USERS'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Import ip variables
+source $HESTIA/data/ips/$ipv6
+cidr=$(convert_netmaskv6 $NETMASK)
+
+# Checking main ip on the interface
+interface=$(/sbin/ip  -6 addr | grep "$ipv6/$cidr" | awk '{print $NF}')
+if [ ! -z "$interface" ] && [ -z "$(echo $interface |cut -s -f2 -d :)" ]; then
+    echo "Error: can't delete main IP address"
+    log_event "$E_FORBIDEN" "$ARGUMENTS"
+    exit $E_FORBIDEN
+fi
+
+# Deleting system ip
+if [ ! -z "$interface" ]; then
+    /sbin/ip -6 addr del $ip/$cidr dev $INTERFACE
+    if [ "$?" -ne 0 ]; then
+        echo "Error: can't delete system ip"
+        log_event "$E_FORBIDEN" "$ARGUMENTS"
+        exit $E_FORBIDEN
+    fi
+fi
+
+# Deleting startup conf on RHEL/CentOS/Fedora
+if [ -e "/etc/sysconfig/network-scripts/ifcfg-$interface" ]; then
+    rm -f /etc/sysconfig/network-scripts/ifcfg-$interface
+fi
+
+# Deleting startup conf on Debian/Ubuntu
+if [ -e "/etc/network/interfaces" ]; then
+    ip_str=$(grep -n $ip$ /etc/network/interfaces |cut -f1 -d:)
+    if [ ! -z "$ip_str" ]; then
+        first_str=$((ip_str - 3))
+        last_str=$((ip_str + 1))
+        sed -i "$first_str,$last_str d" /etc/network/interfaces
+    fi
+fi
+
+# Deleting hestia ip
+rm -f $HESTIA/data/ips/$ipv6
+
+# Deleting web config
+if [ ! -z "$WEB_SYSTEM" ]; then
+    rm -f /etc/$WEB_SYSTEM/conf.d/$ipv6.conf
+fi
+
+# Deleting proxy config
+if [ ! -z "$PROXY_SYSTEM" ]; then
+    rm -f /etc/$PROXY_SYSTEM/conf.d/$ipv6.conf
+
+    # mod_extract_forwarded
+    fw_conf="/etc/$WEB_SYSTEM/conf.d/mod_extract_forwarded.conf"
+    if [ -e "$fw_conf" ]; then
+        ips=$(grep 'MEFaccept 127.0.0.1' $fw_conf)
+        new_ips=$(echo "$ips" | sed "s/$ipv6//" )
+        sed -i "s/$ips/$new_ips/g" $fw_conf
+    fi
+
+    # mod_rpaf
+    rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
+    if [ -e "$rpaf_conf" ]; then
+        ips=$(grep RPAFproxy_ips $rpaf_conf)
+        new_ips=$(echo "$rpaf_str" | sed "s/$ipv6//")
+        sed -i "s/$ips/$new_ips/g" $rpaf_conf
+    fi
+    
+    #mod_remoteip
+    remoteip_conf="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
+    if [ -e "$remoteip_conf" ]; then
+        sed -i "s/RemoteIPInternalProxy $ipv6//g" $remoteip_conf
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Updating user conf
+if [ ! -z "$OWNER" ]; then
+    decrease_user_value "$OWNER" '$IPV6_OWNED'
+fi
+
+if [ "$OWNER" = 'admin' ]; then
+    if [ "$STATUS" = 'shared' ]; then
+        for user in $(ls $HESTIA/data/users/); do
+            decrease_user_value "$user" '$IPV6_AVAIL'
+        done
+    fi
+else
+    decrease_user_value "$OWNER" '$IPV6_AVAIL'
+fi
+
+# Restarting web server
+$BIN/v-restart-web
+check_result $? "Web restart failed" >/dev/null
+
+# Restarting proxy server
+if [ ! -z "$PROXY_SYSTEM" ]; then
+    $BIN/v-restart-proxy
+    check_result $? "Proxy restart failed" >/dev/null
+fi
+
+# Restarting firewall
+if [ ! -z "$FIREWALL_SYSTEM" ]; then
+    $BIN/v-update-firewall
+fi
+
+# Logging
+log_history "deleted system ip address $ip"
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 51 - 0
bin/v-list-firewall-ipv6

@@ -0,0 +1,51 @@
+#!/bin/bash
+# info: delete firewall rule
+# options: RULE
+#
+# The function deletes firewall rule.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing system variables
+source /etc/profile
+
+# Argument definition
+rule=$1
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/HESTIA.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'RULE'
+is_format_valid 'rule'
+is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
+is_object_valid '../../data/firewallv6/rules' 'RULE' "$rule"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Deleting rule
+sed -i "/RULE='$rule' /d" $HESTIA/data/firewallv6/rules.conf
+
+# Updating system firewall
+$BIN/v-update-firewall-ipv6
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 88 - 0
bin/v-list-firewall-ipv6-rule

@@ -0,0 +1,88 @@
+#!/bin/bash
+# info: list firewall rule
+# options: RULE [FORMAT]
+#
+# The function of obtaining firewall rule parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+rule=$1
+format=${2-shell}
+
+# Includes
+source $HESTIA/func/main.sh
+
+json_list() {
+    echo '{'
+    echo '    "'$RULE'": {
+        "ACTION": "'$ACTION'",
+        "PROTOCOL": "'$PROTOCOL'",
+        "PORT": "'$PORT'",
+        "IP6": "'$IP6'",
+        "COMMENT": "'$COMMENT'",
+        "SUSPENDED": "'$SUSPENDED'",
+        "TIME": "'$TIME'",
+        "DATE": "'$DATE'"
+    }'
+    echo '}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "ACTION:         $ACTION"
+    echo "PROTOCOL:       $PROTOCOL"
+    echo "PORT:           $PORT"
+    echo "IP6:            $IP6"
+    echo "COMMENT:        $COMMENT"
+    echo "SUSPENDED:      $SUSPENDED"
+    echo "TIME:           $TIME"
+    echo "DATE:           $DATE"
+}
+
+# PLAIN list function
+plain_list() {
+    echo -ne "$RULE\t$ACTION\t$PROTOCOL\t$PORT\t$IP6\t$COMMENT\t"
+    echo -e "$SUSPENDED\t$TIME\t$DATE"
+}
+
+# CSV list function
+csv_list() {
+    echo "RULE,ACTION,PROTOCOL,PORT,IP6,COMMENT,SUSPENDED,TIME,DATE"
+    echo "$RULE,$ACTION,$PROTOCOL,$PORT,$IP6,$COMMENT,$SUSPENDED,$TIME,$DATE"
+}
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'RULE [FORMAT]'
+is_number_format_valid "$rule" "rule id"
+is_object_valid '../../data/firewallv6/rules' 'RULE' "$rule"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Parsing rules
+eval $(grep "RULE='$rule'" $HESTIA/data/firewallv6/rules.conf)
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list ;;
+esac
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+exit

+ 49 - 0
bin/v-suspend-firewall-ipv6-rule

@@ -0,0 +1,49 @@
+#!/bin/bash
+# info: suspend firewall rule
+# options: RULE
+#
+# The function suspends a certain firewall rule.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+rule=$1
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/conf/HESTIA.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'RULE'
+is_format_valid 'rule'
+is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
+is_object_valid '../../data/firewallv6/rules' 'RULE' "$rule"
+is_object_unsuspended '../../data/firewallv6/rules' 'RULE' "$rule"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Suspending rule
+update_object_value ../../data/firewallv6/rules RULE $rule '$SUSPENDED' yes
+
+# Updating system firewall
+$BIN/v-update-firewall-ipv6
+
+
+#----------------------------------------------------------#
+#                       HESTIA                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 1 - 0
bin/v-update-firewall

@@ -11,6 +11,7 @@
 
 # Defining absolute path for iptables and modprobe
 iptables="/sbin/iptables"
+ip6tables="/sbin/ip6tables"
 modprobe="/sbin/modprobe"
 sysctl="/sbin/sysctl"
 

+ 224 - 0
func/ipv6.sh

@@ -0,0 +1,224 @@
+# Check ipv6 ownership
+is_ipv6_owner() {
+    owner=$(grep 'OWNER=' $HESTIA/data/ips/$ipv6 |cut -f 2 -d \')
+    if [ "$owner" != "$user" ]; then
+        check_result $E_FORBIDEN "$ipv6 is not owned by $user"
+    fi
+}
+
+# Check if ipv6 address is free
+is_ipv6_free() {
+    if [ -e "$HESTIA/data/ips/$ipv6" ]; then
+        check_result $E_EXISTS "$ipv6 is already exists"
+    fi
+}
+
+# Get full interface name
+get_ipv6_iface() {
+    i=$(/sbin/ip addr |grep -w $interface |\
+         awk '{print $NF}' |tail -n 1 |cut -f 2 -d :)
+    if [ "$i" = "$interface" ]; then
+        n=0
+    else
+        n=$((i + 1))
+    fi
+    echo "$interface:$n"
+}
+
+
+# Check ipv6 address speciefic value
+is_ipv6_key_empty() {
+    key="$1"
+    string=$(cat $HESTIA/data/ips/$ipv6)
+    eval $string
+    eval value="$key"
+    if [ ! -z "$value" ] && [ "$value" != '0' ]; then
+        key="$(echo $key|sed -e "s/\$U_//")"
+        check_result $E_EXISTS "IP6 is in use / $key = $value"
+    fi
+}
+
+# Update ipv6 address value
+update_ipv6_value() {
+    key="$1"
+    value="$2"
+    conf="$HESTIA/data/ips/$ipv6"
+    str=$(cat $conf)
+    eval $str
+    c_key=$(echo "${key//$/}")
+    eval old="${key}"
+    old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
+    new=$(echo "$value" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
+    sed -i "$str_number s/$c_key='${old//\*/\\*}'/$c_key='${new//\*/\\*}'/g"\
+        $conf
+}
+
+# Get ipv6 name
+get_ipv6_alias() {
+    ip_name=$(grep "NAME=" $HESTIA/data/ips/$ipv6 2> /dev/null |cut -f 2 -d \')
+    if [ ! -z "$ip_name" ]; then
+        echo "${1//./-}.$ip_name"
+    fi
+}
+
+# Increase ipv6 value
+increase_ipv6_value() {
+    sip=${1-ipv6}
+    if [ "$sip" != "no" ] && [ ! -z "$sip" ]; then
+        USER=$user
+        web_key='U_WEB_DOMAINS'
+        usr_key='U_SYS_USERS'
+        current_web=$(grep "$web_key=" $HESTIA/data/ips/$sip |cut -f 2 -d \')
+        current_usr=$(grep "$usr_key=" $HESTIA/data/ips/$sip |cut -f 2 -d \')
+        if [ -z "$current_web" ]; then
+            echo "Error: Parsing error"
+            log_event "$E_PARSING" "$ARGUMENTS"
+            exit $E_PARSING
+        fi
+        new_web=$((current_web + 1))
+        if [ -z "$current_usr" ]; then
+            new_usr="$USER"
+        else
+            check_usr=$(echo -e "${current_usr//,/\n}" |grep -w $USER)
+            if [ -z "$check_usr" ]; then
+                new_usr="$current_usr,$USER"
+            else
+                new_usr="$current_usr"
+            fi
+        fi
+
+        sed -i "s/$web_key='$current_web'/$web_key='$new_web'/g" \
+            $HESTIA/data/ips/$sip
+        sed -i "s/$usr_key='$current_usr'/$usr_key='$new_usr'/g" \
+            $HESTIA/data/ips/$sip
+    fi
+}
+
+# Decrease ipv6 value
+decrease_ipv6_value() {
+    sip=${1-ipv6}
+    if [ "$sip" != "no" ] && [ ! -z "$sip" ]; then
+        USER=$user
+        web_key='U_WEB_DOMAINS'
+        usr_key='U_SYS_USERS'
+
+        current_web=$(grep "$web_key=" $HESTIA/data/ips/$sip |cut -f 2 -d \')
+        current_usr=$(grep "$usr_key=" $HESTIA/data/ips/$sip |cut -f 2 -d \')
+
+        if [ -z "$current_web" ]; then
+            check_result $E_PARSING "Parsing error"
+        fi
+
+        new_web=$((current_web - 1))
+        check_ip=$(grep $sip $USER_DATA/web.conf |wc -l)
+        if [ "$check_ip" -lt 2 ]; then
+            new_usr=$(echo "$current_usr" |\
+                sed "s/,/\n/g"|\
+                sed "s/^$user$//g"|\
+                sed "/^$/d"|\
+                sed ':a;N;$!ba;s/\n/,/g')
+        else
+            new_usr="$current_usr"
+        fi
+
+        sed -i "s/$web_key='$current_web'/$web_key='$new_web'/g" \
+            $HESTIA/data/ips/$sip
+        sed -i "s/$usr_key='$current_usr'/$usr_key='$new_usr'/g" \
+            $HESTIA/data/ips/$sip
+    fi
+}
+
+# Get ipv6 address value
+get_ipv6_value() {
+    key="$1"
+    string=$(cat $HESTIA/data/ips/$ip)
+    eval $string
+    eval value="$key"
+    echo "$value"
+}
+
+
+# Get real ipv6 address
+get_real_ipv6() {
+    if [ -e "$HESTIA/data/ips/$1" ]; then
+        echo $1
+    else
+        nat=$(grep -H "^NAT='$1'" $HESTIA/data/ips/*)
+        if [ ! -z "$nat" ]; then
+            echo "$nat" |cut -f 1 -d : |cut -f 7 -d /
+        fi
+    fi
+}
+
+# Convert CIDR to netmask
+convert_cidrv6() {
+    set -- $(( 5 - ($1 / 8) )) 255 255 255 255 \
+        $(((255 << (8 - ($1 % 8))) & 255 )) 0 0 0
+    if [[ $1 -gt 1 ]]; then
+        shift $1
+    else
+        shift
+    fi
+    echo ${1-0}.${2-0}.${3-0}.${4-0}
+}
+
+# Convert netmask to CIDR
+convert_netmaskv6() {
+    nbits=0
+    IFS=.
+    for dec in $1 ; do
+        case $dec in
+            255) let nbits+=8;;
+            254) let nbits+=7;;
+            252) let nbits+=6;;
+            248) let nbits+=5;;
+            240) let nbits+=4;;
+            224) let nbits+=3;;
+            192) let nbits+=2;;
+            128) let nbits+=1;;
+            0);;
+        esac
+    done
+    echo "$nbits"
+}
+
+# Get user ips
+get_user_ip6s() {
+    dedicated=$(grep -H -A10 "OWNER='$user'" $HESTIA/data/ips/* |grep "VERSION='6'")
+    dedicated=$(echo "$dedicated" |cut -f 1 -d '-' |sed 's=.*/==')
+    shared=$(grep -H -A10 "OWNER='admin'" $HESTIA/data/ips/* |grep -A10 shared |grep "VERSION='6'")
+    shared=$(echo "$shared" |cut -f 1 -d '-' |sed 's=.*/==' |cut -f 1 -d \-)
+    for dedicated_ip in $dedicated; do
+        shared=$(echo "$shared" |grep -v $dedicated_ip)
+    done
+    echo -e "$dedicated\n$shared" |sed "/^$/d"
+}
+
+# Get user ipv6
+get_user_ipv6() {
+    ipv6=$(get_user_ip6s |head -n1)
+    if [ -z "$ipv6" ]; then
+        ipv6="no"
+        #check_result $E_NOTEXIST "no IP6 is available"
+    fi
+}
+
+# Validate ipv6 address
+is_ipv6_valid() {
+    ipv6="$1"
+    if [ ! -e "$HESTIA/data/ips/$1" ]; then
+        check_result $E_NOTEXIST "IP6 $1 doesn't exist"
+    fi
+    if [ ! -z $2 ]; then
+        ip_data=$(cat $HESTIA/data/ips/$1)
+        ip_owner=$(echo "$ip_data" |grep OWNER= |cut -f2 -d \')
+        ip_status=$(echo "$ip_data" |grep STATUS= |cut -f2 -d \')
+        if [ "$ip_owner" != "$user" ] && [ "$ip_status" = 'dedicated' ]; then
+            check_result $E_FORBIDEN "$user user can't use IP6 $1"
+        fi
+        get_user_owner
+        if [ "$ip_owner" != "$user" ] && [ "$ip_owner" != "$owner" ]; then
+            check_result $E_FORBIDEN "$user user can't use IP6 $1"
+        fi
+    fi
+}

+ 69 - 0
install/upgrade/manual/add_ipv6.sh

@@ -0,0 +1,69 @@
+#!/bin/bash
+source /etc/profile.d/hestia.sh
+source /usr/local/hestia/func/main.sh
+
+#Download firewallv6 templates
+if [ ! -e "$HESTIA/data/firewallv6" ]; then
+    mkdir -p $HESTIA/data/firewallv6
+    chmod 770 $HESTIA/data/firewallv6
+
+    cp $HESTIA/install/rhel/6/firewallv6/* \
+        $HESTIA/data/firewallv6/
+    chmod 660 $HESTIA/data/firewallv6/*
+
+fi
+
+#download new templates
+if [ -z $0 ]; then
+	$BIN/v-update-web-templates
+	$BIN/v-update-dns-templates
+fi
+#testing
+#rm -rf /usr/local/hestia/data/templates/*
+# cp -rf /usr/local/hestia/install/rhel/7/templates/* /usr/local/hestia/data/templates/es/
+
+#set IPv4 version
+iplist=$(ls --sort=time $HESTIA/data/ips/)
+for ip in $iplist; do
+	echo "VERSION='4'" >> $HESTIA/data/ips/$ip
+done
+
+#Add IP6 field
+ipv6=$(ip addr show | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | grep -ve "^fe80" | tail -1)
+ipv6use=""
+if [ ! -z "$ipv6" ] && [ "::1" != "$ipv6" ]; then
+    netmask="ip addr show | grep '$ipv6' | awk -F '/' '{print \$2}' | awk '{print \$1}'"
+    netmask=$(eval $netmask)
+    $HESTIA/bin/v-add-sys-ipv6 $ipv6 $netmask
+    $BIN/v-update-firewall-ipv6
+    ipv6use=$ipv6
+fi
+
+#set IPv6
+userlist=$(ls --sort=time $HESTIA/data/users/)
+for user in $userlist; do
+    USER_DATA="$HESTIA/data/users/$user"
+
+    #UPDATE WEB
+    conf="$USER_DATA/web.conf"
+    while read line ; do
+        eval $line
+        update_object_value 'web' 'DOMAIN' "$DOMAIN" '$IP6' "$ipv6use"
+    done < $conf
+
+    #UPDATE DNS
+    conf="$USER_DATA/dns.conf"
+    while read line ; do
+        eval $line
+        if [ "$(echo $line | grep 'IP6=')" == "" ]; then
+	          sed -i "s/DOMAIN='$DOMAIN' IP='$IP'/DOMAIN='$DOMAIN' IP='$IP' IP6='$ipv6use'/g" "$conf"
+        else
+            update_object_value 'dns' 'DOMAIN' "$DOMAIN" '$IP6' "$ipv6use"
+        fi
+    done < $conf
+    $BIN/v-rebuild-user $user
+done
+
+$BIN/v-update-sys-ip-counters
+
+$BIN/v-add-user-notification admin "IPv6 support" "Your hestia installation supports IPv6!"