Browse Source

IPV6: Remove needless file to delete sys ipv6

asmcc 3 years ago
parent
commit
3af68f7676
1 changed files with 0 additions and 165 deletions
  1. 0 165
      bin/v-delete-sys-ipv6

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

@@ -1,165 +0,0 @@
-#!/bin/bash
-# info: delete system ipv6
-# options: IPV6
-#
-# example: v-delete-sys-ipv6 1234:5678::1
-#
-# This function for deleting a system ipv6. It does not allow
-# to delete ip which is used by a web domain.
-
-#----------------------------------------------------------#
-#                Variables & Functions                     #
-#----------------------------------------------------------#
-
-# Argument definition
-ipv6=$1
-
-# Includes
-# shellcheck source=/etc/hestiacp/hestia.conf
-source /etc/hestiacp/hestia.conf
-# shellcheck source=/usr/local/hestia/func/main.sh
-source $HESTIA/func/main.sh
-# shellcheck source=/usr/local/hestia/func/ip.sh
-source $HESTIA/func/ip.sh
-# shellcheck source=/usr/local/hestia/func/domain.sh
-source $HESTIA/func/domain.sh
-# load config file
-source_conf "$HESTIA/conf/hestia.conf"
-
-#----------------------------------------------------------#
-#                    Verifications                         #
-#----------------------------------------------------------#
-
-check_args '1' "$#" 'IPV6'
-is_format_valid 'ipv6'
-is_ipv6_valid "$ipv6"
-is_ipv6_key_empty '$U_WEB_DOMAINS'
-is_ipv6_key_empty '$U_SYS_USERS'
-
-# Perform verification if read-only mode is enabled
-check_hestia_demo_mode
-
-#----------------------------------------------------------#
-#                       Action                             #
-#----------------------------------------------------------#
-
-# Import ip variables
-source "$HESTIA/data/ips/$ipv6"
-
-# Checking main ip on the interface
-interface=$(/sbin/ip  -6 addr | grep "$ipv6${NETMASK}" | awk '{print $NF}')
-if [ $(/sbin/ip -6 addr | grep -c global) -le 1 ]; then
-    echo "Error: can't delete main IP address"
-    log_event "$E_FORBIDEN" "$ARGUMENTS"
-    exit "$E_FORBIDEN"
-fi
-
-# Deleting system ip
-if [ -n "$interface" ]; then
-    /sbin/ip -6 addr del $ipv6${NETMASK} 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 [ -f "/etc/netplan/60-hestia.yaml" ]; then
-    sed -i "/$ipv6/d" /etc/netplan/60-hestia.yaml
-    if ! grep -q '-' /etc/netplan/60-hestia.yaml; then
-        rm /etc/netplan/60-hestia.yaml
-    fi
-elif [ -e "/etc/network/interfaces" ]; then
-    ip_str=$(grep -n $ipv6 /etc/network/interfaces |cut -f1 -d:)
-    if [ -n "$ip_str" ]; then
-		first_str=$((ip_str - 4))
-		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 [ -n "$WEB_SYSTEM" ]; then
-    rm -f /etc/$WEB_SYSTEM/conf.d/$ipv6.conf
-fi
-
-# Deleting proxy config
-if [ -n "$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 "$ips" | sed "s/$ipv6//")
-        sed -i "s/$ips/$new_ips/g" "$rpaf_conf"
-
-        # Remove RPAFproxy_ips line when ip list is empty
-        [ "$(grep RPAFproxy_ips $rpaf_conf | sed 's/^[[:space:]]*//g')" = "RPAFproxy_ips" ] && sed -i "/RPAFproxy_ips/d" $rpaf_conf
-    fi
-    
-    #mod_remoteip
-    remoteip_conf="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
-    if [ -e "$remoteip_conf" ]; then
-        sed -i "/RemoteIPInternalProxy $ipv6\$/d" "$remoteip_conf"
-    fi
-fi
-
-#----------------------------------------------------------#
-#                       Hestia                             #
-#----------------------------------------------------------#
-
-# Updating user conf
-if [ -n "$OWNER" ]; then
-    decrease_user_value "$OWNER" '$IPV6_OWNED'
-fi
-
-if [ "$OWNER" = 'admin' ]; then
-    if [ "$STATUS" = 'shared' ]; then
-        for hestia_user in $($HESTIA/bin/v-list-sys-users plain); do
-            decrease_user_value "$hestia_user" '$IPV6_AVAIL'
-        done
-    else
-        decrease_user_value "$OWNER" '$IPV6_AVAIL'
-    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 [ -n "$PROXY_SYSTEM" ]; then
-    $BIN/v-restart-proxy
-    check_result $? "Proxy restart failed" >/dev/null
-fi
-
-# Restarting firewall
-if [ -n "$FIREWALL_SYSTEM" ]; then
-    $BIN/v-update-firewall
-fi
-
-# Logging
-$BIN/v-log-action "system" "Info" "System" "IPV6 address deleted (IPV6: $ipv6)."
-log_event "$OK" "$ARGUMENTS"
-
-exit