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' validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_package_full 'CRON_JOBS' is_package_full 'CRON_JOBS'
get_next_cronjob get_next_cronjob
validate_format 'job' validate_format 'job'

View file

@ -26,7 +26,7 @@ check_args '1' "$#" 'user'
validate_format 'user' validate_format 'user'
is_system_enabled "$CRON_SYSTEM" is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user" 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_system_enabled 'DB_SYSTEM'
is_type_valid "$DB_SYSTEM" "$type" is_type_valid "$DB_SYSTEM" "$type"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_free 'db' 'DB' "$database" is_object_free 'db' 'DB' "$database"
get_next_dbhost get_next_dbhost
is_object_valid "$type" 'DBHOST' "$host" is_object_valid "$type" 'DBHOST' "$host"

View file

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

View file

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

View file

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

View file

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

View file

@ -30,11 +30,11 @@ check_args '4' "$#" 'user domain account alias'
validate_format 'user' 'domain' 'account' 'malias' validate_format 'user' 'domain' 'account' 'malias'
is_system_enabled 'MAIL_SYSTEM' is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user" 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_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_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' is_key_empty "mail/$domain" '' '$AUTOREPLY'
exit exit

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -38,7 +38,7 @@ is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
# Checking user is active # Checking user is active
is_object_suspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist # Checking domain exist
is_domain_valid 'web' 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' validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user" 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_valid 'cron' 'JOB' "$job"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,7 +32,7 @@ validate_format 'user' 'email'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
# Checking user is active # 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # Checking user is active
is_object_suspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist # Checking domain exist
is_domain_valid 'web' is_domain_valid 'web'

View file

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

View file

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

View file

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

View file

@ -26,9 +26,9 @@ check_args '2' "$#" 'user job'
validate_format 'user' 'job' validate_format 'user' 'job'
is_system_enabled "$CRON_SYSTEM" is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user" 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_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' validate_format 'user'
is_system_enabled "$CRON_SYSTEM" is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user" 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # Checking user is active
is_object_suspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
# Checking db existance # Checking db existance
is_db_valid is_db_valid

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,7 +32,7 @@ validate_format 'user'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
# Checking domain is not suspened # 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # Checking user is active
is_object_suspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
# Checking domain exist # Checking domain exist
is_domain_valid 'web' is_domain_valid 'web'

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,7 +35,7 @@ is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
# Checking user is active # 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" is_object_valid 'user' 'USER' "$user"
# Checking user is active # Checking user is active
is_object_suspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
ID='1' RECORD='@' TYPE='NS' VALUE='%ns1%.' SUSPEND='no' DATE='%date%' ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='2' RECORD='@' TYPE='NS' VALUE='%ns2%.' SUSPEND='no' DATE='%date%' ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='3' RECORD='@' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='4' RECORD='mail' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='4' RECORD='mail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='5' RECORD='www' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='5' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='6' RECORD='pop' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='6' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='7' RECORD='ftp' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='7' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='8' RECORD='@' TYPE='MX' VALUE='10 mail' SUSPEND='no' DATE='%date%' ID='8' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='mail' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='9' RECORD='@' TYPE='TXT' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' DATE='%date%' ID='9' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' TIME='%time%' DATE='%date%'

View file

