Refactoring stage II

This commit is contained in:
Serghey Rodin 2012-03-08 23:37:03 +02:00
commit b998c72500
88 changed files with 422 additions and 896 deletions

View file

@ -33,7 +33,7 @@ check_args '7' "$#" 'user min hour day month wday command [job]'
validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_package_full 'CRON_JOBS'
get_next_cronjob
validate_format 'job'

View file

@ -26,7 +26,7 @@ check_args '1' "$#" 'user'
validate_format 'user'
is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -40,7 +40,7 @@ validate_format 'user' 'database' 'db_user' 'db_password' 'encoding'
is_system_enabled 'DB_SYSTEM'
is_type_valid "$DB_SYSTEM" "$type"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_free 'db' 'DB' "$database"
get_next_dbhost
is_object_valid "$type" 'DBHOST' "$host"

View file

@ -25,7 +25,7 @@ exp=${5-$next_year}
soa=$6
ttl=${7-14400}
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
@ -35,30 +35,16 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '3' "$#" 'user domain ip [template] [exp] [soa] [ttl]'
# Checking argument format
validate_format 'user' 'domain' 'ip' 'template' 'exp' 'ttl'
# Checking dns system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_object_unsuspended 'user' 'USER' "$user"
is_domain_new 'dns'
# Checking package
is_package_full 'DNS_DOMAINS'
# Checking template
is_dns_template_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
@ -68,9 +54,10 @@ i=1
ns=$(get_user_value '$NS')
for nameserver in ${ns//,/ };do
eval ns$i=$nameserver
i=$((i + 1))
(( ++i))
done
# Define soa
if [ -z "$soa" ]; then
soa="$ns1"
fi
@ -88,13 +75,16 @@ cat $DNSTPL/$template.tpl |\
-e "s/%ns6%/$ns6/g" \
-e "s/%ns7%/$ns7/g" \
-e "s/%ns8%/$ns8/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain
records="$(wc -l $USER_DATA/dns/$domain)"
-e "s/%time%/$TIME/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
chmod 660 $USER_DATA/dns/$domain.conf
records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
# Adding dns.conf record
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' DATE='$DATE'"
dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'"
dns_rec="$dns_rec DATE='$DATE'"
echo "$dns_rec" >> $USER_DATA/dns.conf
chmod 660 $USER_DATA/dns.conf
@ -104,7 +94,6 @@ named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};"
echo "$named" >> /etc/named.conf
# Updating domain dns zone
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
chmod 640 $conf
@ -119,11 +108,11 @@ chown root:named $conf
increase_user_value "$user" '$U_DNS_DOMAINS'
increase_user_value "$user" '$U_DNS_RECORDS' "$records"
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging
log_history "$EVENT" "v_delete_dns_domain $user $domain"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: add dns domain record
# options: user domain record type value [id]
# options: user domain record type value [id] [priority]
#
# The call is used for adding new DNS record. Complex records of TXT, MX and
# SRV types can be used by a filling in the 'value' argument. The function also
@ -23,8 +23,9 @@ rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
dvalue=$(idn -t --quiet -u "$5" )
dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]')
id=$6
priority=$7
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
@ -34,59 +35,37 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '5' "$#" 'user domain record type value [id]'
# Checking argument format
check_args '5' "$#" 'user domain record type value [id] [priority]'
validate_format 'user' 'domain' 'record' 'rtype' 'dvalue'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is active
is_domain_suspended 'dns'
# Checking package
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_package_full 'DNS_RECORDS'
# Defining if emtpy
if [ -z "$id"] ; then
id=$(get_next_dns_record)
fi
# Checking id format
get_next_dnsrecord
validate_format 'id'
# Checking id
is_dns_record_free
is_object_free "dns/$domain" 'ID' "$id"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining zone path
zone="$USER_DATA/dns/$domain"
if [ "$rtype" != 'MX' ] || [ "$rtype" != 'SRV' ]; then
priority=''
fi
# Adding record
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$dvalue'"
dns_rec="$dns_rec SUSPENDED='no' DATE='$DATE'"
echo "$dns_rec" >> $zone
zone="$USER_DATA/dns/$domain.conf"
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'"
dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
echo "$dns_rec" >> $zone
# Sorting records
sort_dns_records
# Updating zone
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
@ -94,18 +73,16 @@ update_domain_zone
# Vesta #
#----------------------------------------------------------#
# Updating dns domain values
records="$(wc -l $USER_DATA/dns/$domain)"
update_domain_value 'dns' '$RECORDS' "$records"
# Updating user counters
# Upddate counters
records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
increase_user_value "$user" '$U_DNS_RECORDS'
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging
log_history "$EVENT" "v_delete_dns_domain_record $user $domain $id"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -41,7 +41,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -40,7 +40,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -30,11 +30,11 @@ check_args '4' "$#" 'user domain account alias'
validate_format 'user' 'domain' 'account' 'malias'
is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_suspended 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_suspended "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
is_key_empty "mail/$domain" '' '$AUTOREPLY'
exit

