new improved template scheme

This commit is contained in:
Serghey Rodin 2013-05-10 11:04:40 +03:00
commit fd4e68bb8c
96 changed files with 1395 additions and 1425 deletions

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: add dns domain
# options: USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4] [RESTART]
# options: USER DOMAIN IP [NS1] [NS2] [NS3] [NS4] [RESTART]
#
# The function adds DNS zone with records defined in the template. If the exp
# argument isn't stated, the expiration date value will be set to next year.
@ -20,12 +20,11 @@ domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
template=$4
ns1=$5
ns2=$6
ns3=$7
ns4=$8
restart=$9
ns1=$4
ns2=$5
ns3=$6
ns4=$7
restart=$8
# Includes
source $VESTA/conf/vesta.conf
@ -37,36 +36,32 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4]'
check_args '3' "$#" 'USER DOMAIN IP [NS1] [NS2] [NS3] [NS4]'
validate_format 'user' 'domain' 'ip'
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_domain_new 'dns'
is_package_full 'DNS_DOMAINS'
if [ ! -z "$template" ]; then
validate_format 'template'
is_dns_template_valid
else
template=$(get_user_value '$TEMPLATE')
is_dns_template_valid
fi
template=$(get_user_value '$DNS_TEMPLATE')
is_dns_template_valid
if [ ! -z "$ns1" ]; then
ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns1=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns1'
fi
if [ ! -z "$ns2" ]; then
ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns2=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns2'
fi
if [ ! -z "$ns3" ]; then
ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns3=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns3'
fi
if [ ! -z "$ns4" ]; then
ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns4=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns4'
fi
@ -75,7 +70,7 @@ fi
# Action #
#----------------------------------------------------------#
# Defining variables
# Defining NS variables
if [ -z $ns2 ]; then
i=1
ns=$(get_user_value '$NS')
@ -88,7 +83,6 @@ soa="$ns1"
exp=$(date +%F -d "+ 1 year")
ttl=14400
# Adding zone to dns dir
cat $DNSTPL/$template.tpl |\
sed -e "s/%ip%/$ip/g" \