|
|
@@ -11,8 +11,8 @@
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
# Argument definition
|
|
|
-ip=$1
|
|
|
-ip_status=$2
|
|
|
+ip46=${1}
|
|
|
+ip_status=${2}
|
|
|
|
|
|
# Includes
|
|
|
# shellcheck source=/etc/hestiacp/hestia.conf
|
|
|
@@ -29,8 +29,21 @@ source_conf "$HESTIA/conf/hestia.conf"
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
check_args '2' "$#" 'IP IP_STATUS'
|
|
|
-is_format_valid 'ip' 'ip_status'
|
|
|
-is_ip_valid "$ip"
|
|
|
+ip_format="$(get_ip_format ${ip46})" # ip verification and format identification
|
|
|
+if [ -n "$ip_format" ]; then
|
|
|
+ if [ $ip_format -eq 6 ]; then
|
|
|
+ ip=""
|
|
|
+ ipv6="${ip46}"
|
|
|
+ is_format_valid 'ipv6'
|
|
|
+ is_ip_valid "$ipv6"
|
|
|
+ else
|
|
|
+ ip="${ip46}"
|
|
|
+ ipv6=""
|
|
|
+ is_format_valid 'ip'
|
|
|
+ is_ip_valid "$ip"
|
|
|
+ fi
|
|
|
+fi
|
|
|
+is_format_valid 'ip_status'
|
|
|
if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then
|
|
|
check_result "$E_EXISTS" "status $ip_status is already set"
|
|
|
fi
|
|
|
@@ -38,10 +51,10 @@ web_domains=$(get_ip_value '$U_WEB_DOMAINS')
|
|
|
sys_user=$(get_ip_value '$U_SYS_USERS')
|
|
|
ip_owner=$(get_ip_value '$OWNER')
|
|
|
if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
|
|
|
- check_result "$E_INUSE" "ip $ip is used"
|
|
|
+ check_result "$E_INUSE" "ip ${ip46} is used"
|
|
|
fi
|
|
|
if [ "$ip_owner" != "admin" ] && [ "$ip_status" == "shared" ]; then
|
|
|
- $BIN/v-change-sys-ip-owner "$ip" "admin"
|
|
|
+ $BIN/v-change-sys-ip-owner "${ip46}" "admin"
|
|
|
fi
|
|
|
|
|
|
# Perform verification if read-only mode is enabled
|
|
|
@@ -59,7 +72,7 @@ update_ip_value '$STATUS' "$ip_status"
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
# Logging
|
|
|
-$BIN/v-log-action "system" "Info" "System" "IP address status changed (Status: $ip_status, IP: $ip)."
|
|
|
+$BIN/v-log-action "system" "Info" "System" "IP address status changed (Status: $ip_status, IP: ${ip46})."
|
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
|
|
exit
|