@ -1,14 +1,14 @@
ID='1' RECORD='@' TYPE='NS' VALUE='%ns1%.' SUSPEND='no' DATE='%date%' ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='2' RECORD='@' TYPE='NS' VALUE='%ns2%.' SUSPEND='no' DATE='%date%' ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='3' RECORD='@' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='4' RECORD='ftp' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='4' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='5' RECORD='localhost' TYPE='A' VALUE='127.0.0.1' SUSPEND='no' DATE='%date%' ID='5' RECORD='localhost' TYPE='A' PRIORITY='' VALUE='127.0.0.1' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='6' RECORD='mail' TYPE='CNAME' VALUE='ghs.google.com.' SUSPEND='no' DATE='%date%' ID='6' RECORD='mail' TYPE='CNAME' PRIORITY='' VALUE='ghs.google.com.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='7' RECORD='pop' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='7' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='8' RECORD='www' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%' ID='8' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='9' RECORD='@' TYPE='MX' VALUE='1 ASPMX.L.GOOGLE.COM.' SUSPEND='no' DATE='%date%' ID='9' RECORD='@' TYPE='MX' PRIORITY='1' VALUE='ASPMX.L.GOOGLE.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='10' RECORD='@' TYPE='MX' VALUE='5 ALT1.ASPMX.L.GOOGLE.COM.' SUSPEND='no' DATE='%date%' ID='10' RECORD='@' TYPE='MX' PRIORITY='5' VALUE='ALT1.ASPMX.L.GOOGLE.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='11' RECORD='@' TYPE='MX' VALUE='5 ALT2.ASPMX.L.GOOGLE.COM.' SUSPEND='no' DATE='%date%' ID='11' RECORD='@' TYPE='MX' PRIORITY='5' VALUE='ALT2.ASPMX.L.GOOGLE.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='12' RECORD='@' TYPE='MX' VALUE='10 ASPMX2.GOOGLEMAIL.COM.' SUSPEND='no' DATE='%date%' ID='12' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='ASPMX2.GOOGLEMAIL.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='13' RECORD='@' TYPE='MX' VALUE='10 ASPMX3.GOOGLEMAIL.COM.' SUSPEND='no' DATE='%date%' ID='13' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='ASPMX3.GOOGLEMAIL.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='14' RECORD='@' TYPE='TXT' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' DATE='%date%' ID='14' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' TIME='%time%' DATE='%date%'

View file

