myvesta/bin/v-delete-dns-domains-src
2015-10-28 16:34:41 +02:00

56 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# info: delete dns domains based on SRC field
# options: USER SRC [RESTART]
#
# The function for deleting DNS domains related to a certain host.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
src=$2
restart=$3
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER SRC [RESTART]'
validate_format 'user' 'src'
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Starting delete loop
for domain in $(search_objects 'dns' 'SRC' "$src" 'DOMAIN'); do
$BIN/v-delete-dns-domain "$user" "$domain" 'no'
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Restart named
if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns
check_result $? "Bind restart failed" >/dev/null
fi
# Logging
log_event "$OK" "$EVENT"
exit