myvesta/bin/v-change-sys-ipv6-status
2024-04-14 22:28:39 +02:00

57 lines
1.6 KiB
Bash

#!/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 $VESTA/func/main.sh
source $VESTA/func/ipv6.sh
source $VESTA/conf/vesta.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"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_history "changed $ipv6 status to $ip_status" '' 'admin'
log_event "$OK" "$ARGUMENTS"
exit