View file

@ -42,7 +42,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_new 'mail'

View file

@ -38,7 +38,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -38,7 +38,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -39,7 +39,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -39,7 +39,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -46,7 +46,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_new 'dns'

View file

@ -42,7 +42,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -40,7 +40,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -38,7 +38,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -42,7 +42,7 @@ is_system_enabled 'proxy'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -45,7 +45,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -42,7 +42,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user" "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -38,7 +38,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -33,7 +33,7 @@ check_args '7' "$#" 'user job min hour day month wday command'
validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job"

View file

@ -38,7 +38,7 @@ is_system_enabled 'DB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking db existance
is_db_valid

View file

@ -16,47 +16,31 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
exp=$3
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '3' "$#" 'user domain exp'
# Checking argument format
validate_format 'user' 'domain' 'exp'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get old expiriation date
old_exp=$(get_domain_value 'dns' '$EXP')
# Changing exp
update_domain_value 'dns' '$EXP' "$exp"
update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp"
#----------------------------------------------------------#
@ -64,7 +48,7 @@ update_domain_value 'dns' '$EXP' "$exp"
#----------------------------------------------------------#
# Logging
log_history "$EVENT" "$SCRIPT $user $domain $old_exp"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -15,49 +15,34 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '3' "$#" 'user domain ip'
# Checking argument format
validate_format 'user' 'domain' 'ip'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get old ip
old_ip=$(get_domain_value 'dns' '$IP')
# Changing ip
update_domain_value 'dns' '$IP' "$ip"
update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip"
# Changing records
sed -i "s/$old_ip/$ip/g" $USER_DATA/dns/$domain
sed -i "s/$old_ip/$ip/g" $USER_DATA/dns/$domain.conf
# Updating zone
update_domain_zone
@ -67,11 +52,11 @@ update_domain_zone
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging
log_history "$EVENT" "$SCRIPT $user $domain $old_ip"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: change dns domain record
# options: user domain id record type value
# options: user domain record type value id [priority]
#
# The function for changing DNS record.
@ -12,13 +12,17 @@
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
id=$3
record=$(idn -t --quiet -u "$4" )
rtype=$(echo "$5"| tr '[:lower:]' '[:upper:]')
value=$(idn -t --quiet -u "$6" )
record=$(idn -t --quiet -u "$3" )
record=$(echo $record | tr '[:upper:]' '[:lower:]')
rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
dvalue=$(idn -t --quiet -u "$5" )
dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]')
id=$6
priority=$7
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
@ -28,47 +32,31 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '5' "$#" 'user domain id record type value'
# Checking argument format
validate_format 'user' 'domain' 'id' 'record' 'rtype'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
check_args '6' "$#" 'user domain record type value id [priority]'
validate_format 'user' 'domain' 'record' 'rtype' 'dvalue' 'id'
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_object_valid "dns/$domain" 'ID' "$id"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
# Checking record valid
is_dns_record_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining zone path
zone="$USER_DATA/dns/$domain"
# Deleting old record
rm_string=$(grep -n "^ID='$id'" $zone|cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $zone
if [ "$rtype" != 'MX' ] || [ "$rtype" != 'SRV' ]; then
priority=''
fi
# Deleting old record
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
# Adding record
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$value'"
dns_rec="$dns_rec SUSPENDED='no' DATE='$DATE'"
echo "$dns_rec" >> $zone
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'"
dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
# Sorting records
sort_dns_records
@ -81,7 +69,7 @@ update_domain_zone
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging

View file

@ -16,46 +16,31 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
soa=$3
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '3' "$#" 'user domain soa'
# Checking argument format
validate_format 'user' 'domain' 'soa'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get old soa
old_soa=$(get_domain_value 'dns' '$SOA')
# Changing soa
update_domain_value 'dns' '$SOA' "$soa"
update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa"
# Updating zone
update_domain_zone
@ -65,11 +50,11 @@ update_domain_zone
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging
log_history "$EVENT" "$SCRIPT $user $domain $old_soa"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -17,7 +17,7 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
template=$3
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
@ -27,28 +27,13 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '3' "$#" 'user domain template'
# Checking argument format
validate_format 'user' 'domain' 'template'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
# Checking template
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_dns_template_valid
@ -56,14 +41,20 @@ is_dns_template_valid
# Action #
#----------------------------------------------------------#
# Get vals
old_tpl=$(get_domain_value 'dns' '$TPL')
ip=$(get_domain_value 'dns' '$IP')
ns1=$(get_user_value '$NS1')
ns2=$(get_user_value '$NS2')
# Defining variables
ip=$(get_object_value 'dns' 'DOMAIN' "$domain" '$IP')
i=1
ns=$(get_user_value '$NS')
for nameserver in ${ns//,/ };do
eval ns$i=$nameserver
(( ++i))
done
# Changing tpl
update_domain_value 'dns' '$TPL' "$template"
update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
# Adding zone to dns dir
cat $DNSTPL/$template.tpl |\
sed -e "s/%ip%/$ip/g" \
-e "s/%domain_idn%/$domain_idn/g" \
@ -76,10 +67,10 @@ cat $DNSTPL/$template.tpl |\
-e "s/%ns6%/$ns6/g" \
-e "s/%ns7%/$ns7/g" \
-e "s/%ns8%/$ns8/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain
-e "s/%time%/$TIME/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
# Updating zone
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
@ -87,11 +78,11 @@ update_domain_zone
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging
log_history "$EVENT" "$SCRIPT $user $domain $old_tpl"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -15,7 +15,7 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
ttl=$3
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
@ -25,37 +25,21 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '3' "$#" 'user domain ttl'
# Checking argument format
validate_format 'user' 'domain' 'ttl'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get old ttl
old_ttl=$(get_domain_value 'dns' '$TTL')
# Changing ttl
update_domain_value 'dns' '$TTL' "$ttl"
update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
# Updating zone
update_domain_zone
@ -65,11 +49,11 @@ update_domain_zone
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging
log_history "$EVENT" "$SCRIPT $user $domain $old_ttl"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -39,7 +39,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -33,7 +33,7 @@ validate_format 'ip' 'user'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking system ip
is_sys_ip_valid

View file

@ -32,7 +32,7 @@ validate_format 'user' 'email'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -33,7 +33,7 @@ validate_format 'user' 'fname' 'lname'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -62,7 +62,7 @@ fi
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -32,7 +32,7 @@ validate_format 'user' 'password'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -32,7 +32,7 @@ validate_format 'user' 'shell'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -40,7 +40,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -39,7 +39,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -34,7 +34,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -39,7 +39,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -26,9 +26,9 @@ check_args '2' "$#" 'user job'
validate_format 'user' 'job'
is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job"
is_object_suspended 'cron' 'JOB' "$job"
is_object_unsuspended 'cron' 'JOB' "$job"
#----------------------------------------------------------#

View file

@ -26,7 +26,7 @@ check_args '1' "$#" 'user'
validate_format 'user'
is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -37,7 +37,7 @@ is_system_enabled 'DB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking db existance
is_db_valid

View file

@ -13,9 +13,9 @@
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
named_conf=/etc/named.conf
restart="$3"
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
@ -25,43 +25,24 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user domain'
# Checking argument format
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get domain values
tpl_name=$(get_domain_value 'dns' '$TPL')
old_ip=$(get_domain_value 'dns' '$IP')
records=$(wc -l $USER_DATA/dns/$domain|cut -f 1 -d ' ')
records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ')
# Deleting domain in named.conf
rm_string=$(grep -n /conf/dns/$domain.db $named_conf |cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $named_conf
fi
if [ -e "$HOMEDIR/$user/conf/dns/$domain.db" ]; then
rm -f $HOMEDIR/$user/conf/dns/$domain.db
fi
sed -i "/\/$domain.db\"/d" /etc/named.conf
rm -f $HOMEDIR/$user/conf/dns/$domain.db
#----------------------------------------------------------#
@ -69,18 +50,21 @@ fi
#----------------------------------------------------------#
# Deleting domain
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf
rm -f $USER_DATA/dns/$domain
sed -i "/DOMAIN='$domain'/d" $USER_DATA/dns.conf
rm -f $USER_DATA/dns/$domain.conf
# Decreasing domain value
decrease_user_value "$user" '$U_DNS_DOMAINS'
decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
# Adding task to the vesta pipe
$BIN/v_restart_dns
# Restart named
if [ "$restart" != 'no' ]; then
$BIN/v_restart_dns
fi
# Logging
log_history "$EVENT" "v_add_dns_domain $user $domain $old_ip $tpl_name"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -15,7 +15,7 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
id=$3
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
@ -25,26 +25,13 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '3' "$#" 'user domain id'
# Checking argument format
validate_format 'user' 'domain' 'id'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
# Checking record valid
is_dns_record_valid
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_object_valid "dns/$domain" 'ID' "$id"
#----------------------------------------------------------#
@ -52,17 +39,9 @@ is_dns_record_valid
#----------------------------------------------------------#
# Deleting record
conf="$USER_DATA/dns/$domain"
rm_string=$(grep -n "^ID='$id'" $conf|cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $conf
fi
# Sorting records
sort_dns_records
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
# Updating zone
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
@ -70,7 +49,7 @@ update_domain_zone
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging

View file

@ -12,26 +12,18 @@
# Argument defenition
user=$1
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
validate_format 'user'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -39,26 +31,9 @@ is_object_valid 'user' 'USER' "$user"
# Action #
#----------------------------------------------------------#
# Defining config
conf="$USER_DATA/dns.conf"
# Defining fileds to select
field='$DOMAIN'
# Defining search string
search_string="SUSPENDED='no'"
# Parsing domain list
domains=$(dom_clear_search)
# Starting delete loop
for domain in $domains; do
$BIN/v_delete_dns_domain "$user" "$domain"
rv="$?"
if [ "$rv" -ne '0' ]; then
log_event 'debug' "$rv $EVENT"
exit $rv
fi
for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do
$BIN/v_delete_dns_domain "$user" "$domain" 'no'
done
@ -66,6 +41,9 @@ done
# Vesta #
#----------------------------------------------------------#
# Restart named
$BIN/v_restart_dns
# Logging
log_event "$OK" "$EVENT"

View file

@ -37,7 +37,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'mail'

View file

@ -38,7 +38,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -38,7 +38,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -38,7 +38,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -37,7 +37,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -35,7 +35,7 @@ validate_format 'user'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking user admin
if [ "$user" = 'admin' ]; then

View file

@ -32,7 +32,7 @@ validate_format 'user'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking user vesta
if [ "$user" = 'admin' ]; then

View file

@ -41,7 +41,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -40,7 +40,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -40,7 +40,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -39,7 +39,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user" "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -37,7 +37,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -37,7 +37,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -37,7 +37,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -40,7 +40,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -15,41 +15,26 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Importing variables
source $VESTA/conf/vesta.conf
# Includes
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '3' "$#" 'user domain key'
# Checking argument format
validate_format 'user' 'domain'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
is_object_valid 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Checking key
value=$(get_domain_value 'dns' "$key")
# Printing value
echo "$value"
# Print
get_object_value 'dns' 'DOMAIN' "$domain" "$key"
#----------------------------------------------------------#

View file

@ -32,7 +32,7 @@ validate_format 'user'
is_object_valid 'user' 'USER' "$user"
# Checking domain is not suspened
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -37,7 +37,7 @@ validate_format 'user' 'domain'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -15,7 +15,7 @@ user=$1
domain=$2
format=${3-shell}
# Importing variables
# Includes
source $VESTA/func/shared.sh
# Json function
@ -76,25 +76,18 @@ shell_list_domain() {
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '2' "$#" 'user domain [format]'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
is_object_valid 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
# Defining config and fields to select
conf=$USER_DATA/dns.conf
# Defining fileds to select
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $DATE'
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE'
# Listing domains
case $format in

View file

@ -14,26 +14,16 @@ user=$1
domain=$2
format=${3-shell}
# Importing variables
# Includes
source $VESTA/func/shared.sh
# Json func
json_list_dns() {
# Print top bracket
echo '{'
# Count fields
fileds_count=$(echo $fields| wc -w )
# Reading file line by line
while read line; do
# New delimeter
IFS=$'\n'
# Assing key=value pair
eval $line
# Closing bracket if there already was output
if [ -n "$data" ]; then
echo -e ' },'
fi
@ -42,13 +32,10 @@ json_list_dns() {
for field in $fields; do
eval value=\"$field\"
value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
if [ $i -eq 1 ]; then
# Printing parrent
(( ++i))
echo -e "\t\"$value\": {"
else
# Printing child
if [ $i -lt $fileds_count ]; then
(( ++i))
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
@ -59,13 +46,9 @@ json_list_dns() {
fi
done
done < $conf
# Closing bracket if there was output
if [ -n "$data" ]; then
echo -e ' }'
fi
# Printing bottom bracket
echo -e '}'
}
@ -73,22 +56,15 @@ json_list_dns() {
shell_list_dns() {
if [ -z "$nohead" ] ; then
# Print brief info
echo "${fields//$/}"
for a in $fields; do
echo -e "------ \c"
done
echo
fi
# Reading file line by line
while read line ; do
# New delimeter
IFS=$'\n'
# Assing key=value pair
eval $line
# Print result
eval echo "$fields" | sed -e "s/%quote%/'/g"
done < $conf
}
@ -98,28 +74,19 @@ shell_list_dns() {
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '2' "$#" 'user domain [format]'
# Checking argument format
validate_format 'user' 'domain'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
is_object_valid 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
conf=$USER_DATA/dns/$domain
# Defining fileds to select
fields='$ID $RECORD $TYPE $VALUE $SUSPENDED $DATE'
# Defining config and fields
conf=$USER_DATA/dns/$domain.conf
fields='$ID $RECORD $TYPE $PRIORITY $VALUE $SUSPENDED $TIME $DATE'
# Listing domains
case $format in

View file

@ -13,7 +13,7 @@
user=$1
format=${2-shell}
# Importing variables
# Includes
source $VESTA/func/shared.sh
@ -21,13 +21,8 @@ source $VESTA/func/shared.sh
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '1' "$#" 'user [format]'
# Checking argument format
validate_format 'user'
# Checking user
is_object_valid 'user' 'USER' "$user"
@ -35,11 +30,9 @@ is_object_valid 'user' 'USER' "$user"
# Action #
#----------------------------------------------------------#
# Defining config
# Defining config and fields
conf=$USER_DATA/dns.conf
# Defining fileds to select
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $DATE'
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE'
# Listing domains
case $format in

View file

@ -13,41 +13,17 @@
template=$1
format=${2-shell}
# Importing variables
# Includes
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '1' "$#" 'template [format]'
# Checking argument format
validate_format 'template'
# Checking template
is_dns_template_valid
# Json func
json_list_dns() {
# Print top bracket
echo '{'
# Count fields
fileds_count=$(echo $fields| wc -w )
# Reading file line by line
while read line; do
# New delimeter
IFS=$'\n'
# Assing key=value pair
eval $line
# Closing bracket if there already was output
if [ -n "$data" ]; then
echo -e ' },'
fi
@ -56,13 +32,10 @@ json_list_dns() {
for field in $fields; do
eval value=\"$field\"
value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
if [ $i -eq 1 ]; then
# Printing parrent
(( ++i))
echo -e "\t\"$value\": {"
else
# Printing child
if [ $i -lt $fileds_count ]; then
(( ++i))
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
@ -73,21 +46,15 @@ json_list_dns() {
fi
done
done < $conf
# Closing bracket if there was output
if [ -n "$data" ]; then
echo -e ' }'
fi
# Printing bottom bracket
echo -e '}'
}
# Shell function
shell_list_dns() {
if [ -z "$nohead" ] ; then
# Print brief info
echo "${fields//$/}"
for a in $fields; do
echo -e "------ \c"
@ -95,28 +62,31 @@ shell_list_dns() {
echo
fi
# Reading file line by line
while read line ; do
# Assing key=value pair
eval $line
# Print result
eval echo "$fields" | sed -e "s/%quote%/'/g"
done < $conf
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'template [format]'
validate_format 'template'
is_dns_template_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
# Defining config and fields
conf=$DNSTPL/$template.tpl
fields='$RECORD $TYPE $PRIORITY $VALUE'
# Defining fileds to select
fields='$RECORD $TYPE $VALUE'
# Listing domains
# Listing templates
case $format in
json) json_list_dns ;;
plain) nohead=1; shell_list_dns ;;

View file

@ -12,35 +12,25 @@
# Argument defenition
format=${1-shell}
# Importing variables
# Includes
source $VESTA/func/shared.sh
# Json function
json_list_dnstpl() {
# Print top bracket
echo '{'
# Count fields
for template in $(ls $DNSTPL/| grep '.descr'); do
# Closing bracket if there already was output
if [ -n "$data" ]; then
echo -e ' },'
fi
tpl_descr=$(cat $DNSTPL/$template |grep '#'|tr -d '\n')
tpl_name="${template//.descr/}"
echo -e "\t\"$tpl_name\": {"
echo -e "\t\t\"DESCR\": \"${tpl_descr//# /}\""
data=1
done
# Closing bracket if there was output
if [ -n "$data" ]; then
echo -e ' }'
fi
# Printing bottom bracket
echo -e '}'
}
@ -49,8 +39,6 @@ shell_list_dnstpl() {
for template in $(ls $DNSTPL/| grep '.descr'); do
tpl_name="${template//.descr/}"
tpl_descr=$(cat $DNSTPL/$template |grep '#')
# Print result
if [ -z "$nohead" ] ; then
echo "----------"
fi

View file

@ -9,29 +9,22 @@
# Variable&Function #
#----------------------------------------------------------#
# Includes
source $VESTA/func/shared.sh
# Argument defenition
user=$1
USER="$user"
format=${2-shell}
# Importing variables
source $VESTA/func/shared.sh
# Json function
json_list_user() {
i=1
fileds_count=$(echo "$fields" | wc -w)
source $V_USERS/$USER/user.conf
# Print top bracket
source $VESTA/data/users/$user/user.conf
echo '{'
# Starting output loop
for field in $fields; do
# Parsing key=value
eval value=$field
# Checking first field
if [ "$i" -eq 1 ]; then
echo -e "\t\"$value\": {"
else
@ -41,22 +34,17 @@ json_list_user() {
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
fi
fi
# Updating iterator
(( ++i))
done
# If there was any output
if [ -n "$value" ]; then
echo -e ' }'
fi
# Printing bottom json bracket
echo -e "}"
}
# Shell function
shell_list_user() {
source $V_USERS/$USER/user.conf
source $VESTA/data/users/$user/user.conf
for field in $fields; do
eval key="$field"
echo "${field//$/}: $key "
@ -68,13 +56,8 @@ shell_list_user() {
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '1' "$#" 'user [format]'
# Checking argument format
validate_format 'user'
# Checking user
is_object_valid 'user' 'USER' "$user"
@ -101,7 +84,6 @@ case $format in
json) json_list_user ;;
plain) nohead=1; shell_list_user ;;
shell) shell_list_user | column -t ;;
*) check_args '1' '0' 'user [format]' ;;
esac

View file

@ -12,31 +12,21 @@
# Argument defenition
user=$1
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
validate_format 'user'
# Checking dns system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -53,17 +43,9 @@ if [ ! -d "$USER_DATA/dns" ]; then
mkdir $USER_DATA/dns
fi
# Defining config
# Defining config and fie
conf="$USER_DATA/dns.conf"
# Defining search string
search_string="DOMAIN"
# Defining fileds to select
field='$DOMAIN'
# Parsing unsuspeneded domains
domains=$(dom_clear_search)
# Defining user name servers
ns=$(get_user_value '$NS')
@ -74,14 +56,13 @@ for nameserver in ${ns//,/ };do
done
# Starting loop
for domain in $domains; do
for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do
# Defining variables
get_domain_values 'dns'
domain_idn=$(idn -t --quiet -a "$domain")
# Checking zone file
if [ ! -e "$USER_DATA/dns/$domain" ]; then
if [ ! -e "$USER_DATA/dns/$domain.conf" ]; then
cat $DNSTPL/$TPL.tpl |\
sed -e "s/%ip%/$IP/g" \
-e "s/%domain_idn%/$domain_idn/g" \
@ -94,22 +75,22 @@ for domain in $domains; do
-e "s/%ns6%/$ns6/g" \
-e "s/%ns7%/$ns7/g" \
-e "s/%ns8%/$ns8/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain
-e "s/%time%/$TIME/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
fi
# Sorting records
sort_dns_records
# Updating zone
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
chmod 640 $conf
chown root:named $conf
# Set file permissions
chmod 640 $HOMEDIR/$user/conf/dns/$domain.db
chown root:named $HOMEDIR/$user/conf/dns/$domain.db
# Bind config check
nconf='/etc/named.conf'
if [ "$SUSPENDED" = 'yes' ]; then
rm_string=$(grep -n /etc/namedb/$domain.db $nconf | cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
@ -124,9 +105,9 @@ for domain in $domains; do
fi
fi
user_domains=$((user_domains + 1))
records=$(wc -l $USER_DATA/dns/$domain | cut -f 1 -d ' ')
records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ')
user_records=$((user_records + records))
update_domain_value 'dns' '$RECORDS' "$records"
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
done
@ -139,7 +120,7 @@ update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains"
update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging

View file

@ -35,7 +35,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -37,7 +37,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#

View file

@ -9,7 +9,7 @@
# Variable&Function #
#----------------------------------------------------------#
# Importing variables
# Includes
source /etc/profile.d/vesta.sh
source $VESTA/conf/vesta.conf

View file

@ -24,10 +24,10 @@ source $VESTA/func/shared.sh
#----------------------------------------------------------#
check_args '2' "$#" 'user job [restart]'
validate_format 'user' 'job' 'rstart'
validate_format 'user' 'job'
is_object_valid 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job"
is_object_suspended 'cron' 'JOB' "$job"
is_object_unsuspended 'cron' 'JOB' "$job"
#----------------------------------------------------------#

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: suspend dns domain
# options: user domain
# options: user domain [restart]
#
# The function suspends a certain user's domain.
@ -13,47 +13,31 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
restart="$3"
# Importing variables
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user domain'
# Checking argument format
check_args '2' "$#" 'user domain [restart]'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Checking domain is not suspened
is_domain_suspended 'dns'
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining 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
# Deleting domain from named.conf
sed -i "/\/$domain.db\"/d" /etc/named.conf
#----------------------------------------------------------#
@ -61,11 +45,13 @@ fi
#----------------------------------------------------------#
# Adding suspend in config
update_domain_value 'dns' '$SUSPENDED' 'yes'
update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
increase_user_value "$user" '$SUSPENDED_DNS'
# Adding task to the vesta pipe
$BIN/v_restart_dns
# Restart named
if [ "$restart" != 'no' ]; then
$BIN/v_restart_dns
fi
# Logging
log_event "$OK" "$EVENT"

View file

@ -12,26 +12,18 @@
# Argument defenition
user=$1
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
validate_format 'user'
# Checking dns system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -39,17 +31,9 @@ is_object_valid 'user' 'USER' "$user"
# Action #
#----------------------------------------------------------#
# Defining config
conf="$USER_DATA/dns.conf"
# Defining fileds to select
field='$DOMAIN'
search_string="SUSPENDED='no'"
domains=$(dom_clear_search)
# Starting suspend loop
for domain in $domains; do
$BIN/v_suspend_dns_domain "$user" "$domain"
for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do
$BIN/v_suspend_dns_domain "$user" "$domain" 'no'
done

View file

@ -38,7 +38,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'

View file

@ -31,7 +31,7 @@ validate_format 'user'
is_object_valid 'user' 'USER' "$user"
# Checking user status
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking user admin
if [ "$user" = 'admin' ]; then

View file

@ -27,7 +27,7 @@ check_args '2' "$#" 'user job [restart]'
validate_format 'user' 'job' 'restart'
is_object_valid 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job"
is_object_unsuspended 'cron' 'JOB' "$job"
is_object_suspended 'cron' 'JOB' "$job"
#----------------------------------------------------------#

View file

@ -13,57 +13,45 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
restart="$3"
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user domain'
# Checking argument format
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
# Check domain is suspened
is_domain_unsuspended 'dns'
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_suspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
conf="/etc/named.conf"
# Adding zone in named.conf
nmd_rec="zone \"$domain\" { type master; file \"/etc/namedb/$domain.db\"; };"
echo "$nmd_rec" >> $conf
echo "zone \"$domain\" { type master; file \"/etc/namedb/$domain.db\"; };" \
>> /etc/named.conf
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Unsuspending domain in config
update_domain_value 'dns' '$SUSPENDED' 'no'
update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no'
decrease_user_value "$user" '$SUSPENDED_DNS'
# Adding task to the vesta pipe
$BIN/v_restart_dns
# Restart named
if [ "$restart" != 'no' ]; then
$BIN/v_restart_dns
fi
# Logging
log_event "$OK" "$EVENT"

View file

@ -12,26 +12,18 @@
# Argument defenition
user=$1
# Importing variables
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
validate_format 'user'
# Checking dns system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -39,22 +31,9 @@ is_object_valid 'user' 'USER' "$user"
# Action #
#----------------------------------------------------------#
# Defining config
conf="$USER_DATA/dns.conf"
# Defining fileds to select
field='$DOMAIN'
# Defining search string
search_string="SUSPENDED='yes'"
# Parsing suspeneded domains
domains=$(dom_clear_search)
# Starting unsuspend loop
for domain in $domains; do
$BIN/v_unsuspend_dns_domain "$user" "$domain"
for domain in $(search_objects 'dns' 'SUSPENDED' "yes" 'DOMAIN'); do
$BIN/v_unsuspend_dns_domain "$user" "$domain" 'no'
done
@ -62,7 +41,7 @@ done
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
# Restart named
$BIN/v_restart_dns
# Logging

View file

@ -38,7 +38,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'