Files
VestaCP/bin/v-insert-dns-record

57 lines
1.5 KiB
Plaintext
Raw Normal View History

2013-05-19 15:00:08 +03:00
#!/bin/bash
2013-05-28 16:09:07 +03:00
# info: insert dns record
2013-06-01 14:25:44 +03:00
# options: USER DOMAIN DATA [RESTART]
2013-05-19 15:00:08 +03:00
#
2013-05-28 16:09:07 +03:00
# The function inserts raw dns record to the domain conf
2013-05-19 15:00:08 +03:00
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Argument definition
2013-05-19 15:00:08 +03:00
user=$1
2013-05-28 16:09:07 +03:00
domain=$2
data=$3
2013-06-01 14:25:44 +03:00
restart=$4
2013-05-19 15:00:08 +03:00
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
2013-05-19 15:00:08 +03:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
2013-06-01 14:25:44 +03:00
check_args '3' "$#" 'USER DOMAIN DATA [RESTART]'
2013-05-28 16:09:07 +03:00
validate_format 'user' 'domain' 'data'
2013-05-29 13:16:09 +03:00
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
2013-05-19 15:00:08 +03:00
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
2013-05-28 16:09:07 +03:00
# Insert values
echo "$data" >> $USER_DATA/dns/$domain.conf
2013-05-19 15:00:08 +03:00
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
2015-10-28 16:34:41 +02:00
# Restarting named
2013-06-01 14:25:44 +03:00
if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns $restart
2015-10-28 16:34:41 +02:00
check_result $? "Bind restart failed" >/dev/null
2013-06-01 14:25:44 +03:00
fi
2013-05-19 15:00:08 +03:00
# Logging
log_event "$OK" "$EVENT"
exit