| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #!/bin/bash
- # info: change dns domain ip address
- # options: user domain ip
- #
- # The function for changing the main ip of DNS zone.
- #----------------------------------------------------------#
- # 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_CONF/vesta.conf
- source $V_FUNC/shared.func
- source $V_FUNC/domain.func
- #----------------------------------------------------------#
- # 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/dns/$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
|