mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-02-03 16:43:09 -08:00
77 lines
2.0 KiB
Bash
Executable File
77 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: suspend dns domain record
|
|
# options: USER DOMAIN ID [RESTART]
|
|
#
|
|
# The function suspends a certain domain record.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument defenition
|
|
user=$1
|
|
domain=$(idn -t --quiet -u "$2" )
|
|
domain_idn=$(idn -t --quiet -a "$domain")
|
|
id=$3
|
|
restart="$4"
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/func/domain.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '3' "$#" 'USER DOMAIN ID [RESTART]'
|
|
validate_format 'user' 'domain' 'id'
|
|
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_valid 'dns' 'DOMAIN' "$domain"
|
|
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
|
|
is_object_valid "dns/$domain" 'ID' "$id"
|
|
is_object_unsuspended "dns/$domain" 'ID' "$id"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
|
|
eval $line
|
|
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
|
|
|
|
# Adding record
|
|
dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'"
|
|
dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'"
|
|
echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
|
|
|
|
# Sorting records
|
|
sort_dns_records
|
|
|
|
# Updating zone
|
|
if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
|
|
update_domain_zone
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Restart named
|
|
#if [ "$restart" != 'no' ]; then
|
|
# $BIN/v-restart-dns
|
|
# if [ $? -ne 0 ]; then
|
|
# exit $E_RESTART
|
|
# fi
|
|
#fi
|
|
|
|
# Logging
|
|
log_event "$OK" "$EVENT"
|
|
|
|
exit
|