mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-01-23 11:13:01 -08:00
74 lines
1.7 KiB
Bash
Executable File
74 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: changing dns domain ip
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
user="$1"
|
|
domain=$(idn -t --quiet -u "$2" )
|
|
domain_idn=$(idn -t --quiet -a "$domain")
|
|
ip="$3"
|
|
|
|
# Importing variables
|
|
source $VESTA/conf/vars.conf
|
|
source $V_FUNC/shared_func.sh
|
|
source $V_FUNC/domain_func.sh
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
# Checking arg number
|
|
check_args '3' "$#" 'user domain ip'
|
|
|
|
# Checking argument format
|
|
format_validation 'user' 'domain' 'ip'
|
|
|
|
# Checking web system is enabled
|
|
is_system_enabled 'dns'
|
|
|
|
# Checking user
|
|
is_user_valid
|
|
|
|
# Checking user is active
|
|
is_user_suspended
|
|
|
|
# Checking domain exist
|
|
is_dns_domain_valid
|
|
|
|
# Checking domain is not suspened
|
|
is_domain_suspended 'dns'
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Get old ip
|
|
old_ip=$(get_dns_domain_value '$IP')
|
|
|
|
# Changing ip
|
|
update_dns_domain_value '$IP' "$ip"
|
|
|
|
# Changing records
|
|
sed -i "s/$old_ip/$ip/g" $V_USERS/$user/zones/$domain
|
|
|
|
# Updating zone
|
|
update_domain_zone
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Adding task to the vesta pipe
|
|
restart_schedule 'dns'
|
|
|
|
# Logging
|
|
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ip"
|
|
log_event 'system' "$V_EVENT"
|
|
|
|
exit $OK
|