@ -1,3 +1,39 @@
# Web template check
is_apache_template_valid() {
c=$(echo "$templates" | grep -w "$template")
t="$WEBTPL/apache_$template.tpl"
d="$WEBTPL/apache_$template.descr"
s="$WEBTPL/apache_$template.stpl"
if [ -z "$c" ] || [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
echo "Error: $template not found"
log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST
fi
}
# Nginx template check
is_nginx_template_valid() {
t="$WEBTPL/ngingx_vhost_$template.tpl"
d="$WEBTPL/ngingx_vhost_$template.descr"
s="$WEBTPL/ngingx_vhost_$template.stpl"
if [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
echo "Error: $template not found"
log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST
fi
}
# DNS template check
is_dns_template_valid() {
tpl="$DNSTPL/$template.tpl"
descr="$DNSTPL/$template.descr"
if [ ! -e $tpl ] || [ ! -e $descr ]; then
echo "Error: template not found"
log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST
fi
}
# Checking domain existance # Checking domain existance
is_domain_new() { is_domain_new() {
config_type="$1" config_type="$1"
@ -20,38 +56,12 @@ is_domain_new() {
fi fi
} }
is_domain_suspended() { # Update domain zone
config_type="$1"
# Parsing domain values
check_domain=$(grep "DOMAIN='$domain'" $USER_DATA/$config_type.conf|\
grep "SUSPENDED='yes'")
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain $domain is suspended"
log_event 'debug' "$E_SUSPENDED $EVENT"
exit $E_SUSPENDED
fi
}
is_domain_unsuspended() {
config_type="$1"
# Parsing domain values
check_domain=$(grep "DOMAIN='$domain'" $USER_DATA/$config_type.conf|\
grep "SUSPENDED='no'")
# Checking result
if [ ! -z "$check_domain" ]; then
echo "Error: domain unsuspended"
log_event 'debug' "$E_UNSUSPENDED $EVENT"
exit $E_UNSUSPENDED
fi
}
update_domain_zone() { update_domain_zone() {
# Definigng variables # Definigng variables
conf="$HOMEDIR/$user/conf/dns/$domain.db"
line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
fields='$RECORD\t$TTL\tIN\t$TYPE\t$VALUE' fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
# Checking serial # Checking serial
if [ -e $conf ]; then if [ -e $conf ]; then
@ -99,34 +109,21 @@ update_domain_zone() {
# Converting utf records to ascii # Converting utf records to ascii
RECORD=$(idn --quiet -a -t "$RECORD") RECORD=$(idn --quiet -a -t "$RECORD")
#VALUE=$(idn --quiet -a -t "$VALUE")
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
done < $USER_DATA/dns/$domain done < $USER_DATA/dns/$domain.conf
} }
get_next_dns_record() { get_next_dnsrecord(){
# Parsing config if [ -z "$id" ]; then
curr_str=$(grep "ID=" $USER_DATA/dns/$domain|cut -f 2 -d \'|\ curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
sort -n|tail -n1) sort -n|tail -n1)
id="$((curr_str +1))"
# Print result
echo "$((curr_str +1))"
}
is_dns_record_free() {
# Checking record id
check_id=$(grep "ID='$id'" $USER_DATA/dns/$domain)
if [ ! -z "$check_id" ]; then
echo "Error: ID exist"
log_event 'debug' "$E_EXISTS $EVENT"
exit $E_EXISTS
fi fi
} }
sort_dns_records() { sort_dns_records() {
# Defining conf # Defining conf
conf="$USER_DATA/dns/$domain" conf="$USER_DATA/dns/$domain.conf"
cat $conf |sort -n -k 2 -t \' >$conf.tmp cat $conf |sort -n -k 2 -t \' >$conf.tmp
mv -f $conf.tmp $conf mv -f $conf.tmp $conf
} }
@ -231,86 +228,13 @@ replace_web_config() {
sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
} }
get_domain_value() { # Get domain values
conf_type="$1"
key="$2"
default_str="DOMAIN='$domain'"
search_str="${3-DOMAIN=$search_str}"
# Parsing config
string=$(grep "$search_str" $USER_DATA/$conf_type.conf )
# Parsing key=value
eval $string
# Self reference
eval value="$key"
# Print value
echo "$value"
}
get_domain_values() { get_domain_values() {
# Defining domain parameters
for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do
# Assing key=value
eval $line eval $line
done done
} }
update_domain_value() {
conf_type="$1"
key="$2"
value="$3"
default_str="DOMAIN='$domain'"
search_str=${4-$default_str}
# Defining conf
conf="$USER_DATA/$conf_type.conf"
# Parsing conf
domain_str=$(grep -n "$search_str" $conf)
str_number=$(echo $domain_str | cut -f 1 -d ':')
str=$(echo $domain_str | cut -f 2 -d ':')
# Reading key=values
eval $str
# Defining clean key
c_key=$(echo "${key//$/}")
eval old="${key}"
# Escaping slashes
old=$(echo "$old" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
new=$(echo "$value" | sed -e 's/\\/\\\\/g' -e 's/&/\\&/g' -e 's/\//\\\//g')
# Updating conf
sed -i "$str_number s/$c_key='${old//\*/\\*}'/$c_key='${new//\*/\\*}'/g"\
$conf
}
is_domain_key_empty() {
conf_type="$1"
key="$2"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $USER_DATA/$conf_type.conf )
# Parsing key=value
eval $string
# Self reference
eval value="$key"
# Checkng key
if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
echo "Error: ${key//$} is not empty = $value"
log_event 'debug' "$E_EXISTS $EVENT"
exit $E_EXISTS
fi
}
is_web_domain_cert_valid() { is_web_domain_cert_valid() {
# Checking file existance # Checking file existance

View file

@ -51,7 +51,7 @@ log_history() {
# Argument list checker # Argument list checker
check_args() { check_args() {
if [ "$1" -gt "$2" ]; then if [ "$1" -gt "$2" ]; then
echo "Error: bad args" echo "Error: not enought arguments"
echo "Usage: $SCRIPT $3" echo "Usage: $SCRIPT $3"
log_event "$E_ARGS" "$EVENT" log_event "$E_ARGS" "$EVENT"
exit $E_ARGS exit $E_ARGS
@ -75,14 +75,13 @@ is_package_full() {
awk -F "ALIAS='" '{print $2}' | cut -f 1 -d \' | tr ',' '\n' |\ awk -F "ALIAS='" '{print $2}' | cut -f 1 -d \' | tr ',' '\n' |\
wc -l );; wc -l );;
DNS_DOMAINS) used=$(wc -l $USER_DATA/dns.conf |cut -f1 -d \ );; DNS_DOMAINS) used=$(wc -l $USER_DATA/dns.conf |cut -f1 -d \ );;
DNS_RECORDS) used=$(wc -l $USER_DATA/dns/$domain |cut -f1 -d \ );; DNS_RECORDS) used=$(wc -l $USER_DATA/dns/$domain.conf |cut -f1 -d \ );;
MAIL_DOMAINS) used=$(wc -l $USER_DATA/mail.conf |cut -f1 -d \ );; MAIL_DOMAINS) used=$(wc -l $USER_DATA/mail.conf |cut -f1 -d \ );;
MAIL_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain |\ MAIL_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain.conf |\
cut -f1 -d \ );; cut -f1 -d \ );;
DATABASES) used=$(wc -l $USER_DATA/db.conf |cut -f1 -d \ );; DATABASES) used=$(wc -l $USER_DATA/db.conf |cut -f1 -d \ );;
CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );; CRON_JOBS) used=$(wc -l $USER_DATA/cron.conf |cut -f1 -d \ );;
esac esac
limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' ) limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' )
if [ "$used" -ge "$limit" ]; then if [ "$used" -ge "$limit" ]; then
echo "Error: Upgrade package" echo "Error: Upgrade package"
@ -102,42 +101,6 @@ gen_password() {
echo "$pass" echo "$pass"
} }
# Web template check
is_apache_template_valid() {
c=$(echo "$templates" | grep -w "$template")
t="$WEBTPL/apache_$template.tpl"
d="$WEBTPL/apache_$template.descr"
s="$WEBTPL/apache_$template.stpl"
if [ -z "$c" ] || [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
echo "Error: $template not found"
log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST
fi
}
# Nginx template check
is_nginx_template_valid() {
t="$WEBTPL/ngingx_vhost_$template.tpl"
d="$WEBTPL/ngingx_vhost_$template.descr"
s="$WEBTPL/ngingx_vhost_$template.stpl"
if [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
echo "Error: $template not found"
log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST
fi
}
# DNS template check
is_dns_template_valid() {
tpl="$DNSTPL/$template.tpl"
descr="$DNSTPL/$template.descr"
if [ ! -e $tpl ] || [ ! -e $descr ]; then
echo "Error: template not found"
log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST
fi
}
# Package existance check # Package existance check
is_package_valid() { is_package_valid() {
if [ ! -e "$VESTA/data/packages/$package.pkg" ]; then if [ ! -e "$VESTA/data/packages/$package.pkg" ]; then
@ -176,7 +139,7 @@ is_object_free() {
object=$(grep "$2='$3'" $USER_DATA/$1.conf) object=$(grep "$2='$3'" $USER_DATA/$1.conf)
fi fi
if [ ! -z "$object" ]; then if [ ! -z "$object" ]; then
echo "Error: $3 exists" echo "Error: $2 with value $3 exists"
log_event "$E_EXISTS" "$EVENT" log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS exit $E_EXISTS
fi fi
@ -209,7 +172,7 @@ is_object_suspended() {
else else
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'") spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
fi fi
if [ ! -z "$spnd" ]; then if [ -z "$spnd" ]; then
echo "Error: $3 is suspended" echo "Error: $3 is suspended"
log_event "$E_SUSPENDED" "$EVENT" log_event "$E_SUSPENDED" "$EVENT"
exit $E_SUSPENDED exit $E_SUSPENDED
@ -223,13 +186,21 @@ is_object_unsuspended() {
else else
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'") spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
fi fi
if [ -z "$spnd" ]; then if [ ! -z "$spnd" ]; then
echo "Error: $3 is not suspended" echo "Error: $3 is not suspended"
log_event "$E_UNSUSPENDED" "$EVENT" log_event "$E_UNSUSPENDED" "$EVENT"
exit $E_UNSUSPENDED exit $E_UNSUSPENDED
fi fi
} }
# Get object value
get_object_value() {
object=$(grep "$2='$3'" $USER_DATA/$1.conf)
eval "$object"
eval object_val="$4"
echo "$object_val"
}
# Update object value # Update object value
update_object_value() { update_object_value() {
row=$(grep -n "$2='$3'" $USER_DATA/$1.conf) row=$(grep -n "$2='$3'" $USER_DATA/$1.conf)
@ -256,7 +227,7 @@ search_objects() {
# Get user value # Get user value
get_user_value() { get_user_value() {
grep "^$1=" $USER_DATA/user.conf| cut -f 2 -d \' grep "^${1//$/}=" $USER_DATA/user.conf| cut -f 2 -d \'
} }
# Update user value in user.conf # Update user value in user.conf
@ -514,7 +485,7 @@ validate_format_email() {
# Username # Username
validate_format_username() { validate_format_username() {
if ! [[ "$1" =~ ^[0-Z]+(\.[0-Z]+)?$ ]] || [[ "${#1}" -gt 28 ]]; then if ! [[ "$1" =~ ^[0-Z]+(\.[0-Z]+)?$ ]] || [[ "${#1}" -gt 28 ]]; then
echo "Error: usernmae $1 is not valid" echo "Error: $2 $1 is not valid"
log_event "$E_INVALID" "$EVENT" log_event "$E_INVALID" "$EVENT"
exit $E_INVALID exit $E_INVALID
fi fi
@ -593,10 +564,10 @@ validate_format_mhdmw() {
} }
# Nginx static extention or DNS record # Nginx static extention or DNS record
validate_format_extentions() { validate_format_common() {
exclude="[!|@|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%| ]" exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%| ]"
if [[ "$1" =~ $exclude ]] || [ 200 -le ${#1} ]; then if [[ "$1" =~ $exclude ]] || [ 200 -le ${#1} ]; then
echo "Error: extention $1 is not valid" echo "Error: $2 $1 is not valid"
log_event "$E_INVALID" "$EVENT" log_event "$E_INVALID" "$EVENT"
exit $E_INVALID exit $E_INVALID
fi fi
@ -616,6 +587,11 @@ validate_format_dvalue() {
if [ "$rtype" = 'NS' ]; then if [ "$rtype" = 'NS' ]; then
validate_format_domain "$1" validate_format_domain "$1"
fi fi
if [ "$rtype" = 'MX' ]; then
validate_format_domain "$1"
validate_format_int "$priority"
fi
} }
# Date # Date
@ -630,13 +606,19 @@ validate_format_date() {
# Format validation controller # Format validation controller
validate_format(){ validate_format(){
for arg_name in $*; do for arg_name in $*; do
eval arg=\$$argument_name eval arg=\$$arg_name
case $var in if [ -z "$arg" ]; then
account) validate_format_username "$arg" ;; echo "Error: argument $arg_name is not valid (empty)"
log_event "$E_INVALID" "$EVENT"
exit $E_INVALID
fi
case $arg_name in
account) validate_format_username "$arg" "$arg_name" ;;
antispam) validate_format_boolean "$arg" ;; antispam) validate_format_boolean "$arg" ;;
antivirus) validate_format_boolean "$arg" ;; antivirus) validate_format_boolean "$arg" ;;
auth_pass) validate_format_password "$arg" ;; auth_pass) validate_format_password "$arg" ;;
auth_user) validate_format_username "$arg" ;; auth_user) validate_format_username "$arg" "$arg_name" ;;
backup) validate_format_date "$arg" ;; backup) validate_format_date "$arg" ;;
database) validate_format_database "$arg" ;; database) validate_format_database "$arg" ;;
day) validate_format_mhdmw "$arg" $arg_name ;; day) validate_format_mhdmw "$arg" $arg_name ;;
@ -648,11 +630,11 @@ validate_format(){
dom_alias) validate_format_domain "$arg" ;; dom_alias) validate_format_domain "$arg" ;;
dvalue) validate_format_dvalue "$arg";; dvalue) validate_format_dvalue "$arg";;
email) validate_format_email "$arg" ;; email) validate_format_email "$arg" ;;
encoding) validate_format_username "$arg" ;; encoding) validate_format_username "$arg" "$arg_name" ;;
exp) validate_format_date "$arg" ;; exp) validate_format_date "$arg" ;;
extentions) validate_format_extentions "$arg" ;; extentions) validate_format_common "$arg" 'extentions' ;;
fname) validate_format_username "$arg" ;; fname) validate_format_username "$arg" "$arg_name" ;;
host) validate_format_username "$arg" ;; host) validate_format_username "$arg" "$arg_name" ;;
hour) validate_format_mhdmw "$arg" $arg_name ;; hour) validate_format_mhdmw "$arg" $arg_name ;;
id) validate_format_int "$arg" ;; id) validate_format_int "$arg" ;;
interface) validate_format_interface "$arg" ;; interface) validate_format_interface "$arg" ;;
@ -660,9 +642,9 @@ validate_format(){
ip_name) validate_format_domain "$arg" ;; ip_name) validate_format_domain "$arg" ;;
ip_status) validate_format_ip_status "$arg" ;; ip_status) validate_format_ip_status "$arg" ;;
job) validate_format_int "$arg" ;; job) validate_format_int "$arg" ;;
key) validate_format_username "$arg" ;; key) validate_format_username "$arg" "$arg_name" ;;
lname) validate_format_username "$arg" ;; lname) validate_format_username "$arg" "$arg_name" ;;
malias) validate_format_username "$arg" ;; malias) validate_format_username "$arg" "$arg_name" ;;
mask) validate_format_ip "$arg" ;; mask) validate_format_ip "$arg" ;;
max_db) validate_format_int "$arg" ;; max_db) validate_format_int "$arg" ;;
min) validate_format_mhdmw "$arg" $arg_name ;; min) validate_format_mhdmw "$arg" $arg_name ;;
@ -675,16 +657,16 @@ validate_format(){
ns6) validate_format_domain "$arg" ;; ns6) validate_format_domain "$arg" ;;
ns7) validate_format_domain "$arg" ;; ns7) validate_format_domain "$arg" ;;
ns8) validate_format_domain "$arg" ;; ns8) validate_format_domain "$arg" ;;
package) validate_format_username "$arg" ;; package) validate_format_username "$arg" "$arg_name" ;;
password) validate_format_password "$arg" ;; password) validate_format_password "$arg" ;;
port) validate_format_int "$arg" ;; port) validate_format_int "$arg" ;;
quota) validate_format_int "$arg" ;; quota) validate_format_int "$arg" ;;
restart) validate_format_boolean "$arg" ;; restart) validate_format_boolean "$arg" ;;
record) validate_format_extentions "$arg" ;; record) validate_format_common "$arg" 'record';;
rtype) validate_format_dns_type "$arg" ;; rtype) validate_format_dns_type "$arg" ;;
shell) validate_format_shell "$arg" ;; shell) validate_format_shell "$arg" ;;
soa) validate_format_domain "$arg" ;; soa) validate_format_domain "$arg" ;;
template) validate_format_username "$arg" ;; template) validate_format_username "$arg" "$arg_name" ;;
ttl) validate_format_int "$arg" ;; ttl) validate_format_int "$arg" ;;
url) validate_format_url "$arg" ;; url) validate_format_url "$arg" ;;
user) validate_format_username "$arg" ;; user) validate_format_username "$arg" ;;

