Răsfoiți Sursa

IPV6: Enancement in change system IP scripts

bin/v-change-sys-ip-xxx
asmcc 3 ani în urmă
părinte
comite
8919b40138
5 a modificat fișierele cu 25 adăugiri și 18 ștergeri
  1. 2 1
      bin/v-change-sys-ip-name
  2. 1 0
      bin/v-change-sys-ip-nat
  3. 4 3
      bin/v-change-sys-ip-owner
  4. 2 1
      bin/v-change-sys-ip-status
  5. 16 13
      func/ip.sh

+ 2 - 1
bin/v-change-sys-ip-name

@@ -3,6 +3,7 @@
 # options: IP NAME
 #
 # example: v-change-sys-ip-name 80.122.52.70 acme.com
+# example: v-change-sys-ip-name 1111:2222:3333::1 acme.com
 #
 # This function for changing dns domain associated with ip.
 
@@ -53,7 +54,7 @@ check_hestia_demo_mode
 #----------------------------------------------------------#
 
 # Changing ip name
-update_ip_value '$NAME' "$ip_name"
+update_ip_value '$NAME' "$ip_name" "${ip46}"
 
 #----------------------------------------------------------#
 #                       Hestia                             #

+ 1 - 0
bin/v-change-sys-ip-nat

@@ -3,6 +3,7 @@
 # options: IP NAT_IP [RESTART]
 #
 # example: v-change-sys-ip-nat 185.209.50.140 10.110.104.205
+# example: v-change-sys-ip-nat 1111:2222:3333::1 ''
 #
 # This function for changing nat ip associated with ip.
 

+ 4 - 3
bin/v-change-sys-ip-owner

@@ -3,6 +3,7 @@
 # options: IP USER
 #
 # example: v-change-sys-ip-owner 91.198.136.14 admin
+# example: v-change-sys-ip-owner 1111:2222:3333::1 admin
 #
 # This function of changing ip address ownership.
 
@@ -45,8 +46,8 @@ fi
 is_format_valid 'user'
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
-is_ip_key_empty '$U_WEB_DOMAINS'
-is_ip_key_empty '$U_SYS_USERS'
+is_ip_key_empty '$U_WEB_DOMAINS' "${ip46}"
+is_ip_key_empty '$U_SYS_USERS' "${ip46}"
 
 ip_status="$(get_ip_value '$STATUS')"
 
@@ -60,7 +61,7 @@ check_hestia_demo_mode
 # Changing ip owner
 ip_owner=$(get_ip_value '$OWNER')
 if [ "$ip_owner" != "$user" ]; then
-	update_ip_value '$OWNER' "$user"
+	update_ip_value '$OWNER' "$user" "${ip46}"
 	decrease_user_value "$ip_owner" '$IP_OWNED'
 	if [ "$ip_owner" = 'admin' ]; then
 		if [ "$ip_status" = 'shared' ]; then

+ 2 - 1
bin/v-change-sys-ip-status

@@ -3,6 +3,7 @@
 # options: IP IP_STATUS
 #
 # example: v-change-sys-ip-status 91.198.136.14 yourstatus
+# example: v-change-sys-ip-status 1111:2222:3333::1 yourstatus
 #
 # This function of changing an ip address's status.
 
@@ -65,7 +66,7 @@ check_hestia_demo_mode
 #----------------------------------------------------------#
 
 # Changing ip name
-update_ip_value '$STATUS' "$ip_status"
+update_ip_value '$STATUS' "$ip_status" "${ip46}"
 
 #----------------------------------------------------------#
 #                       Hestia                             #

+ 16 - 13
func/ip.sh

@@ -23,8 +23,7 @@ is_ip_owner() {
 
 # Check if ip address is free
 is_ip_free() {
-	# ip address (ipv4/ipv6) as first parameter, otherwise $ip (ipv4)
-	ip_for_test="${1-$ip}"
+	ip_for_test="${1-$ip}" # ip address (ipv4/ipv6) as first parameter, otherwise $ip (ipv4)
 	if [ -e "$HESTIA/data/ips/$ip_for_test" ]; then
 		check_result "$E_EXISTS" "$ip_for_test is already exists"
 	fi
@@ -33,8 +32,7 @@ is_ip_free() {
 # Check ip address specific value
 is_ip_key_empty() {
 	key="$1"
-	# ip address (ipv4/ipv6) as second parameter, otherwise $ip (ipv4)
-	ip_for_test="${2-$ip}"
+	ip_for_test="${2-$ip}" # ip address (ipv4/ipv6) as second parameter, otherwise $ip (ipv4)
 	if [ -n "$ip_for_test" ]; then
 		string=$(cat $HESTIA/data/ips/$ip_for_test)
 		eval $string
@@ -70,15 +68,20 @@ is_ip_rdns_valid() {
 update_ip_value() {
 	key="$1"
 	value="$2"
-	conf="$HESTIA/data/ips/$ip"
-	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
+	ip_for_update="${3-$ip}" # ip address (ipv4/ipv6) as third parameter, otherwise $ip (ipv4)
+	if [ -n "$ip_for_update" ]; then
+		conf="$HESTIA/data/ips/$ip_for_update"
+		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
+	else
+		check_result 1 "is_ip_key_empty(): IP address is empty!"
+	fi
 }
 
 # New method that is improved on a later date we need to check if we can improve it for other locations