Refactoring stage II

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,9 @@
ID='1' RECORD='@' TYPE='NS' VALUE='%ns1%.' SUSPEND='no' DATE='%date%'
ID='2' RECORD='@' TYPE='NS' VALUE='%ns2%.' SUSPEND='no' DATE='%date%'
ID='3' RECORD='@' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='4' RECORD='mail' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='5' RECORD='www' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='6' RECORD='pop' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='7' RECORD='ftp' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='8' RECORD='@' TYPE='MX' VALUE='10 mail' SUSPEND='no' DATE='%date%'
ID='9' RECORD='@' TYPE='TXT' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' DATE='%date%'
ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='4' RECORD='mail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='5' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='6' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='7' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='8' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='mail' SUSPEND='no' TIME='%time%' 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='2' RECORD='@' TYPE='NS' VALUE='%ns2%.' SUSPEND='no' DATE='%date%'
ID='3' RECORD='@' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='4' RECORD='ftp' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='5' RECORD='localhost' TYPE='A' VALUE='127.0.0.1' SUSPEND='no' DATE='%date%'
ID='6' RECORD='mail' TYPE='CNAME' VALUE='ghs.google.com.' SUSPEND='no' DATE='%date%'
ID='7' RECORD='pop' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='8' RECORD='www' TYPE='A' VALUE='%ip%' SUSPEND='no' DATE='%date%'
ID='9' RECORD='@' TYPE='MX' VALUE='1 ASPMX.L.GOOGLE.COM.' SUSPEND='no' DATE='%date%'
ID='10' RECORD='@' TYPE='MX' VALUE='5 ALT1.ASPMX.L.GOOGLE.COM.' SUSPEND='no' DATE='%date%'
ID='11' RECORD='@' TYPE='MX' VALUE='5 ALT2.ASPMX.L.GOOGLE.COM.' SUSPEND='no' DATE='%date%'
ID='12' RECORD='@' TYPE='MX' VALUE='10 ASPMX2.GOOGLEMAIL.COM.' SUSPEND='no' DATE='%date%'
ID='13' RECORD='@' TYPE='MX' VALUE='10 ASPMX3.GOOGLEMAIL.COM.' SUSPEND='no' DATE='%date%'
ID='14' RECORD='@' TYPE='TXT' VALUE='"v=spf1 a mx ip4:%ip% ?all"' SUSPEND='no' DATE='%date%'
ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns1%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns2%.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='3' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='4' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' 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' PRIORITY='' VALUE='ghs.google.com.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='7' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='8' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPEND='no' TIME='%time%' 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' PRIORITY='5' VALUE='ALT1.ASPMX.L.GOOGLE.COM.' SUSPEND='no' TIME='%time%' 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' PRIORITY='10' VALUE='ASPMX2.GOOGLEMAIL.COM.' SUSPEND='no' TIME='%time%' DATE='%date%'
ID='13' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='ASPMX3.GOOGLEMAIL.COM.' SUSPEND='no' TIME='%time%' 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
is_domain_new() {
config_type="$1"
@ -20,38 +56,12 @@ is_domain_new() {
fi
}
is_domain_suspended() {
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
conf="$HOMEDIR/$user/conf/dns/$domain.db"
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
if [ -e $conf ]; then
@ -99,34 +109,21 @@ update_domain_zone() {
# Converting utf records to ascii
RECORD=$(idn --quiet -a -t "$RECORD")
#VALUE=$(idn --quiet -a -t "$VALUE")
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() {
# Parsing config
curr_str=$(grep "ID=" $USER_DATA/dns/$domain|cut -f 2 -d \'|\
sort -n|tail -n1)
# 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
get_next_dnsrecord(){
if [ -z "$id" ]; then
curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
sort -n|tail -n1)
id="$((curr_str +1))"
fi
}
sort_dns_records() {
# Defining conf
conf="$USER_DATA/dns/$domain"
conf="$USER_DATA/dns/$domain.conf"
cat $conf |sort -n -k 2 -t \' >$conf.tmp
mv -f $conf.tmp $conf
}
@ -231,86 +228,13 @@ replace_web_config() {
sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
}
get_domain_value() {
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
# Assing key=value
eval $line
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() {
# Checking file existance

View file

@ -51,7 +51,7 @@ log_history() {
# Argument list checker
check_args() {
if [ "$1" -gt "$2" ]; then
echo "Error: bad args"
echo "Error: not enought arguments"
echo "Usage: $SCRIPT $3"
log_event "$E_ARGS" "$EVENT"
exit $E_ARGS
@ -75,14 +75,13 @@ is_package_full() {
awk -F "ALIAS='" '{print $2}' | cut -f 1 -d \' | tr ',' '\n' |\
wc -l );;
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_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain |\
MAIL_ACCOUNTS) used=$(wc -l $USER_DATA/mail/$domain.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 \ );;
esac
limit=$(grep "^$1=" $USER_DATA/user.conf | cut -f 2 -d \' )
if [ "$used" -ge "$limit" ]; then
echo "Error: Upgrade package"
@ -102,42 +101,6 @@ gen_password() {
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
is_package_valid() {
if [ ! -e "$VESTA/data/packages/$package.pkg" ]; then
@ -176,7 +139,7 @@ is_object_free() {
object=$(grep "$2='$3'" $USER_DATA/$1.conf)
fi
if [ ! -z "$object" ]; then
echo "Error: $3 exists"
echo "Error: $2 with value $3 exists"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
@ -209,7 +172,7 @@ is_object_suspended() {
else
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
fi
if [ ! -z "$spnd" ]; then
if [ -z "$spnd" ]; then
echo "Error: $3 is suspended"
log_event "$E_SUSPENDED" "$EVENT"
exit $E_SUSPENDED
@ -223,13 +186,21 @@ is_object_unsuspended() {
else
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf|grep "SUSPENDED='yes'")
fi
if [ -z "$spnd" ]; then
if [ ! -z "$spnd" ]; then
echo "Error: $3 is not suspended"
log_event "$E_UNSUSPENDED" "$EVENT"
exit $E_UNSUSPENDED
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() {
row=$(grep -n "$2='$3'" $USER_DATA/$1.conf)
@ -256,7 +227,7 @@ search_objects() {
# 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
@ -514,7 +485,7 @@ validate_format_email() {
# Username
validate_format_username() {
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"
exit $E_INVALID
fi
@ -593,10 +564,10 @@ validate_format_mhdmw() {
}
# Nginx static extention or DNS record
validate_format_extentions() {
exclude="[!|@|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%| ]"
validate_format_common() {
exclude="[!|#|$|^|&|(|)|+|=|{|}|:|<|>|?|/|\|\"|'|;|%| ]"
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"
exit $E_INVALID
fi
@ -616,6 +587,11 @@ validate_format_dvalue() {
if [ "$rtype" = 'NS' ]; then
validate_format_domain "$1"
fi
if [ "$rtype" = 'MX' ]; then
validate_format_domain "$1"
validate_format_int "$priority"
fi
}
# Date
@ -630,13 +606,19 @@ validate_format_date() {
# Format validation controller
validate_format(){
for arg_name in $*; do
eval arg=\$$argument_name
case $var in
account) validate_format_username "$arg" ;;
eval arg=\$$arg_name
if [ -z "$arg" ]; then
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" ;;
antivirus) validate_format_boolean "$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" ;;
database) validate_format_database "$arg" ;;
day) validate_format_mhdmw "$arg" $arg_name ;;
@ -648,11 +630,11 @@ validate_format(){
dom_alias) validate_format_domain "$arg" ;;
dvalue) validate_format_dvalue "$arg";;
email) validate_format_email "$arg" ;;
encoding) validate_format_username "$arg" ;;
encoding) validate_format_username "$arg" "$arg_name" ;;
exp) validate_format_date "$arg" ;;
extentions) validate_format_extentions "$arg" ;;
fname) validate_format_username "$arg" ;;
host) validate_format_username "$arg" ;;
extentions) validate_format_common "$arg" 'extentions' ;;
fname) validate_format_username "$arg" "$arg_name" ;;
host) validate_format_username "$arg" "$arg_name" ;;
hour) validate_format_mhdmw "$arg" $arg_name ;;
id) validate_format_int "$arg" ;;
interface) validate_format_interface "$arg" ;;
@ -660,9 +642,9 @@ validate_format(){
ip_name) validate_format_domain "$arg" ;;
ip_status) validate_format_ip_status "$arg" ;;
job) validate_format_int "$arg" ;;
key) validate_format_username "$arg" ;;
lname) validate_format_username "$arg" ;;
malias) validate_format_username "$arg" ;;
key) validate_format_username "$arg" "$arg_name" ;;
lname) validate_format_username "$arg" "$arg_name" ;;
malias) validate_format_username "$arg" "$arg_name" ;;
mask) validate_format_ip "$arg" ;;
max_db) validate_format_int "$arg" ;;
min) validate_format_mhdmw "$arg" $arg_name ;;
@ -675,16 +657,16 @@ validate_format(){
ns6) validate_format_domain "$arg" ;;
ns7) 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" ;;
port) validate_format_int "$arg" ;;
quota) validate_format_int "$arg" ;;
restart) validate_format_boolean "$arg" ;;
record) validate_format_extentions "$arg" ;;
record) validate_format_common "$arg" 'record';;
rtype) validate_format_dns_type "$arg" ;;
shell) validate_format_shell "$arg" ;;
soa) validate_format_domain "$arg" ;;
template) validate_format_username "$arg" ;;
template) validate_format_username "$arg" "$arg_name" ;;
ttl) validate_format_int "$arg" ;;
url) validate_format_url "$arg" ;;
user) validate_format_username "$arg" ;;

View file

@ -5,27 +5,27 @@ source /etc/profile.d/vesta.sh
V_BIN="$VESTA/bin"
V_TEST="$VESTA/test"
commands='v_list_cron_jobs vesta json
v_list_db_bases vesta json
v_list_db_base vesta vesta_read json
commands='v_list_cron_jobs admin json
v_list_db_bases admin json
v_list_db_base admin admin_read json
v_list_db_host mysql localhost 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_sys_config json
v_list_sys_interfaces json
v_list_sys_ips 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_ips vesta json
v_list_user_ns vesta json
v_list_user_ips admin json
v_list_user_ns admin json
v_list_user_packages json
v_list_users json
v_list_web_domains vesta json
v_list_web_domain vesta default.vesta.domain json
v_list_web_templates vesta json
v_list_web_templates_nginx vesta json'
v_list_web_domains admin json
v_list_web_domain admin default.vesta.domain json
v_list_web_templates admin json
v_list_web_templates_nginx admin json'
IFS=$'\n'
for cmd in $commands; do