vesta/bin/v_suspend_dns_domains
2011-06-14 00:22:25 +03:00

74 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# info: suspening dns domains
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
# 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 '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking dns system is enabled
is_system_enabled 'dns'
# Checking user
is_user_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/dns.conf"
# Defining fileds to select
field='$DOMAIN'
# Defining search string
search_string="SUSPEND='no'"
# Parsing unsuspeneded domains
domains=$(dom_clear_search)
# Starting suspend loop
for domain in $domains; do
# Defining named config
conf="/etc/named.conf"
rm_string=$(grep -n /etc/namedb/$domain.db $conf|cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $conf
fi
# Adding suspend in config
update_dns_domain_value '$SUSPEND' 'yes'
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'dns'
# Logging
log_event 'system' "$V_EVENT"
exit $OK