View file

@ -5,27 +5,27 @@ source /etc/profile.d/vesta.sh
V_BIN="$VESTA/bin" V_BIN="$VESTA/bin"
V_TEST="$VESTA/test" V_TEST="$VESTA/test"
commands='v_list_cron_jobs vesta json commands='v_list_cron_jobs admin json
v_list_db_bases vesta json v_list_db_bases admin json
v_list_db_base vesta vesta_read json v_list_db_base admin admin_read json
v_list_db_host mysql localhost json v_list_db_host mysql localhost json
v_list_db_hosts mysql json v_list_db_hosts mysql json
v_list_dns_domains vesta json v_list_dns_domains admin json
v_list_dns_templates json v_list_dns_templates json
v_list_sys_config json v_list_sys_config json
v_list_sys_interfaces json v_list_sys_interfaces json
v_list_sys_ips json v_list_sys_ips json
v_list_sys_rrd json v_list_sys_rrd json
v_list_user vesta json v_list_user admin json
v_list_user_backups vesta json v_list_user_backups vesta json
v_list_user_ips vesta json v_list_user_ips admin json
v_list_user_ns vesta json v_list_user_ns admin json
v_list_user_packages json v_list_user_packages json
v_list_users json v_list_users json
v_list_web_domains vesta json v_list_web_domains admin json
v_list_web_domain vesta default.vesta.domain json v_list_web_domain admin default.vesta.domain json
v_list_web_templates vesta json v_list_web_templates admin json
v_list_web_templates_nginx vesta json' v_list_web_templates_nginx admin json'
IFS=$'\n' IFS=$'\n'
for cmd in $commands; do for cmd in $commands; do