diff --git a/bin/v_add_cron_job b/bin/v_add_cron_job index 52747fc28..776071877 100755 --- a/bin/v_add_cron_job +++ b/bin/v_add_cron_job @@ -20,42 +20,24 @@ wday=$6 command=$7 job=$8 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '7' "$#" 'user min hour day month wday command [job]' - -# Checking argument format -format_validation 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' - -# Checking cron system -is_system_enabled 'CRON_SYSTEM' - -# Checking user -is_user_valid - -# Checking package +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_package_full 'CRON_JOBS' - -# Get str position -if [ -z "$job" ]; then - job=$(get_next_cron_string) -fi - -# Checking id format -format_validation 'job' - -# Checking job id -is_cron_job_free +get_next_cronjob +validate_format 'job' +is_object_free 'cron' 'JOB' "$job" #----------------------------------------------------------# @@ -63,19 +45,20 @@ is_cron_job_free #----------------------------------------------------------# # Concatenating cron string -command=$(echo $command|sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") -v_str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month" -v_str="$v_str' WDAY='$wday' CMD='$command' SUSPENDED='no' DATE='$V_DATE'" +command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") +str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month WDAY='$wday'" +str="$v_str' CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" # Adding to crontab -echo "$v_str">>$V_USERS/$user/cron.conf +echo "$str" >> $VESTA/data/users/$user/cron.conf -chmod 660 $V_USERS/$user/cron.conf +# Chaning permissions +chmod 660 $VESTA/data/users/$user/cron.conf -# Sorting jobs by id +# Sort jobs by id number sort_cron_jobs -# Sync system cron with user +# Sync cronjobs with system crond sync_cron_jobs @@ -84,13 +67,13 @@ sync_cron_jobs #----------------------------------------------------------# # Increasing cron value -increase_user_value "$user" '$U_CRON_JOBS' +increase_user_value $user '$U_CRON_JOBS' -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_history "$V_EVENT" "v_delete_cron_job $user $job" -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_user_reports b/bin/v_add_cron_report similarity index 67% rename from bin/v_add_user_reports rename to bin/v_add_cron_report index a480abf84..f77b1c899 100755 --- a/bin/v_add_user_reports +++ b/bin/v_add_cron_report @@ -1,5 +1,5 @@ #!/bin/bash -# info: add user reports +# info: add cron reports # opions: user # # The script for enabling reports on cron tasks and administrative @@ -13,28 +13,20 @@ # Argument defenition user=$1 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '1' "$#" 'user' - -# Checking argument format -format_validation 'user' - -# Checking user -is_user_valid - -# Checking user is active -is_user_suspended +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -42,7 +34,7 @@ is_user_suspended #----------------------------------------------------------# # Changing user report value -update_user_value "$user" '$REPORTS' 'yes' +update_user_value "$user" '$CRON_REPORTS' 'yes' # Sync system cron with user sync_cron_jobs @@ -52,11 +44,11 @@ sync_cron_jobs # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_history "$V_EVENT" "v_delete_user_reports $user" -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_db_base b/bin/v_add_db_base index 4c9e8e3da..d0846c26a 100755 --- a/bin/v_add_db_base +++ b/bin/v_add_db_base @@ -24,45 +24,26 @@ type=$5 host=$6 encoding=${7-UTF8} encoding=$(echo "$encoding" |tr '[:lower:]' '[:upper:]') + # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '5' "$#" 'user db db_user db_password type [host] [encoding]' - -# Checking argument format -format_validation 'user' 'database' 'db_user' 'db_password' 'encoding' - -# Checking db system is enabled +validate_format 'user' 'database' 'db_user' 'db_password' 'encoding' is_system_enabled 'DB_SYSTEM' - -# Checking db type -is_type_valid 'db' "$type" - -# Checking user -is_user_valid - -# Checking user is active -is_user_suspended - -# Checking db existance -is_db_new - -# Checking db host -if [ -z "$host" ]; then - host=$(get_next_db_host) -fi -is_db_host_valid - -# Checking package +is_type_valid "$DB_SYSTEM" "$type" +is_object_valid 'user' 'USER' "$user" +is_object_suspended 'user' 'USER' "$user" +is_object_free 'db' 'DB' "$database" +get_next_dbhost +is_object_valid "$type" 'DBHOST' "$host" is_package_full 'DATABASES' @@ -81,24 +62,22 @@ esac # Vesta # #----------------------------------------------------------# -# Increasing db value -increase_db_value - -# Increasing domain value +# Increasing counters +increase_dbhost_values increase_user_value "$user" '$U_DATABASES' # Adding db to db conf v_str="DB='$database' USER='$db_user' HOST='$host' TYPE='$type'" -v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPENDED='no' DATE='$V_DATE'" -echo "$v_str" >> $V_USERS/$user/db.conf -chmod 660 $V_USERS/$user/db.conf +v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPENDED='no' DATE='$DATE'" +echo "$v_str" >> $USER_DATA/db.conf +chmod 660 $USER_DATA/db.conf # Hiding password -V_EVENT="$V_DATE $V_SCRIPT $user $database $db_user ***** $type $host" -V_EVENT="$V_EVENT $encoding" +EVENT="$DATE $SCRIPT $user $database $db_user ***** $type $host" +EVENT="$EVENT $encoding" # Logging -log_history "$V_EVENT" "v_delete_db_base $user $database" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_db_base $user $database" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_db_host b/bin/v_add_db_host index 84354ba8d..4c9e63e15 100755 --- a/bin/v_add_db_host +++ b/bin/v_add_db_host @@ -24,10 +24,9 @@ template=${7-template1} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -39,14 +38,14 @@ args_usage='type host port db_user db_password [max_db] [tpl]' check_args '5' "$#" "$args_usage" # Checking argument format -format_validation 'host' 'port' 'db_user' 'db_password' 'max_db' -format_validation 'template' +validate_format 'host' 'port' 'db_user' 'db_password' 'max_db' +validate_format 'template' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking db type -is_type_valid 'db' "$type" +is_type_valid "$DB_SYSTEM" "$type" # Checking host existance is_db_host_new @@ -66,16 +65,16 @@ esac case $type in mysql) new_str="HOST='$host' USER='$db_user' PASSWORD='$db_password'"; new_str="$new_str PORT='$port' MAX_DB='$max_db' U_SYS_USERS=''"; - new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";; + new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$DATE'";; pgsql) new_str="HOST='$host' USER='$db_user' PASSWORD='$db_password'"; new_str="$new_str PORT='$port' TPL='$template'"; new_str="$new_str MAX_DB='$max_db' U_SYS_USERS=''"; - new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";; + new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$DATE'";; esac # Adding host to conf -echo "$new_str" >> $V_DB/$type.conf -chmod 660 $V_DB/$type.conf +echo "$new_str" >> $VESTA/conf/$type.conf +chmod 660 $VESTA/conf/$type.conf #----------------------------------------------------------# @@ -83,9 +82,9 @@ chmod 660 $V_DB/$type.conf #----------------------------------------------------------# # Hidding db pass -V_EVENT=$(echo $V_EVENT | sed -e "s/$db_password/xxxxxx/g") +EVENT=$(echo $EVENT | sed -e "s/$db_password/xxxxxx/g") # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_dns_domain b/bin/v_add_dns_domain index 87e5ee952..34c44ca8a 100755 --- a/bin/v_add_dns_domain +++ b/bin/v_add_dns_domain @@ -26,10 +26,9 @@ soa=$6 ttl=${7-14400} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -40,16 +39,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain ip [template] [exp] [soa] [ttl]' # Checking argument format -format_validation 'user' 'domain' 'ip' 'template' 'exp' 'ttl' +validate_format 'user' 'domain' 'ip' 'template' 'exp' 'ttl' # Checking dns system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_new 'dns' @@ -58,8 +57,7 @@ is_domain_new 'dns' is_package_full 'DNS_DOMAINS' # Checking template -is_template_valid 'dns' - +is_dns_template_valid #----------------------------------------------------------# # Action # @@ -78,7 +76,7 @@ if [ -z "$soa" ]; then fi # Adding zone to dns dir -cat $V_DNSTPL/$template.tpl |\ +cat $DNSTPL/$template.tpl |\ sed -e "s/%ip%/$ip/g" \ -e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain%/$domain/g" \ @@ -90,23 +88,23 @@ cat $V_DNSTPL/$template.tpl |\ -e "s/%ns6%/$ns6/g" \ -e "s/%ns7%/$ns7/g" \ -e "s/%ns8%/$ns8/g" \ - -e "s/%date%/$V_DATE/g" > $V_USERS/$user/dns/$domain + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain -records="$(wc -l $V_USERS/$user/dns/$domain)" +records="$(wc -l $USER_DATA/dns/$domain)" # 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='$V_DATE'" -echo "$dns_rec" >> $V_USERS/$user/dns.conf -chmod 660 $V_USERS/$user/dns.conf +dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' DATE='$DATE'" +echo "$dns_rec" >> $USER_DATA/dns.conf +chmod 660 $USER_DATA/dns.conf # Adding zone in named.conf named="zone \"$domain_idn\" {type master; file" -named="$named \"$V_HOME/$user/conf/dns/$domain.db\";};" +named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" echo "$named" >> /etc/named.conf # Updating domain dns zone -conf="$V_HOME/$user/conf/dns/$domain.db" +conf="$HOMEDIR/$user/conf/dns/$domain.db" update_domain_zone chmod 640 $conf @@ -122,10 +120,10 @@ increase_user_value "$user" '$U_DNS_DOMAINS' increase_user_value "$user" '$U_DNS_RECORDS' "$records" # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" "v_delete_dns_domain $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_dns_domain $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_dns_domain_record b/bin/v_add_dns_domain_record index be6343e8d..88757deb6 100755 --- a/bin/v_add_dns_domain_record +++ b/bin/v_add_dns_domain_record @@ -25,10 +25,9 @@ dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]') id=$6 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -39,16 +38,16 @@ source $V_FUNC/domain.func check_args '5' "$#" 'user domain record type value [id]' # Checking argument format -format_validation 'user' 'domain' 'record' 'rtype' 'dvalue' +validate_format 'user' 'domain' 'record' 'rtype' 'dvalue' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -65,7 +64,7 @@ if [ -z "$id"] ; then fi # Checking id format -format_validation 'id' +validate_format 'id' # Checking id is_dns_record_free @@ -76,18 +75,18 @@ is_dns_record_free #----------------------------------------------------------# # Defining zone path -zone="$V_USERS/$user/dns/$domain" +zone="$USER_DATA/dns/$domain" # Adding record dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$dvalue'" -dns_rec="$dns_rec SUSPENDED='no' DATE='$V_DATE'" +dns_rec="$dns_rec SUSPENDED='no' DATE='$DATE'" echo "$dns_rec" >> $zone # Sorting records sort_dns_records # Updating zone -conf="$V_HOME/$user/conf/dns/$domain.db" +conf="$HOMEDIR/$user/conf/dns/$domain.db" update_domain_zone @@ -96,17 +95,17 @@ update_domain_zone #----------------------------------------------------------# # Updating dns domain values -records="$(wc -l $V_USERS/$user/dns/$domain)" +records="$(wc -l $USER_DATA/dns/$domain)" update_domain_value 'dns' '$RECORDS' "$records" # Updating user counters increase_user_value "$user" '$U_DNS_RECORDS' # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" "v_delete_dns_domain_record $user $domain $id" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_dns_domain_record $user $domain $id" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_mail_account b/bin/v_add_mail_account new file mode 100755 index 000000000..f3be8a6ab --- /dev/null +++ b/bin/v_add_mail_account @@ -0,0 +1,85 @@ +#!/bin/bash +# info: add mail domain account +# options: user domain account password [quota] +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +password=$4 +quota=${5-0} + +# Importing variables +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking arg number +check_args '4' "$#" 'user domain account password quota' + +# Checking argument format +validate_format 'user' 'domain' 'account' 'password' 'quota' + +# Checking dns system is enabled +is_system_enabled 'MAIL_SYSTEM' + +# Checking user +is_object_valid 'user' 'USER' "$user" + +# Checking user is active +is_object_suspended 'user' 'USER' "$user" + +# Checking domain +is_domain_valid 'mail' + +# Checking domain is not suspened +is_domain_suspended 'mail' + +# Checking package +is_package_full 'MAIL_ACCOUNTS' + +# Checking account +is_mail_account_free + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +password=$(/usr/sbin/dovecotpw -s md5 -p "$password") +str="$account:$password:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''" +str="$str U_DISK='0' SUSPENDED='no' DATE='$DATE'" +echo "$str" >> $USER_DATA/mail/$domain.conf + +# Increase mail accounts counter +accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') +increase_user_value "$user" '$U_MAIL_ACCOUNTS' +update_domain_value 'mail' '$ACCOUNTS' "$accounts" + +# Logging +EVENT="$DATE $SCRIPT $user $domain ***** $quota" +log_history "$EVENT" "v_delete_mail_account $user $domain $account" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v_add_mail_account_alias b/bin/v_add_mail_account_alias new file mode 100755 index 000000000..385d8b19e --- /dev/null +++ b/bin/v_add_mail_account_alias @@ -0,0 +1,85 @@ +#!/bin/bash +# info: add mail account alias aka nickname +# options: user domain account alias +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Importing variables +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking arg number +check_args '4' "$#" 'user domain account alias' + +# Checking argument format +validate_format 'user' 'domain' 'account' 'malias' + +# Checking dns system is enabled +is_system_enabled 'MAIL_SYSTEM' + +# Checking user +is_object_valid 'user' 'USER' "$user" + +# Checking user is active +is_object_suspended 'user' 'USER' "$user" + +# Checking domain +is_domain_valid 'mail' + +# Checking domain is not suspened +is_domain_suspended 'mail' + +# Checking account +is_mail_account_valid + +# Checking account +is_mail_account_free "$malias" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding exim alias +str="$mailas@$domain:$account@$domain" +echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding vesta alias +aliases=$(get_domain_value "mail/$domain" '$ALIAS' "ACCOUNT='$account'") +if [ -z "$aliases" ]; then + aliases="$malias" +else + aliases="$aliases,$malias" +fi +update_domain_value "mail/$domain" '$ALIAS' "$aliases" "ACCOUNT='$account'" + +# Logging +cmd='v_delete_mail_account_alias' +log_history "$EVENT" "$cmd $user $domain $account $malias" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v_add_mail_account_autoreply b/bin/v_add_mail_account_autoreply new file mode 100755 index 000000000..3cba3eec0 --- /dev/null +++ b/bin/v_add_mail_account_autoreply @@ -0,0 +1,68 @@ +#!/bin/bash +# info: add mail account alias aka nickname +# options: user domain account alias +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Importing variables +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# +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_valid 'mail' 'DOMAIN' "$domain" +is_object_suspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_suspended "mail/$domain" 'ACCOUNT' "$account" +is_key_empty "mail/$domain" '' '$AUTOREPLY' +exit + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +exit +# Adding exim alias +str="$mailas@$domain:$account@$domain" +echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding vesta alias +aliases=$(get_domain_value "mail/$domain" '$ALIAS' "ACCOUNT='$account'") +if [ -z "$aliases" ]; then + aliases="$malias" +else + aliases="$aliases,$malias" +fi +update_domain_value "mail/$domain" '$ALIAS' "$aliases" "ACCOUNT='$account'" + +# Logging +cmd='v_delete_mail_account_alias' +log_history "$EVENT" "$cmd $user $domain $account $malias" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v_add_mail_domain b/bin/v_add_mail_domain index a45e744cc..44dd82c43 100755 --- a/bin/v_add_mail_domain +++ b/bin/v_add_mail_domain @@ -20,10 +20,9 @@ dkim=${5-yes} dkim_size=${6-512} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -34,16 +33,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain [antispam] [antivirus] [dkim] [dkim_size]' # Checking argument format -format_validation 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' +validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_new 'mail' @@ -57,62 +56,62 @@ is_package_full 'MAIL_DOMAINS' #----------------------------------------------------------# # Adding domain directory -mkdir $V_HOME/$user/conf/mail/$domain -touch $V_HOME/$user/conf/mail/$domain/aliases -touch $V_HOME/$user/conf/mail/$domain/protection -touch $V_HOME/$user/conf/mail/$domain/passwd -chown -R root:mail $V_HOME/$user/conf/mail/$domain -chmod 770 $V_HOME/$user/conf/mail/$domain -chmod 660 $V_HOME/$user/conf/mail/$domain* -mkdir $V_HOME/$user/mail/$domain -chown $user:mail $V_HOME/$user/mail/$domain -chmod 770 $V_HOME/$user/mail/$domain +mkdir $HOMEDIR/$user/conf/mail/$domain +touch $HOMEDIR/$user/conf/mail/$domain/aliases +touch $HOMEDIR/$user/conf/mail/$domain/protection +touch $HOMEDIR/$user/conf/mail/$domain/passwd +chown -R root:mail $HOMEDIR/$user/conf/mail/$domain +chmod 770 $HOMEDIR/$user/conf/mail/$domain +chmod 660 $HOMEDIR/$user/conf/mail/$domain/* +mkdir $HOMEDIR/$user/mail/$domain +chown $user:mail $HOMEDIR/$user/mail/$domain +chmod 770 $HOMEDIR/$user/mail/$domain # Adding symlink -ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/ +ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ # Adding antispam protection if [ "$antispam" = 'yes' ]; then - echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection fi # Adding antivirus protection if [ "$antivirus" = 'yes' ]; then - echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection fi # Adding dkim if [ "$dkim" = 'yes' ]; then - openssl genrsa -out $V_USERS/$user/mail/$domain.pem $dkim_size 2>/dev/null - openssl rsa -pubout -in $V_USERS/$user/mail/$domain.pem \ - -out $V_USERS/$user/mail/$domain.pub 2>/dev/null - chmod 660 $V_USERS/$user/mail/$domain.* + openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null + openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ + -out $USER_DATA/mail/$domain.pub &>/dev/null + chmod 660 $USER_DATA/mail/$domain.* - cp $V_USERS/$user/mail/$domain.pem $V_HOME/$user/conf/mail/$domain/dkim.pem - chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem - chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem + cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem # Adding dkim dns records check_dns_domain=$(is_domain_valid 'dns') if [ "$?" -eq 0 ]; then - p=$(cat $V_USERS/$user/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') + p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') record='_domainkey' policy="\"t=y; o=~;\"" - $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$policy" + $BIN/v_add_dns_domain_record $user $domain $record TXT "$policy" record='mail._domainkey' selector="\"k=rsa\; p=$p\"" - $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$selector" + $BIN/v_add_dns_domain_record $user $domain $record TXT "$selector" fi fi # Adding domain to vesta db s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'" -s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' DATE='$V_DATE'" -echo $s >> $V_USERS/$user/mail.conf -touch $V_USERS/$user/mail/$domain -chmod 660 $V_USERS/$user/mail.conf -chmod 660 $V_USERS/$user/mail/$domain +s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' DATE='$DATE'" +echo $s >> $USER_DATA/mail.conf +touch $USER_DATA/mail/$domain.conf +chmod 660 $USER_DATA/mail.conf +chmod 660 $USER_DATA/mail/$domain.conf #----------------------------------------------------------# @@ -123,7 +122,7 @@ chmod 660 $V_USERS/$user/mail/$domain increase_user_value "$user" '$U_MAIL_DOMAINS' # Logging -log_history "$V_EVENT" "v_delete_mail_domain $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_mail_domain $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_mail_domain_antispam b/bin/v_add_mail_domain_antispam index 16afd46cf..5912e3bdf 100755 --- a/bin/v_add_mail_domain_antispam +++ b/bin/v_add_mail_domain_antispam @@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -56,8 +55,8 @@ is_domain_key_empty 'mail' '$ANTISPAM' #----------------------------------------------------------# # Adding antispam key to config -if [ -z "$(grep 'antispam' $V_HOME/$user/conf/mail/$domain/protection)" ]; then - echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection +if [ -z "$(grep 'antispam' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection fi #----------------------------------------------------------# @@ -68,7 +67,7 @@ fi update_domain_value 'mail' '$ANTISPAM' 'yes' # Logging -log_history "$V_EVENT" "v_delete_mail_domain_antispam $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_mail_domain_antispam $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_mail_domain_antivirus b/bin/v_add_mail_domain_antivirus index 81f5615d9..4d9a1b2a9 100755 --- a/bin/v_add_mail_domain_antivirus +++ b/bin/v_add_mail_domain_antivirus @@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -56,8 +55,8 @@ is_domain_key_empty 'mail' '$ANTIVIRUS' #----------------------------------------------------------# # Adding antivirus key to config -if [ -z "$(grep 'virus' $V_HOME/$user/conf/mail/$domain/protection)" ]; then - echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection +if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection fi #----------------------------------------------------------# @@ -68,7 +67,7 @@ fi update_domain_value 'mail' '$ANTIVIRUS' 'yes' # Logging -log_history "$V_EVENT" "v_delete_mail_domain_antivirus $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_mail_domain_antivirus $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_mail_domain_cactchall b/bin/v_add_mail_domain_cactchall index 22c70e4f7..bead73266 100755 --- a/bin/v_add_mail_domain_cactchall +++ b/bin/v_add_mail_domain_cactchall @@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain") email="$3" # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -31,16 +30,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain email' # Checking argument format -format_validation 'user' 'domain' 'email' +validate_format 'user' 'domain' 'email' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -57,8 +56,8 @@ is_domain_key_empty 'mail' '$CATCHALL' #----------------------------------------------------------# # Adding catchall alias -sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases -echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases +sed -i "/*@demo.vestacp.com:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "*@demo.vestacp.com:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases #----------------------------------------------------------# @@ -69,7 +68,7 @@ echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases update_domain_value 'mail' '$CATCHALL' "$email" # Logging -log_history "$V_EVENT" "v_delete_mail_domain_catchall $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_mail_domain_catchall $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_mail_domain_dkim b/bin/v_add_mail_domain_dkim index ac202e1e2..e3886a5e9 100755 --- a/bin/v_add_mail_domain_dkim +++ b/bin/v_add_mail_domain_dkim @@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain") dkim_size=${3-512} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -31,16 +30,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain [dkim_size]' # Checking argument format -format_validation 'user' 'domain' 'dkim_size' +validate_format 'user' 'domain' 'dkim_size' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -57,28 +56,28 @@ is_domain_key_empty 'mail' '$DKIM' #----------------------------------------------------------# # Generating dkim -openssl genrsa -out $V_USERS/$user/mail/$domain.pem $dkim_size 2>/dev/null -openssl rsa -pubout -in $V_USERS/$user/mail/$domain.pem \ - -out $V_USERS/$user/mail/$domain.pub 2>/dev/null -chmod 660 $V_USERS/$user/mail/$domain.* +openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null +openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ + -out $USER_DATA/mail/$domain.pub &>/dev/null +chmod 660 $USER_DATA/mail/$domain.* # Adding dkim to config -cp $V_USERS/$user/mail/$domain.pem $V_HOME/$user/conf/mail/$domain/dkim.pem -chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem -chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem +cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem +chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem +chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem # Checking dns domain check_dns_domain=$(is_domain_valid 'dns') if [ "$?" -eq 0 ]; then # Adding dkim dns records - p=$(cat $V_USERS/$user/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') + p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') record='_domainkey' policy="\"t=y; o=~;\"" - $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$policy" + $BIN/v_add_dns_domain_record $user $domain $record TXT "$policy" record='mail._domainkey' selector="\"k=rsa\; p=$p\"" - $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$selector" + $BIN/v_add_dns_domain_record $user $domain $record TXT "$selector" fi @@ -90,7 +89,7 @@ fi update_domain_value 'mail' '$DKIM' 'yes' # Logging -log_history "$V_EVENT" "v_delete_mail_domain_dkim $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_mail_domain_dkim $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_sys_ip b/bin/v_add_sys_ip index 7e4426f00..c1a5c9b09 100755 --- a/bin/v_add_sys_ip +++ b/bin/v_add_sys_ip @@ -23,11 +23,10 @@ ip_status="${5-shared}" ip_name=$6 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/ip.func -source $V_FUNC/domain.func # for namehosting +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh # for namehosting #----------------------------------------------------------# # Verifications # @@ -37,22 +36,22 @@ source $V_FUNC/domain.func # for namehosting check_args '2' "$#" 'ip mask [interface] [user] [ip_status] [ip_name]' # Checking argument format -format_validation 'ip' 'mask' 'interface' 'user' +validate_format 'ip' 'mask' 'interface' 'user' # Checking system ip is_sys_ip_free # Checking user -is_user_valid "$user" +is_object_valid 'user' 'USER' "$user" "$user" # Checking ip_status if [ ! -z "$ip_status" ]; then - format_validation 'ip_status' + validate_format 'ip_status' fi # Checking ip_name if [ ! -z "$ip_name" ] ; then - format_validation 'ip_name' + validate_format 'ip_name' fi @@ -80,7 +79,7 @@ ip_add_startup ip_add_vesta # Importing main config -source $V_CONF/vesta.conf +source $VESTA/conf/vesta.conf # Adding namehosting support namehost_ip_support @@ -107,10 +106,10 @@ fi # Adding task to the vesta pipe if [ "$web_restart" = 'yes' ]; then - restart_schedule 'web' + $BIN/v_restart_web fi # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_user b/bin/v_add_user index 360615c4f..6ea31dc8e 100755 --- a/bin/v_add_user +++ b/bin/v_add_user @@ -18,18 +18,17 @@ fname=$5 lname=$6 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh is_user_free() { # Parsing domain values check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" ) # Checking result - if [ ! -z "$check_sysuser" ] || [ -e "$V_USERS/$user" ]; then + if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then echo "Error: user $user exist" - log_event 'debug' "$E_EXISTS $V_EVENT" + log_event "$E_EXISTS" "$EVENT" exit $E_EXISTS fi } @@ -43,7 +42,7 @@ is_user_free() { check_args '3' "$#" 'user password email [package] [fname] [lname]' # Checking argument format -format_validation 'user' 'password' 'email' 'package' 'fname' 'lname' +validate_format 'user' 'password' 'email' 'package' 'fname' 'lname' # Checking user is_user_free "$user" @@ -57,7 +56,7 @@ is_package_valid "$package" #----------------------------------------------------------# # Parsing package data -package_data=$(cat $V_PKG/$package.pkg) +package_data=$(cat $VESTA/data/packages/$package.pkg) # Checking shell shell_conf=$(echo "$package_data" | grep 'SHELL' | cut -f 2 -d \') @@ -69,45 +68,45 @@ case $shell_conf in esac # Adding user -/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$V_HOME/$user" +/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user" # Adding password -echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1 +echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null # Building directory tree -mkdir $V_HOME/$user/conf -chmod 751 $V_HOME/$user/conf/web +mkdir $HOMEDIR/$user/conf +chmod 751 $HOMEDIR/$user/conf/web if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir $V_HOME/$user/conf/web - mkdir $V_HOME/$user/web - mkdir $V_HOME/$user/tmp - chmod 751 $V_HOME/$user/conf/web - chmod 751 $V_HOME/$user/web - chmod 777 $V_HOME/$user/tmp - chown $user:$user $V_HOME/$user/web + mkdir $HOMEDIR/$user/conf/web + mkdir $HOMEDIR/$user/web + mkdir $HOMEDIR/$user/tmp + chmod 751 $HOMEDIR/$user/conf/web + chmod 751 $HOMEDIR/$user/web + chmod 777 $HOMEDIR/$user/tmp + chown $user:$user $HOMEDIR/$user/web fi if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir $V_HOME/$user/conf/mail - mkdir $V_HOME/$user/mail - chmod 751 $V_HOME/$user/mail - chmod 751 $V_HOME/$user/conf/mail + mkdir $HOMEDIR/$user/conf/mail + mkdir $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/conf/mail fi if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir $V_HOME/$user/conf/dns - chmod 751 $V_HOME/$user/conf/dns + mkdir $HOMEDIR/$user/conf/dns + chmod 751 $HOMEDIR/$user/conf/dns fi # Set permissions -chmod -R a+x $V_HOME/$user +chmod -R a+x $HOMEDIR/$user # Checking quota if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then DISK_QUOTA=$(echo "$package_data" | grep 'DISK_QUOTA' | cut -f 2 -d \') - #$V_BIN/v_add_user_quota "$user" "$DISK_QUOTA" + #$BIN/v_add_user_quota "$user" "$DISK_QUOTA" fi @@ -116,57 +115,58 @@ fi #----------------------------------------------------------# # Adding user dir -mkdir $V_USERS/$user -chmod 770 $V_USERS/$user +mkdir $USER_DATA +chmod 770 $USER_DATA # Creating configuration files and pipes -touch $V_USERS/$user/backup.conf -chmod 660 $V_USERS/$user/backup.conf -touch $V_USERS/$user/history.log -chmod 660 $V_USERS/$user/history.log -touch $V_USERS/$user/stats.log -chmod 660 $V_USERS/$user/stats.log +touch $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf +touch $USER_DATA/history.log +chmod 660 $USER_DATA/history.log +touch $USER_DATA/stats.log +chmod 660 $USER_DATA/stats.log -echo "v_update_user_disk $user" >> $V_QUEUE/disk.pipe +echo "v_update_user_disk $user" >> $VESTA/data/queue/disk.pipe if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir $V_USERS/$user/ssl - chmod 770 $V_USERS/$user/ssl - touch $V_USERS/$user/web.conf - chmod 660 $V_USERS/$user/web.conf - echo "$V_BIN/v_update_web_domains_traff $user" >> $V_QUEUE/traffic.pipe - echo "v_update_web_domains_disk $user" >> $V_QUEUE/disk.pipe + mkdir $USER_DATA/ssl + chmod 770 $USER_DATA/ssl + touch $USER_DATA/web.conf + chmod 660 $USER_DATA/web.conf + echo "$BIN/v_update_web_domains_traff $user" \ + >> $VESTA/data/queue/traffic.pipe + echo "v_update_web_domains_disk $user" >> $VESTA/data/queue/disk.pipe fi if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir $V_USERS/$user/dns - chmod 770 $V_USERS/$user/dns - touch $V_USERS/$user/dns.conf - chmod 660 $V_USERS/$user/dns.conf + mkdir $USER_DATA/dns + chmod 770 $USER_DATA/dns + touch $USER_DATA/dns.conf + chmod 660 $USER_DATA/dns.conf fi if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir $V_USERS/$user/mail - chmod 770 $V_USERS/$user/mail - touch $V_USERS/$user/mail.conf - chmod 660 $V_USERS/$user/mail.conf - echo "v_upd_mail_domains_disk $user" >> $V_QUEUE/disk.pipe + mkdir $USER_DATA/mail + chmod 770 $USER_DATA/mail + touch $USER_DATA/mail.conf + chmod 660 $USER_DATA/mail.conf + echo "v_upd_mail_domains_disk $user" >> $VESTA/data/queue/disk.pipe fi if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - touch $V_USERS/$user/db.conf - chmod 660 $V_USERS/$user/db.conf - echo "v_update_db_bases_disk $user" >> $V_QUEUE/disk.pipe + touch $USER_DATA/db.conf + chmod 660 $USER_DATA/db.conf + echo "v_update_db_bases_disk $user" >> $VESTA/data/queue/disk.pipe fi if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - touch $V_USERS/$user/cron.conf - chmod 660 $V_USERS/$user/cron.conf + touch $USER_DATA/cron.conf + chmod 660 $USER_DATA/cron.conf fi # Filling user config if [ "$user" != 'admin' ]; then - ip_avail=$($V_BIN/v_list_user_ips admin plain |grep -w shared|wc -l) + ip_avail=$($BIN/v_list_user_ips admin plain |grep -w shared|wc -l) u_users=0 else ip_avail=0 @@ -178,7 +178,7 @@ LNAME='$lname' PACKAGE='$package' $package_data CONTACT='$email' -REPORTS='yes' +CRON_REPORTS='yes' RKEY='$(gen_password)' SUSPENDED='no' SUSPENDED_USERS='0' @@ -206,8 +206,8 @@ U_MAIL_ACCOUNTS='0' U_DATABASES='0' U_CRON_JOBS='0' U_BACKUPS='0' -DATE='$V_DATE'" > $V_USERS/$user/user.conf -chmod 660 $V_USERS/$user/user.conf +DATE='$DATE'" > $USER_DATA/user.conf +chmod 660 $USER_DATA/user.conf # Updating admin counter if [ "$user" != 'admin' ]; then @@ -215,9 +215,9 @@ if [ "$user" != 'admin' ]; then fi # Hiding password -V_EVENT="$V_DATE $V_SCRIPT $user ***** $email $package $fname $lname" +EVENT="$DATE $SCRIPT $user ***** $email $package $fname $lname" # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_user_backup b/bin/v_add_user_backup index 2682ba7d1..b484c5b6f 100755 --- a/bin/v_add_user_backup +++ b/bin/v_add_user_backup @@ -13,9 +13,8 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,13 +25,13 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking backup system is enabled is_system_enabled 'BACKUP_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user backups is_backup_enabled @@ -43,7 +42,7 @@ is_backup_enabled #----------------------------------------------------------# # Adding backup to pipe -echo "$user" >> $V_QUEUE/backup.pipe +echo "$user" >> $VESTA/data/queue/backup.pipe #----------------------------------------------------------# @@ -51,6 +50,6 @@ echo "$user" >> $V_QUEUE/backup.pipe #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain b/bin/v_add_web_domain index 0acd0ce85..ef5a6bdc4 100755 --- a/bin/v_add_web_domain +++ b/bin/v_add_web_domain @@ -23,11 +23,10 @@ ip=$3 template=${4-default} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -38,16 +37,16 @@ source $V_FUNC/ip.func check_args '3' "$#" 'user domain ip [template]' # Checking argument format -format_validation 'user' 'domain' 'ip' 'template' +validate_format 'user' 'domain' 'ip' 'template' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_new 'dns' @@ -60,7 +59,7 @@ is_package_full 'WEB_DOMAINS' # Checking template templates=$(get_user_value '$WEB_TPL') -is_template_valid "web" +is_apache_template_valid #----------------------------------------------------------# @@ -88,14 +87,14 @@ fi # Defining vars for add_config function group="$user" email="$user@$domain" -docroot="$V_HOME/$user/web/$domain/public_html" +docroot="$HOMEDIR/$user/web/$domain/public_html" docroot_string="DocumentRoot $docroot" -conf="$V_HOME/$user/conf/web/httpd.conf" -tpl_file="$V_WEBTPL/apache_$template.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$template.tpl" # Parsing template keys -template_data=$(cat $V_WEBTPL/apache_$template.descr|grep -v '#') +template_data=$(cat $WEBTPL/apache_$template.descr|grep -v '#') for keys in $template_data; do eval ${keys%%=*}=${keys#*=} done @@ -120,14 +119,14 @@ fi add_web_config # Building directory tree -mkdir $V_HOME/$user/web/$domain \ - $V_HOME/$user/web/$domain/public_html \ - $V_HOME/$user/web/$domain/public_shtml \ - $V_HOME/$user/web/$domain/document_errors \ - $V_HOME/$user/web/$domain/cgi-bin \ - $V_HOME/$user/web/$domain/private \ - $V_HOME/$user/web/$domain/stats \ - $V_HOME/$user/web/$domain/logs +mkdir $HOMEDIR/$user/web/$domain \ + $HOMEDIR/$user/web/$domain/public_html \ + $HOMEDIR/$user/web/$domain/public_shtml \ + $HOMEDIR/$user/web/$domain/document_errors \ + $HOMEDIR/$user/web/$domain/cgi-bin \ + $HOMEDIR/$user/web/$domain/private \ + $HOMEDIR/$user/web/$domain/stats \ + $HOMEDIR/$user/web/$domain/logs # Adding domain logs touch /var/log/httpd/domains/$domain.bytes \ @@ -135,50 +134,50 @@ touch /var/log/httpd/domains/$domain.bytes \ /var/log/httpd/domains/$domain.error.log # Adding symlink for logs -ln -s /var/log/httpd/domains/$domain.*log $V_HOME/$user/web/$domain/logs/ +ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/ # Adding domain skeleton -if [ -e "$V_WEBTPL/skel/public_html/" ]; then - cp -r $V_WEBTPL/skel/public_html/ $V_HOME/$user/web/$domain/ +if [ -e "$WEBTPL/skel/public_html/" ]; then + cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/ fi -if [ -e "$V_WEBTPL/skel/public_shtml/" ]; then - cp -r $V_WEBTPL/skel/public_shtml/ $V_HOME/$user/web/$domain/ +if [ -e "$WEBTPL/skel/public_shtml/" ]; then + cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/ fi -if [ -e "$V_WEBTPL/skel/document_errors/" ]; then - cp -r $V_WEBTPL/skel/document_errors/ $V_HOME/$user/web/$domain/ +if [ -e "$WEBTPL/skel/document_errors/" ]; then + cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ fi -if [ -e "$V_WEBTPL/skel/cgi-bin/" ]; then - cp -r $V_WEBTPL/skel/cgi-bin/ $V_HOME/$user/web/$domain/ +if [ -e "$WEBTPL/skel/cgi-bin/" ]; then + cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/ fi # Changing tpl values -for file in $(find "$V_HOME/$user/web/$domain/" -type f); do +for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do sed -i "s/%domain%/$domain/g" $file done # Changing file owner -chown -R $user:$user $V_HOME/$user/web/$domain +chown -R $user:$user $HOMEDIR/$user/web/$domain chown root:$user /var/log/httpd/domains/$domain.* chown root:apache $conf # Changing file permissions chmod 660 $conf -chmod 551 $V_HOME/$user/web/$domain -chmod 751 $V_HOME/$user/web/$domain/private -chmod 751 $V_HOME/$user/web/$domain/cgi-bin -chmod 751 $V_HOME/$user/web/$domain/public_html -chmod 751 $V_HOME/$user/web/$domain/public_shtml -chmod 751 $V_HOME/$user/web/$domain/document_errors -chmod -f -R 775 $V_HOME/$user/web/$domain/cgi-bin/* -chmod -f -R 775 $V_HOME/$user/web/$domain/public_html/* -chmod -f -R 775 $V_HOME/$user/web/$domain/document_errors/* -chmod 551 $V_HOME/$user/web/$domain/stats -chmod 551 $V_HOME/$user/web/$domain/logs +chmod 551 $HOMEDIR/$user/web/$domain +chmod 751 $HOMEDIR/$user/web/$domain/private +chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin +chmod 751 $HOMEDIR/$user/web/$domain/public_html +chmod 751 $HOMEDIR/$user/web/$domain/public_shtml +chmod 751 $HOMEDIR/$user/web/$domain/document_errors +chmod -f -R 775 $HOMEDIR/$user/web/$domain/cgi-bin/* +chmod -f -R 775 $HOMEDIR/$user/web/$domain/public_html/* +chmod -f -R 775 $HOMEDIR/$user/web/$domain/document_errors/* +chmod 551 $HOMEDIR/$user/web/$domain/stats +chmod 551 $HOMEDIR/$user/web/$domain/logs chmod 640 /var/log/httpd/domains/$domain.* # Running template trigger -if [ -x $V_WEBTPL/apache_$template.sh ]; then - $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot fi # Checking main vesta httpd config @@ -210,17 +209,17 @@ v_str="$v_str ALIAS='$aliases'" v_str="$v_str $template_data" # Inserting PHP, CGI and ELOG keys v_str="$v_str STATS='' STATS_AUTH=''" v_str="$v_str SSL='no' SSL_HOME='single'" -v_str="$v_str NGINX='' NGINX_EXT='' SUSPENDED='no' DATE='$V_DATE'" +v_str="$v_str NGINX='' NGINX_EXT='' SUSPENDED='no' DATE='$DATE'" # Registering domain -echo "$v_str" >> $V_USERS/$user/web.conf -chmod 660 $V_USERS/$user/web.conf +echo "$v_str" >> $USER_DATA/web.conf +chmod 660 $USER_DATA/web.conf # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_delete_web_domain $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain_alias b/bin/v_add_web_domain_alias index 3a850b3ef..dddd747d1 100755 --- a/bin/v_add_web_domain_alias +++ b/bin/v_add_web_domain_alias @@ -20,10 +20,9 @@ dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -34,16 +33,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain dom_alias' # Checking argument format -format_validation 'user' 'domain' 'dom_alias' +validate_format 'user' 'domain' 'dom_alias' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -64,8 +63,8 @@ is_package_full 'WEB_ALIASES' # Parsing domain values get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" # Parsing domain aliases if [ -z "$ALIAS" ]; then @@ -82,23 +81,23 @@ del_web_config add_web_config if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" del_web_config add_web_config if [ "$SSL" = 'yes' ]; then proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config add_web_config fi @@ -116,9 +115,9 @@ update_domain_value 'web' '$ALIAS' "$ALIAS" increase_user_value "$user" '$U_WEB_ALIASES' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web -log_history "$V_EVENT" "v_delete_web_domain_alias $user $domain $dom_alias" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain_alias $user $domain $dom_alias" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain_cgi b/bin/v_add_web_domain_cgi index 42e705c3c..f154fc51d 100755 --- a/bin/v_add_web_domain_cgi +++ b/bin/v_add_web_domain_cgi @@ -18,10 +18,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -32,16 +31,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -59,8 +58,8 @@ is_domain_key_empty 'web' '$CGI' # Parsing domain values get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" CGI='yes' # Preparing domain values for the template substitution @@ -72,8 +71,8 @@ add_web_config # Checking ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi @@ -87,10 +86,10 @@ fi update_domain_value 'web' '$CGI' 'yes' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_delete_web_domain_cgi $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain_cgi $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain_elog b/bin/v_add_web_domain_elog index 157a3c05a..a9822b06d 100755 --- a/bin/v_add_web_domain_elog +++ b/bin/v_add_web_domain_elog @@ -16,10 +16,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -57,8 +56,8 @@ is_domain_key_empty 'web' '$ELOG' # Parsing domain values get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" ELOG='yes' # Preparing domain values for the template substitution @@ -70,23 +69,23 @@ add_web_config # Checking ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" del_web_config add_web_config if [ "$SSL" = 'yes' ]; then proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config add_web_config fi @@ -101,10 +100,10 @@ fi update_domain_value 'web' '$ELOG' 'yes' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_delete_web_domain_elog $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain_elog $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain_nginx b/bin/v_add_web_domain_nginx index 095095562..d599c51f5 100755 --- a/bin/v_add_web_domain_nginx +++ b/bin/v_add_web_domain_nginx @@ -20,10 +20,9 @@ pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm" extentions=${4-$default_extentions} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -34,16 +33,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain [template] [extentions]' # Checking argument format -format_validation 'user' 'domain' 'template' 'extentions' +validate_format 'user' 'domain' 'template' 'extentions' # Checking proxy system is enabled is_system_enabled 'proxy' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -55,7 +54,7 @@ is_domain_suspended 'web' is_domain_key_empty 'web' '$NGINX' # Checking template -is_template_valid "proxy" +is_nginx_template_valid #----------------------------------------------------------# @@ -66,8 +65,8 @@ is_template_valid "proxy" get_domain_values 'web' NGINX="$template" NGINX_EXT="$extentions" -tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" -conf="$V_HOME/$user/conf/web/nginx.conf" +tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" # Preparing domain values for the template substitution upd_web_domain_values @@ -87,8 +86,8 @@ fi # Checking ssl if [ "$SSL" = 'yes' ]; then proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" add_web_config chown root:nginx $conf @@ -112,9 +111,9 @@ update_domain_value 'web' '$NGINX' "$NGINX" update_domain_value 'web' '$NGINX_EXT' "$extentions" # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web -log_history "$V_EVENT" "v_delete_web_domain_nginx $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain_nginx $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain_ssl b/bin/v_add_web_domain_ssl index 8ebc5f752..bd4c9a3a2 100755 --- a/bin/v_add_web_domain_ssl +++ b/bin/v_add_web_domain_ssl @@ -22,11 +22,10 @@ ssl_dir=$3 ssl_home=${4-single} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -37,16 +36,16 @@ source $V_FUNC/ip.func check_args '3' "$#" 'user domain ssl_dir [ssl_home]' # Checking argument format -format_validation 'user' 'domain' 'ssl_dir' +validate_format 'user' 'domain' 'ssl_dir' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -66,19 +65,19 @@ is_web_domain_cert_valid #----------------------------------------------------------# # Adding certificate to user data directory -cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $V_USERS/$user/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.pem +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt +cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $V_USERS/$user/ssl/$domain.ca - cat $V_USERS/$user/ssl/$domain.ca >> $V_USERS/$user/ssl/$domain.pem + cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca + cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem fi -chmod 660 $V_USERS/$user/ssl/$domain.* +chmod 660 $USER_DATA/ssl/$domain.* # Parsing domain values get_domain_values 'web' -conf="$V_HOME/$user/conf/web/shttpd.conf" -tpl_file="$V_WEBTPL/apache_$TPL.stpl" +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +tpl_file="$WEBTPL/apache_$TPL.stpl" SSL_HOME="$ssl_home" # Checking ip ownership @@ -94,16 +93,16 @@ chown root:apache $conf chmod 640 $conf # Adding certificate to user dir -cp -f $V_USERS/$user/ssl/$domain.crt $V_HOME/$user/conf/web/ssl.$domain.crt -cp -f $V_USERS/$user/ssl/$domain.key $V_HOME/$user/conf/web/ssl.$domain.key -cp -f $V_USERS/$user/ssl/$domain.pem $V_HOME/$user/conf/web/ssl.$domain.pem -if [ -e "$V_USERS/$user/ssl/$domain.ca" ]; then - cp -f $V_USERS/$user/ssl/$domain.ca $V_HOME/$user/conf/web/ssl.$domain.ca +cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt +cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key +cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca fi # Running template trigger -if [ -x $V_WEBTPL/apache_$template.sh ]; then - $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot fi # Checking main vesta httpd config @@ -116,8 +115,8 @@ fi # Checking nginx if [ ! -z "$NGINX" ]; then # Adding domain to the snginx.conf - conf="$V_HOME/$user/conf/web/snginx.conf" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" add_web_config chown root:nginx $conf @@ -144,7 +143,7 @@ update_domain_value 'web' '$SSL_HOME' "$SSL_HOME" update_domain_value 'web' '$SSL' 'yes' # Logging -log_history "$V_EVENT" "v_delete_web_domain_ssl $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain_ssl $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain_stat b/bin/v_add_web_domain_stat index 152a340a5..65cc5837a 100755 --- a/bin/v_add_web_domain_stat +++ b/bin/v_add_web_domain_stat @@ -20,10 +20,9 @@ domain_idn=$(idn -t --quiet -a "$domain") type=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -34,16 +33,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain type' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid "$user" +is_object_valid 'user' 'USER' "$user" "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -52,7 +51,7 @@ is_domain_valid 'web' is_domain_suspended 'web' # Checking statistic type -is_type_valid 'stat' "$type" +is_type_valid "$STATS_SYSTEM" "$type" # Check statistic is not added is_domain_key_empty 'web' '$STATS' @@ -69,7 +68,7 @@ get_domain_values 'web' upd_web_domain_values # Adding statistic config -cat $V_WEBTPL/$type.tpl |\ +cat $WEBTPL/$type.tpl |\ sed -e "s/%ip%/$ip/g" \ -e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ @@ -78,10 +77,10 @@ cat $V_WEBTPL/$type.tpl |\ -e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain%/$domain/g" \ -e "s/%user%/$user/g" \ - -e "s/%home%/${V_HOME////\/}/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ -e "s/%alias%/${aliases//,/ }/g" \ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $V_HOME/$user/conf/web/$type.$domain.conf + > $HOMEDIR/$user/conf/web/$type.$domain.conf #----------------------------------------------------------# @@ -89,13 +88,13 @@ cat $V_WEBTPL/$type.tpl |\ #----------------------------------------------------------# # Adding command to pipe -echo "$V_BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe +echo "$BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe # Adding stats in config update_domain_value 'web' '$STATS' "$type" # Logging -log_history "$V_EVENT" "v_delete_web_domain_stat $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain_stat $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_add_web_domain_stat_auth b/bin/v_add_web_domain_stat_auth index ea9998aeb..7728eef7d 100755 --- a/bin/v_add_web_domain_stat_auth +++ b/bin/v_add_web_domain_stat_auth @@ -16,10 +16,9 @@ auth_user=$3 auth_pass=$4 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '4' "$#" 'user domain auth_user auth_password' # Checking argument format -format_validation 'user' 'domain' 'auth_user' 'auth_pass' +validate_format 'user' 'domain' 'auth_user' 'auth_pass' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -53,7 +52,7 @@ is_domain_suspended 'web' #----------------------------------------------------------# # Definining statistic dir -stat_dir="$V_HOME/$user/web/$domain/stats" +stat_dir="$HOMEDIR/$user/web/$domain/stats" # Adding htaccess file if [ ! -e "$stat_dir/.htaccess" ]; then @@ -66,9 +65,9 @@ fi # Generating htaccess user and password if [ ! -e "$stat_dir/.htpasswd" ]; then - htpasswd -bc $stat_dir/.htpasswd "$auth_user" "$auth_pass" >/dev/null 2>&1 + htpasswd -bc $stat_dir/.htpasswd "$auth_user" "$auth_pass" &>/dev/null else - htpasswd -b $stat_dir/.htpasswd "$auth_user" "$auth_pass" >/dev/null 2>&1 + htpasswd -b $stat_dir/.htpasswd "$auth_user" "$auth_pass" &>/dev/null fi @@ -95,10 +94,10 @@ fi update_domain_value 'web' '$STATS_AUTH' "$a_users" # Hiding password -V_EVENT="$V_DATE $V_SCRIPT $user $domain $auth_user *****" +EVENT="$DATE $SCRIPT $user $domain $auth_user *****" # Logging -log_history "$V_EVENT" "v_delete_web_domain_stat_auth $user $domain $auth_user" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_delete_web_domain_stat_auth $user $domain $auth_user" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_backup_user b/bin/v_backup_user index d885e7e22..68f6948a7 100755 --- a/bin/v_backup_user +++ b/bin/v_backup_user @@ -13,11 +13,10 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -28,13 +27,13 @@ source $V_FUNC/db.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking backup system is enabled is_system_enabled 'BACKUP_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user backups is_backup_enabled @@ -42,7 +41,7 @@ is_backup_enabled # Checking load averages la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.') i=0 -while [ "$la" -ge "$V_BACKUP_LA_LIMIT" ]; do +while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do echo "$(date "+%F %T") Load Average $la" echo @@ -50,7 +49,7 @@ while [ "$la" -ge "$V_BACKUP_LA_LIMIT" ]; do if [ "$i" -ge "15" ]; then echo "Error: LA is too high" - log_event 'debug' "$E_LA $V_EVENT" + log_event 'debug' "$E_LA $EVENT" exit $E_LA fi @@ -66,7 +65,7 @@ done start_time=$(date '+%s') # Creating temporary random directory -tmpdir=$(mktemp -p $V_BACKUP -d) +tmpdir=$(mktemp -p $BACKUP -d) # Prinitng status echo "$(date "+%F %T") System backup for user $user" @@ -87,21 +86,21 @@ mkdir $tmpdir/vesta # Backingup vesta configs echo -e "$(date "+%F %T") user.conf" -cp -r $V_USERS/$user/user.conf $tmpdir/vesta/ +cp -r $USER_DATA/user.conf $tmpdir/vesta/ -if [ -e "$V_USERS/$user/stats.log" ]; then +if [ -e "$USER_DATA/stats.log" ]; then echo -e "$(date "+%F %T") stats.log" - cp -r $V_USERS/$user/stats.log $tmpdir/vesta/ + cp -r $USER_DATA/stats.log $tmpdir/vesta/ fi -if [ -e "$V_USERS/$user/history.log" ]; then +if [ -e "$USER_DATA/history.log" ]; then echo -e "$(date "+%F %T") history.log" - cp -r $V_USERS/$user/history.log $tmpdir/vesta/ + cp -r $USER_DATA/history.log $tmpdir/vesta/ fi -if [ -e "$V_USERS/$user/backup.excludes" ]; then +if [ -e "$USER_DATA/backup.excludes" ]; then echo -e "$(date "+%F %T") backup.excludes" - cp -r $V_USERS/$user/backup.excludes $tmpdir/vesta/ + cp -r $USER_DATA/backup.excludes $tmpdir/vesta/ fi @@ -120,10 +119,10 @@ echo # Checking excludes OLD_IFS="$IFS" IFS=$'\n' -if [ -e "$V_USERS/$user/backup.excludes" ]; then +if [ -e "$USER_DATA/backup.excludes" ]; then echo "-- Excludes --" - for exclude in $(cat $V_USERS/$user/backup.excludes); do + for exclude in $(cat $USER_DATA/backup.excludes); do echo -e "$exclude" # Indirect variable references (a bit of black magic) eval ${exclude%%=*}=${exclude#*=} @@ -139,7 +138,7 @@ then mkdir $tmpdir/web/ # Parsing unsuspeneded domains - conf="$V_USERS/$user/web.conf" + conf="$USER_DATA/web.conf" field='$DOMAIN' search_string='DOMAIN=' domains=$(dom_clear_search) @@ -163,27 +162,27 @@ then get_domain_values 'web' # Packing data folders - cd $V_HOME/$user/web/$domain + cd $HOMEDIR/$user/web/$domain tar -cf $tmpdir/web/$domain/$domain.tar \ public_html public_shtml private document_errors cgi-bin stats # Creating web.config cd $tmpdir/web/$domain/ - conf="$V_USERS/$user/web.conf" + conf="$USER_DATA/web.conf" grep "DOMAIN='$domain'" $conf > conf/vesta.conf # Apache config if [ "$WEB_SYSTEM" = 'apache' ]; then # Parsing httpd.conf - tpl_file="$V_WEBTPL/apache_$TPL.tpl" - conf="$V_HOME/$user/conf/web/httpd.conf" + tpl_file="$WEBTPL/apache_$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/httpd.conf" get_web_config_brds sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf # SSL check if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" get_web_config_brds sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf fi @@ -191,36 +190,36 @@ then # Nginx config if [ ! -z "$NGINX" ] ; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" get_web_config_brds sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf # SSL check if [ "$SSL" = 'yes' ] ; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" get_web_config_brds sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf fi fi # Suplemental configs - for sconfig in $(ls $V_HOME/$user/conf/web/|grep ".$domain.conf"); do - cp $V_HOME/$user/conf/web/$sconfig conf/ + for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do + cp $HOMEDIR/$user/conf/web/$sconfig conf/ done # SSL Certificates if [ "$SSL" = 'yes' ] ; then - cp $V_HOME/$user/conf/web/ssl.$domain.* conf/ + cp $HOMEDIR/$user/conf/web/ssl.$domain.* conf/ fi tar -rf $tmpdir/web/$domain/$domain.tar conf mv $tmpdir/web/$domain/$domain.tar $tmpdir/web/ rm -rf $tmpdir/web/$domain - if [ ! -z "$V_BACKUP_GZIP" ]; then - gzip -$V_BACKUP_GZIP $tmpdir/web/$domain.tar + if [ ! -z "$BACKUP_GZIP" ]; then + gzip -$BACKUP_GZIP $tmpdir/web/$domain.tar fi done @@ -234,7 +233,7 @@ then mkdir $tmpdir/dns/ # Parsing unsuspeneded domains - conf="$V_USERS/$user/dns.conf" + conf="$USER_DATA/dns.conf" field='$DOMAIN' search_string='DOMAIN=' domains=$(dom_clear_search) @@ -255,12 +254,12 @@ then # Creating dns_domains config cd $tmpdir/dns/$domain/ - conf="$V_USERS/$user/dns.conf" + conf="$USER_DATA/dns.conf" grep "DOMAIN='$domain'" $conf > dns.conf # Backingup dns recods - cp $V_USERS/$user/dns/$domain $domain - cp $V_USERS/$user/conf/dns/$domain.db $domain.db + cp $USER_DATA/dns/$domain $domain + cp $USER_DATA/conf/dns/$domain.db $domain.db done echo fi @@ -275,7 +274,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then mkdir $tmpdir/db/ # Parsing unsuspeneded domains - conf="$V_USERS/$user/db.conf" + conf="$USER_DATA/db.conf" field='$DB' search_string='DB=' dbs=$(dom_clear_search) @@ -303,8 +302,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then pgsql) dump_db_pgsql ;; esac - if [ ! -z "$V_BACKUP_GZIP" ]; then - gzip -$V_BACKUP_GZIP $dump + if [ ! -z "$BACKUP_GZIP" ]; then + gzip -$BACKUP_GZIP $dump fi done @@ -319,7 +318,7 @@ then # Backingup cron recods echo -e "$(date "+%F %T") cron.conf" - cp $V_USERS/$user/cron.conf $tmpdir/cron/ + cp $USER_DATA/cron.conf $tmpdir/cron/ echo -e "$(date "+%F %T") system cron" if [ -e "/var/spool/cron/$user" ]; then @@ -338,17 +337,17 @@ end_time=$(date '+%s') # Defining local storage function local_backup(){ echo "-- STORAGE --" - echo -e "$(date "+%F %T") ARCHIVE $V_BACKUP/$user.$V_DATE.tar" + echo -e "$(date "+%F %T") ARCHIVE $BACKUP/$user.$DATE.tar" # Removing dublicate for this day - if [ -e "$V_BACKUP/$user.$V_DATE.tar" ]; then - deprecated="$V_DATE" - echo -e "Deleting old backup for $V_DATE" - rm -f $V_BACKUP/$user.$V_DATE.tar + if [ -e "$BACKUP/$user.$DATE.tar" ]; then + deprecated="$DATE" + echo -e "Deleting old backup for $DATE" + rm -f $BACKUP/$user.$DATE.tar fi # Checking retention - backup_list=$(ls -lrt $V_BACKUP/ | awk '{print $9}' |grep "^$user\.") + backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.") backups_count=$(echo "$backup_list" | wc -l) if [ "$BACKUPS" -le "$backups_count" ]; then @@ -360,23 +359,23 @@ local_backup(){ backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//") deprecated="$deprecated $backup_date" echo -e "\tDeleteing old backup for $backup_date" - rm -f $V_BACKUP/$backup + rm -f $BACKUP/$backup done fi # Checking disk space - disk_usage=$(df $V_BACKUP | awk '{print $5}'|tail -n1|cut -f 1 -d '%') - if [ "$disk_usage" -ge "$V_BACKUP_DISK_LIMIT" ]; then + disk_usage=$(df $BACKUP | awk '{print $5}'|tail -n1|cut -f 1 -d '%') + if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then echo "Error: Not enough disk space" - log_event 'debug' "$E_DISK $V_EVENT" + log_event 'debug' "$E_DISK $EVENT" exit $E_DISK fi # Creating final tarball cd $tmpdir - tar -cf $V_BACKUP/$user.$V_DATE.tar . - chmod 640 $V_BACKUP/$user.$V_DATE.tar - chown nginx:$user $V_BACKUP/$user.$V_DATE.tar + tar -cf $BACKUP/$user.$DATE.tar . + chmod 640 $BACKUP/$user.$DATE.tar + chown nginx:$user $BACKUP/$user.$DATE.tar localbackup='yes' echo } @@ -399,17 +398,17 @@ ftp_backup(){ echo "-- FTP --" # Checking config - source $V_CONF/ftp.backup.conf + source $VESTA/conf/ftp.backup.conf if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\ [ -z "$BPATH" ]; then echo "Error: Parsing error" - log_event 'debug' "$E_PARSING $V_EVENT" + log_event 'debug' "$E_PARSING $EVENT" exit $E_PARSING fi # Debug info echo -ne "$(date "+%F %T") " - echo -e "ftp://$USERNAME@$HOST$BPATH/$user.$V_DATE.tar" + echo -e "ftp://$USERNAME@$HOST$BPATH/$user.$DATE.tar" # Checking ftp permission ftmpdir=$(mktemp -u -p $BPATH) @@ -418,7 +417,7 @@ ftp_backup(){ rm $ftmpdir" if [ ! -z "$(ftpc "$command")" ] ; then echo "Error: FTP error" - log_event 'debug' "$E_FTP $V_EVENT" + log_event 'debug' "$E_FTP $EVENT" exit $E_FTP fi @@ -437,14 +436,14 @@ ftp_backup(){ # Uploading backup archive if [ "$localbackup" = 'yes' ]; then - cd $V_BACKUP - ftpc "put $user.$V_DATE.tar" + cd $BACKUP + ftpc "put $user.$DATE.tar" else cd $tmpdir - tar -cf $V_BACKUP/$user.$V_DATE.tar . - cd $V_BACKUP/ - ftpc "put $user.$V_DATE.tar" - rm -f $user.$V_DATE.tar + tar -cf $BACKUP/$user.$DATE.tar . + cd $BACKUP/ + ftpc "put $user.$DATE.tar" + rm -f $user.$DATE.tar fi echo } @@ -484,13 +483,13 @@ echo # Deleting old backup records for backup_record in $deprecated; do - if [ -e "$V_USERS/$user/backup.conf" ]; then - sed -i "/DATE='$backup_record/d" $V_USERS/$user/backup.conf + if [ -e "$USER_DATA/backup.conf" ]; then + sed -i "/DATE='$backup_record/d" $USER_DATA/backup.conf fi done # Concatenating string -backup_str="DATE='$V_DATE' TIME='$current_time' RUNTIME='$run_time'" +backup_str="DATE='$DATE' TIME='$current_time' RUNTIME='$run_time'" backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'" backup_str="$backup_str VESTA='$vst'" backup_str="$backup_str PAM='$pam'" @@ -499,10 +498,10 @@ backup_str="$backup_str DNS='${dns_list// /,}'" backup_str="$backup_str MAIL='${mail_list// /,}'" backup_str="$backup_str DB='${db_list// /,}'" backup_str="$backup_str CRON='$cron_list'" -echo "$backup_str" >> $V_USERS/$user/backup.conf -chmod 660 $V_USERS/$user/backup.conf +echo "$backup_str" >> $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_backup_users b/bin/v_backup_users index 1a1ac0037..193d12d9a 100755 --- a/bin/v_backup_users +++ b/bin/v_backup_users @@ -14,9 +14,8 @@ source /etc/profile.d/vesta.sh # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -27,7 +26,7 @@ user_list=$(ls $V_USERS/) # Updating user billing for user in $user_list; do - $V_BIN/v_backup_user $user >> $V_LOG/backup.log 2>> $V_LOG/backup.log + $BIN/v_backup_user $user &>> $VESTA/logs/backup.log done #----------------------------------------------------------# @@ -35,6 +34,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_cron_job b/bin/v_change_cron_job index c72a4eb1f..0b7b909ad 100755 --- a/bin/v_change_cron_job +++ b/bin/v_change_cron_job @@ -20,52 +20,37 @@ month=$6 wday=$7 command=$8 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number 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_valid 'cron' 'JOB' "$job" -# Checking argument format -format_validation 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command' - -# Checking cron system -is_system_enabled 'CRON_SYSTEM' - -# Checking user -is_user_valid - -# Checking user is active -is_user_suspended - -# Checking cron job -is_job_valid - -# Checking job is active -# is_job_suspended #----------------------------------------------------------# # Action # #----------------------------------------------------------# # Concatenating cron string -command=$(echo $command|sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") -v_str="JOB='$job' MIN='$min' HOUR='$hour' WDAY='$wday'" -v_str="$v_str MONTH='$month' DAY='$day' CMD='$command' SUSPENDED='no'" +command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") +str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month WDAY='$wday'" +str="$v_str' CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -# Deleting job -del_cron_job +# Deleting old job +sed -i "/JOB='$job' /d" $USER_DATA/cron.conf -# Adding to crontab -echo "$v_str">>$V_USERS/$user/cron.conf +# Adding new +echo "$v_str" >> $USER_DATA/cron.conf # Sorting jobs by id sort_cron_jobs @@ -78,11 +63,11 @@ sync_cron_jobs # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_history "$V_EVENT" -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_db_password b/bin/v_change_db_password index f7485c9b2..6f7594448 100755 --- a/bin/v_change_db_password +++ b/bin/v_change_db_password @@ -16,10 +16,9 @@ database=$2 db_password=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/db.func check_args '3' "$#" 'user db_name db_password' # Checking argument format -format_validation 'user' 'database' 'db_password' +validate_format 'user' 'database' 'db_password' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking db existance is_db_valid @@ -69,9 +68,9 @@ esac #----------------------------------------------------------# # Hiding password -V_EVENT="$V_DATE $V_SCRIPT $user $database *****" +EVENT="$DATE $SCRIPT $user $database *****" # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_dns_domain_exp b/bin/v_change_dns_domain_exp index c0c69c7c3..e32e4808a 100755 --- a/bin/v_change_dns_domain_exp +++ b/bin/v_change_dns_domain_exp @@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain") exp=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -31,16 +30,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain exp' # Checking argument format -format_validation 'user' 'domain' 'exp' +validate_format 'user' 'domain' 'exp' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -65,7 +64,7 @@ update_domain_value 'dns' '$EXP' "$exp" #----------------------------------------------------------# # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_exp" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $old_exp" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_dns_domain_ip b/bin/v_change_dns_domain_ip index 10ecfc54b..c450fecff 100755 --- a/bin/v_change_dns_domain_ip +++ b/bin/v_change_dns_domain_ip @@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain") ip=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# # Verifications # @@ -29,16 +28,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain ip' # Checking argument format -format_validation 'user' 'domain' 'ip' +validate_format 'user' 'domain' 'ip' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -58,7 +57,7 @@ old_ip=$(get_domain_value 'dns' '$IP') update_domain_value 'dns' '$IP' "$ip" # Changing records -sed -i "s/$old_ip/$ip/g" $V_USERS/$user/dns/$domain +sed -i "s/$old_ip/$ip/g" $USER_DATA/dns/$domain # Updating zone update_domain_zone @@ -69,10 +68,10 @@ update_domain_zone #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ip" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $old_ip" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_dns_domain_record b/bin/v_change_dns_domain_record index d1d6c02ed..c7cd1c383 100755 --- a/bin/v_change_dns_domain_record +++ b/bin/v_change_dns_domain_record @@ -19,10 +19,9 @@ rtype=$(echo "$5"| tr '[:lower:]' '[:upper:]') value=$(idn -t --quiet -u "$6" ) # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -33,16 +32,16 @@ source $V_FUNC/domain.func check_args '5' "$#" 'user domain id record type value' # Checking argument format -format_validation 'user' 'domain' 'id' 'record' 'rtype' +validate_format 'user' 'domain' 'id' 'record' 'rtype' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -58,7 +57,7 @@ is_dns_record_valid #----------------------------------------------------------# # Defining zone path -zone="$V_USERS/$user/dns/$domain" +zone="$USER_DATA/dns/$domain" # Deleting old record rm_string=$(grep -n "^ID='$id'" $zone|cut -d : -f 1) @@ -68,7 +67,7 @@ fi # Adding record dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$value'" -dns_rec="$dns_rec SUSPENDED='no' DATE='$V_DATE'" +dns_rec="$dns_rec SUSPENDED='no' DATE='$DATE'" echo "$dns_rec" >> $zone # Sorting records @@ -83,10 +82,10 @@ update_domain_zone #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_dns_domain_soa b/bin/v_change_dns_domain_soa index f3c83e6f5..17be8de87 100755 --- a/bin/v_change_dns_domain_soa +++ b/bin/v_change_dns_domain_soa @@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain") soa=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# # Verifications # @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain soa' # Checking argument format -format_validation 'user' 'domain' 'soa' +validate_format 'user' 'domain' 'soa' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -67,10 +66,10 @@ update_domain_zone #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_soa" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $old_soa" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_dns_domain_tpl b/bin/v_change_dns_domain_tpl index 14801a51c..011f002ea 100755 --- a/bin/v_change_dns_domain_tpl +++ b/bin/v_change_dns_domain_tpl @@ -18,10 +18,9 @@ domain_idn=$(idn -t --quiet -a "$domain") template=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -32,16 +31,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain template' # Checking argument format -format_validation 'user' 'domain' 'template' +validate_format 'user' 'domain' 'template' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -50,7 +49,7 @@ is_domain_valid 'dns' is_domain_suspended 'dns' # Checking template -is_template_valid 'dns' +is_dns_template_valid #----------------------------------------------------------# @@ -65,7 +64,7 @@ ns2=$(get_user_value '$NS2') # Changing tpl update_domain_value 'dns' '$TPL' "$template" -cat $V_DNSTPL/$template.tpl |\ +cat $DNSTPL/$template.tpl |\ sed -e "s/%ip%/$ip/g" \ -e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain%/$domain/g" \ @@ -77,10 +76,10 @@ cat $V_DNSTPL/$template.tpl |\ -e "s/%ns6%/$ns6/g" \ -e "s/%ns7%/$ns7/g" \ -e "s/%ns8%/$ns8/g" \ - -e "s/%date%/$V_DATE/g" > $V_USERS/$user/dns/$domain + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain # Updating zone -conf="$V_HOME/$user/conf/dns/$domain.db" +conf="$HOMEDIR/$user/conf/dns/$domain.db" update_domain_zone @@ -89,10 +88,10 @@ update_domain_zone #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_tpl" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $old_tpl" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_dns_domain_ttl b/bin/v_change_dns_domain_ttl index dbface527..e14b1343b 100755 --- a/bin/v_change_dns_domain_ttl +++ b/bin/v_change_dns_domain_ttl @@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain") ttl=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain ttl' # Checking argument format -format_validation 'user' 'domain' 'ttl' +validate_format 'user' 'domain' 'ttl' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -67,10 +66,10 @@ update_domain_zone #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ttl" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $old_ttl" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_mail_domain_cactchall b/bin/v_change_mail_domain_cactchall index 19159e0e7..48b0e5414 100755 --- a/bin/v_change_mail_domain_cactchall +++ b/bin/v_change_mail_domain_cactchall @@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain") email="$3" # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -31,16 +30,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain email' # Checking argument format -format_validation 'user' 'domain' 'email' +validate_format 'user' 'domain' 'email' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -57,8 +56,8 @@ is_domain_suspended 'mail' catchall=$(get_domain_value 'mail' '$CATCHALL') # Change cathcall alias -sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases -echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases +sed -i "/*@demo.vestacp.com:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "*@demo.vestacp.com:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases #----------------------------------------------------------# @@ -69,7 +68,7 @@ echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases update_domain_value 'mail' '$CATCHALL' "$email" # Logging -log_history "$V_EVENT" "v_change_mail_domain_catchall $user $domain $catchall" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_change_mail_domain_catchall $user $domain $catchall" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_sys_config_value b/bin/v_change_sys_config_value index 1ca7623d7..a7e914407 100755 --- a/bin/v_change_sys_config_value +++ b/bin/v_change_sys_config_value @@ -15,9 +15,8 @@ key=$(echo "$1" | tr '[:lower:]' '[:upper:]' ) value=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -28,13 +27,13 @@ source $V_FUNC/shared.func check_args '2' "$#" 'key value' # Checking argument format -format_validation 'key' +validate_format 'key' # Checking key existance -check_ckey=$(grep "^$key='" $V_CONF/vesta.conf) +check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf) if [ -z "$check_ckey" ]; then echo "Error: key not found" - log_event 'debug' "$E_INVALID $V_EVENT" + log_event 'debug' "$E_INVALID $EVENT" exit $E_INVALID fi @@ -44,7 +43,7 @@ fi #----------------------------------------------------------# # Updating conf -sed -i "s/$key=.*/$key='$value'/g" $V_CONF/vesta.conf +sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf #----------------------------------------------------------# @@ -52,6 +51,6 @@ sed -i "s/$key=.*/$key='$value'/g" $V_CONF/vesta.conf #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_sys_ip_name b/bin/v_change_sys_ip_name index d0c425d17..ccee08e18 100755 --- a/bin/v_change_sys_ip_name +++ b/bin/v_change_sys_ip_name @@ -14,10 +14,9 @@ ip=$1 ip_name=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -28,7 +27,7 @@ source $V_FUNC/ip.func check_args '2' "$#" 'ip ip_name' # Checking argument format -format_validation 'ip' 'ip_name' +validate_format 'ip' 'ip_name' # Checking system ip is_sys_ip_valid @@ -47,6 +46,6 @@ update_sys_ip_value '$NAME' "$ip_name" #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_sys_ip_owner b/bin/v_change_sys_ip_owner index b7572eae5..f276c4dfb 100755 --- a/bin/v_change_sys_ip_owner +++ b/bin/v_change_sys_ip_owner @@ -14,10 +14,9 @@ ip=$1 user=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -28,13 +27,13 @@ source $V_FUNC/ip.func check_args '2' "$#" 'ip user' # Checking argument format -format_validation 'ip' 'user' +validate_format 'ip' 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking system ip is_sys_ip_valid @@ -90,6 +89,6 @@ fi #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_sys_ip_status b/bin/v_change_sys_ip_status index 9999609e9..d15a4fa68 100755 --- a/bin/v_change_sys_ip_status +++ b/bin/v_change_sys_ip_status @@ -14,10 +14,9 @@ ip=$1 ip_status=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -28,7 +27,7 @@ source $V_FUNC/ip.func check_args '2' "$#" 'ip ip_status' # Checking argument format -format_validation 'ip' 'ip_status' +validate_format 'ip' 'ip_status' # Checking system ip is_sys_ip_valid @@ -37,7 +36,7 @@ is_sys_ip_valid current_status=$(get_sys_ip_value '$STATUS') if [ "$ip_status" = "$current_status" ]; then echo "Error: status is already set" - log_event 'debug' "$E_EXISTS $V_EVENT" + log_event 'debug' "$E_EXISTS $EVENT" exit $E_EXISTS fi @@ -49,7 +48,7 @@ ip_owner=$(get_sys_ip_value '$OWNER') # Checking condition if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then echo "Error: ip is used" - log_event 'debug' "$E_INUSE $V_EVENT" + log_event 'debug' "$E_INUSE $EVENT" exit $E_INUSE fi @@ -67,6 +66,6 @@ update_sys_ip_value '$STATUS' "$ip_status" #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_user_contact b/bin/v_change_user_contact index e8162c9dc..2ea9ec771 100755 --- a/bin/v_change_user_contact +++ b/bin/v_change_user_contact @@ -14,9 +14,8 @@ user=$1 email=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/shared.func check_args '2' "$#" 'user email' # Checking argument format -format_validation 'user' 'email' +validate_format 'user' 'email' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -57,7 +56,7 @@ sed -i "$str s/$old_email/$email/g" /etc/passwd #----------------------------------------------------------# # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $old_email" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $old_email" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_user_name b/bin/v_change_user_name index 9f88eab6a..182963958 100755 --- a/bin/v_change_user_name +++ b/bin/v_change_user_name @@ -15,9 +15,8 @@ fname=$2 lname=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -28,13 +27,13 @@ source $V_FUNC/shared.func check_args '3' "$#" 'user fname lname' # Checking argument format -format_validation 'user' 'fname' 'lname' +validate_format 'user' 'fname' 'lname' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -55,7 +54,7 @@ update_user_value "$user" '$LNAME' "$lname" #----------------------------------------------------------# # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $old_fname $old_lname" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $old_fname $old_lname" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_user_ns b/bin/v_change_user_ns index 32f364166..dd65ad307 100755 --- a/bin/v_change_user_ns +++ b/bin/v_change_user_ns @@ -21,9 +21,8 @@ ns7=$8 ns8=$9 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -34,36 +33,36 @@ source $V_FUNC/shared.func check_args '3' "$#" 'user ns1 ns2 [ns3] [ns4] [ns5] [ns6] [ns7] [ns8]' # Checking argument format -format_validation 'user' 'ns1' 'ns2' +validate_format 'user' 'ns1' 'ns2' if [ ! -z "$ns3" ]; then - format_validation 'ns3' + validate_format 'ns3' fi if [ ! -z "$ns4" ]; then - format_validation 'ns4' + validate_format 'ns4' fi if [ ! -z "$ns5" ]; then - format_validation 'ns5' + validate_format 'ns5' fi if [ ! -z "$ns6" ]; then - format_validation 'ns6' + validate_format 'ns6' fi if [ ! -z "$ns7" ]; then - format_validation 'ns7' + validate_format 'ns7' fi if [ ! -z "$ns8" ]; then - format_validation 'ns8' + validate_format 'ns8' fi # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -86,7 +85,7 @@ update_user_value "$user" '$NS' "$ns" #----------------------------------------------------------# # Logging -log_history "$V_EVENT" "$V_SCRIPT $user ${old_ns//,/ }" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user ${old_ns//,/ }" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_user_package b/bin/v_change_user_package index 6093ace01..db69cd365 100755 --- a/bin/v_change_user_package +++ b/bin/v_change_user_package @@ -14,13 +14,12 @@ user=$1 package=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh is_package_avalable() { # Parsing user data - usr_data=$(cat $V_USERS/$user/user.conf) + usr_data=$(cat $USER_DATA/user.conf) IFS=$'\n' for key in $usr_data; do eval ${key%%=*}=${key#*=} @@ -35,7 +34,7 @@ is_package_avalable() { BANDWIDTH='0' # Parsing package - pkg_data=$(cat $V_PKG/$package.pkg) + pkg_data=$(cat $VESTA/data/packages/$package.pkg) for key in $pkg_data; do eval ${key%%=*}=${key#*=} done @@ -56,11 +55,11 @@ is_package_avalable() { change_user_package() { # Parsing user data - usr_data=$(cat $V_USERS/$user/user.conf) + usr_data=$(cat $USER_DATA/user.conf) eval $usr_data # Parsing package - pkg_data=$(cat $V_PKG/$package.pkg) + pkg_data=$(cat $VESTA/data/packages/$package.pkg) eval $pkg_data echo "FNAME='$FNAME' @@ -81,7 +80,7 @@ NS='$NS' SHELL='$SHELL' BACKUPS='$BACKUPS' CONTACT='$CONTACT' -REPORTS='$REPORTS' +CRON_REPORTS='$CRON_REPORTS' RKEY='$RKEY' SUSPENDED='$SUSPENDED' SUSPENDED_USERS='$SUSPENDED_USERS' @@ -109,7 +108,7 @@ U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES' U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS' -DATE='$DATE'" > $V_USERS/$user/user.conf +DATE='$DATE'" > $USER_DATA/user.conf } @@ -121,10 +120,10 @@ DATE='$DATE'" > $V_USERS/$user/user.conf check_args '2' "$#" 'user package' # Checking argument format -format_validation 'user' 'package' +validate_format 'user' 'package' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking package is_package_valid @@ -146,6 +145,6 @@ change_user_package #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_user_password b/bin/v_change_user_password index 85ef6066c..9fad79e5a 100755 --- a/bin/v_change_user_password +++ b/bin/v_change_user_password @@ -14,9 +14,8 @@ user=$1 password=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/shared.func check_args '2' "$#" 'user password' # Checking argument format -format_validation 'user' 'password' +validate_format 'user' 'password' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_suspended #----------------------------------------------------------# # Changing user password -echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1 +echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null #----------------------------------------------------------# @@ -52,9 +51,9 @@ echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1 update_user_value "$user" '$RKEY' "$(gen_password)" # Hiding password -V_EVENT="$V_DATE $V_SCRIPT $user *****" +EVENT="$DATE $SCRIPT $user *****" # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_user_shell b/bin/v_change_user_shell index 55b9f14be..d1c1c3ca0 100755 --- a/bin/v_change_user_shell +++ b/bin/v_change_user_shell @@ -14,9 +14,8 @@ user=$1 shell=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/shared.func check_args '2' "$#" 'user shell' # Checking argument format -format_validation 'user' 'shell' +validate_format 'user' 'shell' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -44,7 +43,7 @@ is_user_suspended shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" ) # Changing passwd file -/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1 +/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null @@ -56,6 +55,6 @@ shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" ) update_user_value "$user" '$SHELL' "$shell" # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_web_domain_ip b/bin/v_change_web_domain_ip index a2cc4d9b6..0163d9f70 100755 --- a/bin/v_change_web_domain_ip +++ b/bin/v_change_web_domain_ip @@ -17,11 +17,10 @@ domain_idn=$(idn -t --quiet -a "$domain") ip=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -32,16 +31,16 @@ source $V_FUNC/ip.func check_args '3' "$#" 'user domain ip' # Checking argument format -format_validation 'user' 'domain' 'ip' +validate_format 'user' 'domain' 'ip' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -59,30 +58,30 @@ is_ip_avalable # Define variable for replace get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" old=$IP new=$ip replace_web_config # Checking ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" replace_web_config fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" replace_web_config fi # Checking nginx if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" replace_web_config fi @@ -101,10 +100,10 @@ decrease_ip_value "$old" update_domain_value 'web' '$IP' "$new" # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ip" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $old_ip" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_web_domain_sslcert b/bin/v_change_web_domain_sslcert index c2f272a12..1cdb0db33 100755 --- a/bin/v_change_web_domain_sslcert +++ b/bin/v_change_web_domain_sslcert @@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain") ssl_dir=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -31,16 +30,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain ssl_dir' # Checking argument format -format_validation 'user' 'domain' 'ssl_dir' +validate_format 'user' 'domain' 'ssl_dir' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -60,26 +59,26 @@ is_web_domain_cert_valid #----------------------------------------------------------# # Deleting old certificate -tmpdir=$(mktemp -p $V_HOME/$user/web/$domain/private -d) -rm -f $V_HOME/$user/conf/ssl.$domain.* -mv $V_USERS/$user/ssl/$domain.* $tmpdir +tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) +rm -f $HOMEDIR/$user/conf/ssl.$domain.* +mv $USER_DATA/ssl/$domain.* $tmpdir chown -R $user:$user $tmpdir # Adding new certificate to user data directory -cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $V_USERS/$user/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.pem +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt +cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $V_USERS/$user/ssl/$domain.ca - cat $V_USERS/$user/ssl/$domain.ca >> $V_USERS/$user/ssl/$domain.pem + cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca + cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem fi # Adding new certificate to user dir -cp -f $V_USERS/$user/ssl/$domain.crt $V_HOME/$user/conf/ssl.$domain.crt -cp -f $V_USERS/$user/ssl/$domain.key $V_HOME/$user/conf/ssl.$domain.key -cp -f $V_USERS/$user/ssl/$domain.pem $V_HOME/$user/conf/ssl.$domain.pem -if [ -e "$V_USERS/$user/ssl/$domain.ca" ]; then - cp -f $V_USERS/$user/ssl/$domain.ca $V_HOME/$user/conf/ssl.$domain.ca +cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/ssl.$domain.crt +cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/ssl.$domain.key +cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca fi @@ -88,10 +87,10 @@ fi #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $tmpdir" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $tmpdir" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_web_domain_sslhome b/bin/v_change_web_domain_sslhome index 1d832d448..b5e4f7987 100755 --- a/bin/v_change_web_domain_sslhome +++ b/bin/v_change_web_domain_sslhome @@ -12,10 +12,9 @@ domain_idn=$(idn -t --quiet -a "$domain") ssl_home=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -26,16 +25,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain ssl_home' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -55,15 +54,15 @@ is_domain_value_exist 'web' '$SSL' get_domain_values 'web' old_ssl_home=$SSL_HOME SSL_HOME=$ssl_home -tpl_file="$V_WEBTPL/apache_$TPL.stpl" -conf="$V_HOME/$user/conf/shttpd.conf" +tpl_file="$WEBTPL/apache_$TPL.stpl" +conf="$HOMEDIR/$user/conf/shttpd.conf" # Parsing tpl_option case $SSL_HOME in - single) new="$V_HOME/$user/web/$domain/public_shtml" ; - old="$V_HOME/$user/web/$domain/public_html" ;; - same) new="$V_HOME/$user/web/$domain/public_html" ; - old="$V_HOME/$user/web/$domain/public_shtml" ;; + single) new="$HOMEDIR/$user/web/$domain/public_shtml" ; + old="$HOMEDIR/$user/web/$domain/public_html" ;; + same) new="$HOMEDIR/$user/web/$domain/public_html" ; + old="$HOMEDIR/$user/web/$domain/public_shtml" ;; *) check_args '3' "2" 'user domain sslhome' esac @@ -72,8 +71,8 @@ replace_web_config # Checking nginx config if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/snginx.conf" replace_web_config fi @@ -86,10 +85,10 @@ fi update_domain_value 'web' '$SSL_HOME' "$SSL_HOME" # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ssl_home" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$SCRIPT $user $domain $old_ssl_home" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_change_web_domain_tpl b/bin/v_change_web_domain_tpl index abd04ae84..6a5b20dec 100755 --- a/bin/v_change_web_domain_tpl +++ b/bin/v_change_web_domain_tpl @@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain") template=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -31,16 +30,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain template' # Checking argument format -format_validation 'user' 'domain' 'template' +validate_format 'user' 'domain' 'template' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -50,7 +49,7 @@ is_domain_suspended 'web' # Checking template templates=$(get_user_value '$WEB_TPL') -is_template_valid "web" +is_apache_template_valid #----------------------------------------------------------# @@ -61,15 +60,15 @@ is_template_valid "web" get_domain_values 'web' # Deleting domain -tpl_file="$V_WEBTPL/apache_$TPL.tpl" +tpl_file="$WEBTPL/apache_$TPL.tpl" old_tpl=$TPL -conf="$V_HOME/$user/conf/web/httpd.conf" +conf="$HOMEDIR/$user/conf/web/httpd.conf" del_web_config # Deleting ssl vhost if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config fi @@ -77,10 +76,10 @@ fi ip=$IP email="$user@$domain" group="$user" -docroot="$V_HOME/$user/web/$domain/public_html" +docroot="$HOMEDIR/$user/web/$domain/public_html" docroot_string="DocumentRoot $docroot" -conf="$V_HOME/$user/conf/web/httpd.conf" -tpl_file="$V_WEBTPL/apache_$template.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$template.tpl" # Parsing domain aliases @@ -124,7 +123,7 @@ IFS=$OLD_IFS # Parsing new template -template_data=$(cat $V_WEBTPL/apache_$template.descr | grep -v '#') +template_data=$(cat $WEBTPL/apache_$template.descr | grep -v '#') for keys in $template_data; do eval ${keys%%=*}=${keys#*=} done @@ -140,34 +139,34 @@ fi add_web_config # Running template trigger -if [ -x $V_WEBTPL/apache_$template.sh ]; then - $V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot fi # Checking ssl if [ "$SSL" = 'yes' ]; then # Defining SSL vars - ssl_crt="$V_HOME/$user/conf/web/ssl.$domain.crt" - ssl_key="$V_HOME/$user/conf/web/ssl.$domain.key" - ssl_pem="$V_HOME/$user/conf/web/ssl.$domain.pem" - ssl_ca="$V_HOME/$user/conf/web/ssl.$domain.ca" - if [ ! -e "$V_USERS/$user/web/ssl/$domain.ca" ]; then + ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt" + ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key" + ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem" + ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca" + if [ ! -e "$USER_DATA/web/ssl/$domain.ca" ]; then ssl_ca_str='#' fi case $SSL_HOME in - single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;; - same) docroot="$V_HOME/$user/web/$domain/public_html" ;; + single) docroot="$HOMEDIR/$user/web/$domain/public_shtml" ;; + same) docroot="$HOMEDIR/$user/web/$domain/public_html" ;; esac - conf="$V_HOME/$user/conf/web/shttpd.conf" - tpl_file="$V_WEBTPL/apache_$template.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$template.stpl" # Adding domain to the httpd.conf add_web_config # Running template trigger - if [ -x $V_WEBTPL/apache_$template.sh ]; then - $V_WEBTPL/apache_$template.sh \ - "$user" "$domain" "$ip" "$V_HOME" "$docroot" + if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh \ + "$user" "$domain" "$ip" "$HOMEDIR" "$docroot" fi fi @@ -180,17 +179,17 @@ fi update_domain_value 'web' '$TPL' "$template" # Updating db keys -for keys in $(cat $V_WEBTPL/apache_$template.descr|grep -v '#'); do +for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do key=$(echo "$keys"| cut -f 1 -d '=' |sed -e "s/^/\$/g") value=$(echo "$keys" |cut -f 2 -d \') update_domain_value 'web' "$key" "$value" done # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_change_web_domain_tpl $user $domain $old_tpl" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_change_web_domain_tpl $user $domain $old_tpl" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_cron_job b/bin/v_delete_cron_job index f867df9aa..79c4e7591 100755 --- a/bin/v_delete_cron_job +++ b/bin/v_delete_cron_job @@ -13,31 +13,22 @@ user=$1 job=$2 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '2' "$#" 'user job' - -# Checking argument format -format_validation 'user' 'job' - -# Checking user -is_user_valid - -# Checking user is active -is_user_suspended - -# Checking cron job -is_job_valid +validate_format 'user' 'job' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_suspended 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_suspended 'cron' 'JOB' "$job" #----------------------------------------------------------# @@ -45,7 +36,7 @@ is_job_valid #----------------------------------------------------------# # Deleting job -del_cron_job +sed -i "/JOB='$job' /d" $USER_DATA/cron.conf # Sorting jobs by id sort_cron_jobs @@ -61,10 +52,11 @@ sync_cron_jobs # Decreasing cron value decrease_user_value "$user" '$U_CRON_JOBS' -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_user_reports b/bin/v_delete_cron_reports similarity index 67% rename from bin/v_delete_user_reports rename to bin/v_delete_cron_reports index f01c4ffab..03b923679 100755 --- a/bin/v_delete_user_reports +++ b/bin/v_delete_cron_reports @@ -1,5 +1,5 @@ #!/bin/bash -# info: delete user reports +# info: delete cron reports # options: user # # The script for disabling reports on cron tasks and administrative @@ -13,28 +13,20 @@ # Argument defenition user=$1 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '1' "$#" 'user' - -# Checking argument format -format_validation 'user' - -# Checking user -is_user_valid - -# Checking user is active -is_user_suspended +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -42,7 +34,7 @@ is_user_suspended #----------------------------------------------------------# # Changing user report value -update_user_value "$user" '$REPORTS' 'no' +update_user_value "$user" '$CRON_REPORTS' 'no' # Sync system cron with user sync_cron_jobs @@ -52,11 +44,11 @@ sync_cron_jobs # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_history "$V_EVENT" "v_add_user_reports $user" -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_db_base b/bin/v_delete_db_base index b90ae80d7..3df8a40ad 100755 --- a/bin/v_delete_db_base +++ b/bin/v_delete_db_base @@ -15,10 +15,9 @@ user=$1 database=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -29,16 +28,16 @@ source $V_FUNC/db.func check_args '2' "$#" 'user db_name' # Checking argument format -format_validation 'user' 'database' +validate_format 'user' 'database' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking db existance is_db_valid @@ -77,6 +76,6 @@ decrease_user_value "$user" '$U_DATABASES' del_db_vesta # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_db_bases b/bin/v_delete_db_bases index 88227f109..d226d53c6 100755 --- a/bin/v_delete_db_bases +++ b/bin/v_delete_db_bases @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/db.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking web system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/db.conf" +conf="$USER_DATA/db.conf" # Defining fileds to select field='$DB' @@ -54,10 +53,10 @@ databases=$(db_clear_search) # Starting delete loop for database in $databases; do - $V_BIN/v_delete_db_base "$user" "$database" + $BIN/v_delete_db_base "$user" "$database" rv="$?" if [ "$rv" -ne '0' ]; then - log_event 'debug' "$rv $V_EVENT" + log_event 'debug' "$rv $EVENT" exit $rv fi done @@ -68,6 +67,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_db_host b/bin/v_delete_db_host index a294b6ae0..52a693ca1 100755 --- a/bin/v_delete_db_host +++ b/bin/v_delete_db_host @@ -15,10 +15,9 @@ type=$1 host=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -29,13 +28,13 @@ source $V_FUNC/db.func check_args '2' "$#" 'type host' # Checking argument format -format_validation 'host' +validate_format 'host' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking db type -is_type_valid 'db' "$type" +is_type_valid "$DB_SYSTEM" "$type" # Checking host existance is_db_host_valid @@ -57,6 +56,6 @@ del_dbhost_vesta #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_dns_domain b/bin/v_delete_dns_domain index 625595780..5eaea5b0c 100755 --- a/bin/v_delete_dns_domain +++ b/bin/v_delete_dns_domain @@ -16,10 +16,9 @@ domain=$(idn -t --quiet -u "$2" ) named_conf=/etc/named.conf # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -52,7 +51,7 @@ is_domain_valid 'dns' # Get domain values tpl_name=$(get_domain_value 'dns' '$TPL') old_ip=$(get_domain_value 'dns' '$IP') -records=$(wc -l $V_USERS/$user/dns/$domain|cut -f 1 -d ' ') +records=$(wc -l $USER_DATA/dns/$domain|cut -f 1 -d ' ') # Deleting domain in named.conf rm_string=$(grep -n /conf/dns/$domain.db $named_conf |cut -d : -f 1) @@ -60,8 +59,8 @@ if [ ! -z "$rm_string" ]; then sed -i "$rm_string d" $named_conf fi -if [ -e "$V_HOME/$user/conf/dns/$domain.db" ]; then - rm -f $V_HOME/$user/conf/dns/$domain.db +if [ -e "$HOMEDIR/$user/conf/dns/$domain.db" ]; then + rm -f $HOMEDIR/$user/conf/dns/$domain.db fi @@ -70,18 +69,18 @@ fi #----------------------------------------------------------# # Deleting domain -sed -i "/DOMAIN='$domain'/ d" $V_USERS/$user/dns.conf -rm -f $V_USERS/$user/dns/$domain +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf +rm -f $USER_DATA/dns/$domain # Decreasing domain value decrease_user_value "$user" '$U_DNS_DOMAINS' decrease_user_value "$user" '$U_DNS_RECORDS' "$records" # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_history "$V_EVENT" "v_add_dns_domain $user $domain $old_ip $tpl_name" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_dns_domain $user $domain $old_ip $tpl_name" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_dns_domain_record b/bin/v_delete_dns_domain_record index fe184358d..54b820945 100755 --- a/bin/v_delete_dns_domain_record +++ b/bin/v_delete_dns_domain_record @@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain") id=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,13 +29,13 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain id' # Checking argument format -format_validation 'user' 'domain' 'id' +validate_format 'user' 'domain' 'id' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -53,7 +52,7 @@ is_dns_record_valid #----------------------------------------------------------# # Deleting record -conf="$V_USERS/$user/dns/$domain" +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 @@ -63,7 +62,7 @@ fi sort_dns_records # Updating zone -conf="$V_HOME/$user/conf/dns/$domain.db" +conf="$HOMEDIR/$user/conf/dns/$domain.db" update_domain_zone @@ -72,9 +71,9 @@ update_domain_zone #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_dns_domains b/bin/v_delete_dns_domains index a04d3a7fe..544d6c2ac 100755 --- a/bin/v_delete_dns_domains +++ b/bin/v_delete_dns_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/dns.conf" +conf="$USER_DATA/dns.conf" # Defining fileds to select field='$DOMAIN' @@ -54,10 +53,10 @@ domains=$(dom_clear_search) # Starting delete loop for domain in $domains; do - $V_BIN/v_delete_dns_domain "$user" "$domain" + $BIN/v_delete_dns_domain "$user" "$domain" rv="$?" if [ "$rv" -ne '0' ]; then - log_event 'debug' "$rv $V_EVENT" + log_event 'debug' "$rv $EVENT" exit $rv fi done @@ -68,6 +67,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_mail_domain b/bin/v_delete_mail_domain index 4f388314c..9c7f3abb2 100755 --- a/bin/v_delete_mail_domain +++ b/bin/v_delete_mail_domain @@ -15,10 +15,9 @@ user=$1 domain=$(idn -t --quiet -u "$2" ) # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,16 +28,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'mail' @@ -50,11 +49,11 @@ is_domain_valid 'mail' # Get domain values get_domain_values 'mail' -accounts=$(wc -l $V_USERS/$user/mail/$domain|cut -f 1 -d ' ') +accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') rm -f /etc/exim/domains/$domain -rm -rf $V_HOME/$user/conf/$domain -rm -rf $V_HOME/$user/mail/$domain +rm -rf $HOMEDIR/$user/conf/$domain +rm -rf $HOMEDIR/$user/mail/$domain #----------------------------------------------------------# @@ -62,10 +61,10 @@ rm -rf $V_HOME/$user/mail/$domain #----------------------------------------------------------# # Delete domain config -sed -i "/DOMAIN='$domain'/ d" $V_USERS/$user/mail.conf -rm -f $V_USERS/$user/mail/$domain -rm -f $V_USERS/$user/mail/$domain.pem -rm -f $V_USERS/$user/mail/$domain.pub +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf +rm -f $USER_DATA/mail/$domain.conf +rm -f $USER_DATA/mail/$domain.pem +rm -f $USER_DATA/mail/$domain.pub # autoreply # Decreasing domain value @@ -74,7 +73,7 @@ decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts" # Logging cmd='"v_add_mail_domain' -log_history "$V_EVENT" "$cmd $user $domain $ANTISPAM $ANTIVIRUS $DKIM" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "$cmd $user $domain $ANTISPAM $ANTIVIRUS $DKIM" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_mail_domain_antispam b/bin/v_delete_mail_domain_antispam index 4250a32a5..0e63353bc 100755 --- a/bin/v_delete_mail_domain_antispam +++ b/bin/v_delete_mail_domain_antispam @@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -56,7 +55,7 @@ is_domain_value_exist 'mail' '$ANTISPAM' #----------------------------------------------------------# # Delete antispam key -sed -i "/antispam/d" $V_HOME/$user/conf/mail/$domain/protection +sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection #----------------------------------------------------------# @@ -67,7 +66,7 @@ sed -i "/antispam/d" $V_HOME/$user/conf/mail/$domain/protection update_domain_value 'mail' '$ANTISPAM' 'no' # Logging -log_history "$V_EVENT" "v_add_mail_domain_antispam $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_mail_domain_antispam $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_mail_domain_antivirus b/bin/v_delete_mail_domain_antivirus index dce1e840e..85c7c5506 100755 --- a/bin/v_delete_mail_domain_antivirus +++ b/bin/v_delete_mail_domain_antivirus @@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -56,7 +55,7 @@ is_domain_value_exist 'mail' '$ANTIVIRUS' #----------------------------------------------------------# # Delete antivirus key -sed -i "/antivirus/d" $V_HOME/$user/conf/mail/$domain/protection +sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection #----------------------------------------------------------# @@ -67,7 +66,7 @@ sed -i "/antivirus/d" $V_HOME/$user/conf/mail/$domain/protection update_domain_value 'mail' '$ANTIVIRUS' 'no' # Logging -log_history "$V_EVENT" "v_add_mail_domain_antivirus $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_mail_domain_antivirus $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_mail_domain_cactchall b/bin/v_delete_mail_domain_cactchall index 90611390b..2277d6016 100755 --- a/bin/v_delete_mail_domain_cactchall +++ b/bin/v_delete_mail_domain_cactchall @@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -59,7 +58,7 @@ is_domain_value_exist 'mail' '$CATCHALL' email=$(get_domain_value 'mail' '$CATCHALL') # Delete cathcall alias -sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases +sed -i "/*@demo.vestacp.com:/d" $HOMEDIR/$user/conf/mail/$domain/aliases #----------------------------------------------------------# @@ -70,7 +69,7 @@ sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases update_domain_value 'mail' '$CATCHALL' '' # Logging -log_history "$V_EVENT" "v_add_mail_domain_catchall $user $domain $email" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_mail_domain_catchall $user $domain $email" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_mail_domain_dkim b/bin/v_delete_mail_domain_dkim index d642bcaa5..49d1353c8 100755 --- a/bin/v_delete_mail_domain_dkim +++ b/bin/v_delete_mail_domain_dkim @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain=$(echo $domain | tr '[:upper:]' '[:lower:]') # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,16 +28,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -55,17 +54,17 @@ is_domain_value_exist 'mail' '$DKIM' #----------------------------------------------------------# # Generating dkim -rm -f $V_USERS/$user/mail/$domain.pem -rm -f $V_USERS/$user/mail/$domain.pub -rm -f $V_HOME/$user/conf/mail/$domain/dkim.pem +rm -f $USER_DATA/mail/$domain.pem +rm -f $USER_DATA/mail/$domain.pub +rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem # Checking dns domain check_dns_domain=$(is_domain_valid 'dns') if [ "$?" -eq 0 ]; then - records=$($V_BIN/v_list_dns_domain_records $user $domain plain) + records=$($BIN/v_list_dns_domain_records $user $domain plain) dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ') for id in $dkim_records; do - $V_BIN/v_delete_dns_domain_record $user $domain $id + $BIN/v_delete_dns_domain_record $user $domain $id done fi @@ -78,7 +77,7 @@ fi update_domain_value 'mail' '$DKIM' 'no' # Logging -log_history "$V_EVENT" "v_add_mail_domain_dkim $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_mail_domain_dkim $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_sys_ip b/bin/v_delete_sys_ip index 01ab38a45..5d4895ef1 100755 --- a/bin/v_delete_sys_ip +++ b/bin/v_delete_sys_ip @@ -14,11 +14,10 @@ ip=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/ip.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,7 +28,7 @@ source $V_FUNC/domain.func check_args '1' "$#" 'ip' # Checking argument format -format_validation 'ip' +validate_format 'ip' # Checking system ip is_sys_ip_valid "$ip" @@ -65,10 +64,10 @@ ip_status="$(get_sys_ip_value '$STATUS')" rm -f $iconf-$interface # Deleting vesta ip -rm -f $V_IPS/$ip +rm -f $VESTA/data/ips/$ip # Importing main config -source $V_CONF/vesta.conf +source $VESTA/conf/vesta.conf # Deleting namehosting support namehost_ip_disable @@ -99,10 +98,10 @@ fi # Adding task to the vesta pipe if [ "$web_restart" = 'yes' ]; then - restart_schedule 'web' + $BIN/v_restart_web fi # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_user b/bin/v_delete_user index e083e0617..11c0e5207 100755 --- a/bin/v_delete_user +++ b/bin/v_delete_user @@ -14,12 +14,11 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/db.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -30,13 +29,13 @@ source $V_FUNC/ip.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking user admin if [ "$user" = 'admin' ]; then @@ -49,8 +48,8 @@ fi # Checking web system is enabled if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_web_domains $user - $V_BIN/v_delete_web_domains $user + $BIN/v_unsuspend_web_domains $user + $BIN/v_delete_web_domains $user rv="$?" if [ "$rv" -ne '0' ]; then exit $rv @@ -59,8 +58,8 @@ fi # Checking dns system is enabled if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_dns_domains $user - $V_BIN/v_delete_dns_domains $user + $BIN/v_unsuspend_dns_domains $user + $BIN/v_delete_dns_domains $user rv="$?" if [ "$rv" -ne '0' ]; then exit $rv @@ -69,8 +68,8 @@ fi # Checking mail system is enabled if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_mail_domains $user - $V_BIN/v_del_mail_domains $user + $BIN/v_unsuspend_mail_domains $user + $BIN/v_del_mail_domains $user rv="$?" if [ "$rv" -ne '0' ]; then exit $rv @@ -79,8 +78,8 @@ fi # Checking db system is enabled if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_db_bases $user - $V_BIN/v_delete_db_dbases $user + $BIN/v_unsuspend_db_bases $user + $BIN/v_delete_db_dbases $user rv="$?" if [ "$rv" -ne '0' ]; then exit $rv @@ -88,41 +87,23 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then fi # Checking ip -$V_BIN/v_delete_user_ips "$user" +$BIN/v_delete_user_ips "$user" rv="$?" if [ "$rv" -ne '0' ]; then exit $rv fi # Deleteing user pipes -diskp=$(grep -n " $user$" $V_QUEUE/disk.pipe|cut -d : -f 1|sort -n -r) -trafp=$(grep -n " $user$" $V_QUEUE/traffic.pipe|cut -d : -f 1|sort -n -r) -statp=$(grep -n "/$user/" $V_QUEUE/stats.pipe|cut -d : -f 1|sort -n -r) - -if [ ! -z "$diskp" ]; then - for str in $diskp; do - sed -i "$str d" $V_QUEUE/disk.pipe - done -fi - -if [ ! -z "$trafp" ]; then - for str in $trafp; do - sed -i "$str d" $V_QUEUE/traffic.pipe - done -fi - -if [ ! -z "$statp" ]; then - for str in $statp; do - sed -i "$str d" $V_QUEUE/stats.pipe - done -fi +sed -i "/v_update_db_bases_disk $user$/d" $VESTA/data/queue/disk.pipe +sed -i "/v_update_web_domains_traff $user$/d" $VESTA/data/queue/traffic.pipe +sed -i "/v_update_web_domain_stat $user /d" $VESTA/data/queue/stats.pipe # Removing system user /usr/sbin/userdel -f $user -rm -rf $V_HOME/$user +rm -rf $HOMEDIR/$user rm -f /var/spool/mail/$user rm -f /var/spool/cron/$user -rm -rf $V_USERS/$user +rm -rf $USER_DATA # Updating admin counter if [ "$user" != 'admin' ]; then @@ -135,6 +116,6 @@ fi #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_user_ips b/bin/v_delete_user_ips index 755eee018..86a6563e8 100755 --- a/bin/v_delete_user_ips +++ b/bin/v_delete_user_ips @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/ip.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking user vesta if [ "$user" = 'admin' ]; then @@ -45,7 +44,7 @@ fi #----------------------------------------------------------# # Parsing user ips -ip_list=$(grep -H "OWNER='$user'" $V_IPS/* | cut -f 1 -d:) +ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:) for ip in $ip_list; do ip=$(basename $ip) @@ -56,7 +55,7 @@ for ip in $ip_list; do # Assig ip to main account update_sys_ip_value '$OWNER' 'admin' - update_sys_ip_value '$STATUS' 'exclusive' + update_sys_ip_value '$STATUS' 'dedicated' increase_user_value 'admin' '$IP_OWNED' increase_user_value 'admin' '$IP_AVAIL' done @@ -67,6 +66,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain b/bin/v_delete_web_domain index 4f49dd255..ba32675c3 100755 --- a/bin/v_delete_web_domain +++ b/bin/v_delete_web_domain @@ -18,11 +18,10 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -33,16 +32,16 @@ source $V_FUNC/ip.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -57,8 +56,8 @@ is_domain_suspended 'web' # Get template name get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" # Deleting domain del_web_config @@ -72,25 +71,25 @@ fi # Checking ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config # Deleting certificates - rm -f $V_HOME/$user/conf/web/ssl.$domain.* - rm -f $V_USERS/$user/ssl/$domain.* + rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* + rm -f $USER_DATA/ssl/$domain.* fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" del_web_config if [ "$SSL" = 'yes' ]; then proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config fi fi @@ -98,11 +97,11 @@ fi # Checking stats if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then sed -i "/ $domain$/d" $V_QUEUE/stats.pipe - rm -f $V_HOME/$user/conf/web/$STATS.$domain.conf + rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf fi # Deleting directory -rm -rf $V_HOME/$user/web/$domain +rm -rf $HOMEDIR/$user/web/$domain # Deleting logs rm -f /var/log/httpd/domains/$domain.log* @@ -115,19 +114,19 @@ rm -f /var/log/httpd/domains/$domain.error* #----------------------------------------------------------# # Deleting domain -sed -i "/DOMAIN='$domain'/ d" $V_USERS/$user/web.conf +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf # Checking last ssl domain -ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web.conf | wc -l) +ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l) if [ "$ssl_dom" -eq '0' ]; then - sed -i "s/ Include /#Include /" $V_HOME/$user/conf/web/httpd.conf + sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf fi # Checking last domain -domains=$(wc -l $V_USERS/$user/web.conf|cut -f 1 -d ' ') +domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ') if [ "$domains" -eq '0' ]; then conf='/etc/httpd/conf.d/vesta.conf' - line=$(grep -n "$V_HOME/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : ) + line=$(grep -n "$HOMEDIR/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : ) if [ ! -z "$line" ]; then sed -i "$line d" $conf fi @@ -135,22 +134,22 @@ fi # Checking last nginx domain conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf) +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") if [ -z "$last_snginx" ]; then - sline=$(grep -n "$V_HOME/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :) + sline=$(grep -n "$HOMEDIR/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :) if [ ! -z "$sline" ]; then sed -i "$sline d" $conf fi - rm -f $V_HOME/$user/conf/web/snginx.conf + rm -f $HOMEDIR/$user/conf/web/snginx.conf fi if [ -z "$last_nginx" ]; then - line=$(grep -n "$V_HOME/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : ) + line=$(grep -n "$HOMEDIR/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : ) if [ ! -z "$line" ]; then sed -i "$line d" $conf fi - rm -f $V_HOME/$user/conf/web/nginx.conf + rm -f $HOMEDIR/$user/conf/web/nginx.conf fi # Decreasing ip value @@ -168,10 +167,10 @@ if [ "$SSL" = 'yes' ]; then fi # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain_alias b/bin/v_delete_web_domain_alias index 42a328cf7..f161405ea 100755 --- a/bin/v_delete_web_domain_alias +++ b/bin/v_delete_web_domain_alias @@ -1,6 +1,6 @@ #!/bin/bash # info: delete web domain alias -# options user domain alias +# options: user domain alias # # The function of deleting the alias domain (parked domain). By this call # default www aliase can be removed as well. @@ -18,10 +18,9 @@ dom_alias=$(idn -t --quiet -u "$3" ) dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -32,16 +31,16 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain dom_alias' # Checking argument format -format_validation 'user' 'domain' 'dom_alias' +validate_format 'user' 'domain' 'dom_alias' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -54,7 +53,7 @@ get_domain_values 'web' check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias") if [ -z "$check_alias" ]; then echo "Error: alias not exist" - log_event 'debug' "$E_NOTEXIST $V_EVENT" + log_event 'debug' "$E_NOTEXIST $EVENT" exit $E_NOTEXIST fi @@ -68,8 +67,8 @@ ALIAS=$(echo "$ALIAS" |\ sed -e "s/^$dom_alias$//g"|\ sed -e "/^$/d"|\ sed -e ':a;N;$!ba;s/\n/,/g') -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" # Preparing domain values for the template substitution upd_web_domain_values @@ -79,23 +78,23 @@ del_web_config add_web_config if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" del_web_config add_web_config if [ "$SSL" = 'yes' ]; then proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config add_web_config fi @@ -113,10 +112,10 @@ update_domain_value 'web' '$ALIAS' "$ALIAS" decrease_user_value "$user" '$U_WEB_ALIASES' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_add_web_domain_alias $user $domain $dom_alias" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_web_domain_alias $user $domain $dom_alias" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain_cgi b/bin/v_delete_web_domain_cgi index cc0ad024f..38d66532b 100755 --- a/bin/v_delete_web_domain_cgi +++ b/bin/v_delete_web_domain_cgi @@ -18,10 +18,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -32,16 +31,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -58,8 +57,8 @@ is_domain_value_exist 'web' '$CGI' #----------------------------------------------------------# get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" CGI='no' # Preparing domain values for the template substitution @@ -71,8 +70,8 @@ add_web_config # Checking ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi @@ -86,10 +85,10 @@ fi update_domain_value 'web' '$CGI' 'no' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_add_web_domain_cgi $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_web_domain_cgi $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain_elog b/bin/v_delete_web_domain_elog index 13acef301..f3666f080 100755 --- a/bin/v_delete_web_domain_elog +++ b/bin/v_delete_web_domain_elog @@ -17,10 +17,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -31,16 +30,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid "$user" +is_object_valid 'user' 'USER' "$user" "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -58,8 +57,8 @@ is_domain_value_exist 'web' '$ELOG' # Parsing domain values get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" ELOG='no' # Preparing domain values for the template substitution @@ -71,23 +70,23 @@ add_web_config # Checking ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" del_web_config add_web_config if [ "$SSL" = 'yes' ]; then proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config add_web_config fi @@ -102,10 +101,10 @@ fi update_domain_value 'web' '$ELOG' 'no' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_add_web_domain_elog $user $domain" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_web_domain_elog $user $domain" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain_nginx b/bin/v_delete_web_domain_nginx index 87b16e440..4a311dc83 100755 --- a/bin/v_delete_web_domain_nginx +++ b/bin/v_delete_web_domain_nginx @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,16 +28,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -56,14 +55,14 @@ is_domain_value_exist 'web' '$NGINX' # Defining domain parameters get_domain_values 'web' -tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" -conf="$V_HOME/$user/conf/nginx.conf" +tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/nginx.conf" del_web_config # Checking ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/snginx.conf" del_web_config fi @@ -78,23 +77,23 @@ update_domain_value 'web' '$NGINX_EXT' '' # Checking last nginx domain conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf) +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") if [ -z "$last_snginx" ]; then sed -i "/$user\/conf\/web\/snginx.conf/d" $conf - rm -f $V_HOME/$user/conf/web/snginx.conf + rm -f $HOMEDIR/$user/conf/web/snginx.conf fi if [ -z "$last_nginx" ]; then sed -i "/$user\/conf\/web\/nginx.conf/d" $conf - rm -f $V_HOME/$user/conf/web/nginx.conf + rm -f $HOMEDIR/$user/conf/web/nginx.conf fi # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_add_web_domain_nginx $user $domain $NGINX $NGINX_EXT" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_web_domain_nginx $user $domain $NGINX $NGINX_EXT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain_ssl b/bin/v_delete_web_domain_ssl index befd41240..ef1f68dbc 100755 --- a/bin/v_delete_web_domain_ssl +++ b/bin/v_delete_web_domain_ssl @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,16 +28,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -56,23 +55,23 @@ is_domain_value_exist 'web' '$SSL' # Parsing domain values get_domain_values 'web' -conf="$V_HOME/$user/conf/web/shttpd.conf" -tpl_file="$V_WEBTPL/apache_$TPL.stpl" +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +tpl_file="$WEBTPL/apache_$TPL.stpl" # Deleting domain del_web_config # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config fi # Deleting old certificate -tmpdir=$(mktemp -p $V_HOME/$user/web/$domain/private -d) -rm -f $V_HOME/$user/conf/ssl.$domain.* -mv $V_USERS/$user/ssl/$domain.* $tmpdir +tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) +rm -f $HOMEDIR/$user/conf/ssl.$domain.* +mv $USER_DATA/ssl/$domain.* $tmpdir chown -R $user:$user $tmpdir @@ -84,9 +83,9 @@ chown -R $user:$user $tmpdir update_domain_value 'web' '$SSL' 'no' # Checking last ssl domain -ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web.conf) +ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf) main_conf='/etc/httpd/conf.d/vesta.conf' -conf="$V_HOME/$user/conf/shttpd.conf" +conf="$HOMEDIR/$user/conf/shttpd.conf" if [ -z "$ssl_dom" ]; then sed -i "/Include ${conf////\/}/d" $main_conf rm -f $conf @@ -94,22 +93,22 @@ fi # Checking last nginx domain conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf) +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") if [ -z "$last_snginx" ]; then if [ -z "$last_nginx" ]; then sed -i "/$user\/conf\/snginx.conf/d" $conf - rm -f $V_HOME/$user/conf/snginx.conf + rm -f $HOMEDIR/$user/conf/snginx.conf fi # Decreasing domain value decrease_user_value "$user" '$U_WEB_SSL' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_history "$V_EVENT" "v_add_web_domain_ssl $user $domain $tmpdir $SSL_HOME" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_web_domain_ssl $user $domain $tmpdir $SSL_HOME" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain_stat b/bin/v_delete_web_domain_stat index ab5b3c9e0..95c2c4d7b 100755 --- a/bin/v_delete_web_domain_stat +++ b/bin/v_delete_web_domain_stat @@ -15,10 +15,9 @@ user=$1 domain=$(idn -t --quiet -u "$2" ) # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,16 +28,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -58,13 +57,13 @@ is_domain_value_exist 'web' '$STATS' type=$(get_domain_value 'web' '$STATS') # Defining statistic dir -stat_dir="$V_HOME/$user/web/$domain/stats" +stat_dir="$HOMEDIR/$user/web/$domain/stats" # Deleting dir content rm -rf $stat_dir/* # Deleting config -rm -f $V_HOME/$user/conf/$type.$domain.conf +rm -f $HOMEDIR/$user/conf/$type.$domain.conf #----------------------------------------------------------# @@ -78,7 +77,7 @@ sed -i "/ $domain$/d" $V_QUEUE/stats.pipe update_domain_value 'web' '$STATS' '' # Logging -log_history "$V_EVENT" "v_add_web_domain_stat $user $doman $type" -log_event 'system' "$V_EVENT" +log_history "$EVENT" "v_add_web_domain_stat $user $doman $type" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domain_stat_auth b/bin/v_delete_web_domain_stat_auth index db0066f83..6f3bb1e5c 100755 --- a/bin/v_delete_web_domain_stat_auth +++ b/bin/v_delete_web_domain_stat_auth @@ -18,10 +18,9 @@ domain=$(idn -t --quiet -u "$2" ) auth_user=$3 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -32,16 +31,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain [auth_user]' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -58,12 +57,12 @@ is_domain_value_exist 'web' '$STATS_AUTH' #----------------------------------------------------------# # Definining statistic dir -stat_dir="$V_HOME/$user/web/$domain/stats" +stat_dir="$HOMEDIR/$user/web/$domain/stats" # Checking auth_user if [ ! -z "$auth_user" ]; then - format_validation 'auth_user' - htpasswd -D $stat_dir/.htpasswd "$auth_user" >/dev/null 2>&1 + validate_format 'auth_user' + htpasswd -D $stat_dir/.htpasswd "$auth_user" &>/dev/null fi # Checking htpasswd current users @@ -104,7 +103,7 @@ fi update_domain_value 'web' '$STATS_AUTH' "$new_val" # Logging -log_history "$V_EVENT" -log_event 'system' "$V_EVENT" +log_history "$EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_delete_web_domains b/bin/v_delete_web_domains index 7b228ddb5..6c029e9f0 100755 --- a/bin/v_delete_web_domains +++ b/bin/v_delete_web_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/web.conf" +conf="$USER_DATA/web.conf" # Defining fileds to select field='$DOMAIN' @@ -54,10 +53,10 @@ domains=$(dom_clear_search) # Starting delete loop for domain in $domains; do - $V_BIN/v_delete_web_domain "$user" "$domain" + $BIN/v_delete_web_domain "$user" "$domain" rv="$?" if [ "$rv" -ne '0' ]; then - log_event 'debug' "$rv $V_EVENT" + log_event 'debug' "$rv $EVENT" exit $rv fi done @@ -68,6 +67,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_get_dns_domain_value b/bin/v_get_dns_domain_value index 0f6a76b39..89843f953 100755 --- a/bin/v_get_dns_domain_value +++ b/bin/v_get_dns_domain_value @@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain") key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,10 +29,10 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain key' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -58,6 +57,6 @@ echo "$value" #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_get_user_value b/bin/v_get_user_value index 8bc3e5925..628b6acd2 100755 --- a/bin/v_get_user_value +++ b/bin/v_get_user_value @@ -14,9 +14,8 @@ user=$1 key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/shared.func check_args '2' "$#" 'user key' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain is not suspened -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -52,6 +51,6 @@ echo "$value" #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_get_web_domain_value b/bin/v_get_web_domain_value index b1fd25339..2065fe82a 100755 --- a/bin/v_get_web_domain_value +++ b/bin/v_get_web_domain_value @@ -18,10 +18,9 @@ domain_idn=$(idn -t --quiet -a "$domain") key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -32,13 +31,13 @@ source $V_FUNC/domain.func check_args '3' "$#" 'user domain key' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' diff --git a/bin/v_list_cron_jobs b/bin/v_list_cron_jobs index 47dc6f75c..e34fdcbba 100755 --- a/bin/v_list_cron_jobs +++ b/bin/v_list_cron_jobs @@ -13,27 +13,15 @@ user=$1 format=${2-shell} -# Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +# Includes +source $VESTA/func/shared.sh -# Json function +# Json list function json_list_cron() { - # 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 +30,10 @@ json_list_cron() { 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,34 +44,23 @@ json_list_cron() { 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 function shell_list_cron() { - 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 - # Assing key=value pair eval $line - - # Print result eval echo "$fields" | sed -e "s/%quote%/'/g" done < $conf } @@ -96,14 +70,9 @@ shell_list_cron() { # Verifications # #----------------------------------------------------------# -# Checking args check_args '1' "$#" 'user [format]' - -# Checking argument format -format_validation 'user' - -# Checking user -is_user_valid +validate_format 'user' +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -111,19 +80,20 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/cron.conf +conf=$USER_DATA/cron.conf # Defining fileds to select -fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPENDED $DATE' +fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPENDED $TIME $DATE' # Listing domains case $format in json) json_list_cron ;; plain) nohead=1; fields="\"\$JOB\" \"\$SUSPENDED\" \"\$MIN\" \"\$HOUR\" \"\$DAY\"" - fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\""; + fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\" "; + fields="$fields \"\$TIME\" \"\$DATE\"" shell_list_cron ;; - shell) fields='$JOB~$SUSPEND~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD'; + shell) fields='$JOB~$SUSPENDED~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD'; shell_list_cron |column -t -s '~';; *) check_args '1' '0' 'user [format]' ;; esac diff --git a/bin/v_list_db_base b/bin/v_list_db_base index 330d63928..d8d303bd0 100755 --- a/bin/v_list_db_base +++ b/bin/v_list_db_base @@ -15,9 +15,8 @@ database=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/func/shared.sh +source $VESTA/func/db.sh # Json function json_list_db() { @@ -90,10 +89,10 @@ shell_list_db() { check_args '2' "$#" 'user db_name [format]' # Checking argument format -format_validation 'user' 'database' +validate_format 'user' 'database' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking database exist is_db_valid @@ -104,7 +103,7 @@ is_db_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/db.conf +conf=$USER_DATA/db.conf # Defining fileds to select fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $DATE' diff --git a/bin/v_list_db_bases b/bin/v_list_db_bases index f0b1fd515..3944da4ce 100755 --- a/bin/v_list_db_bases +++ b/bin/v_list_db_bases @@ -14,8 +14,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,10 +25,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -37,7 +36,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/db.conf +conf=$USER_DATA/db.conf # Defining fileds to select fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $DATE' diff --git a/bin/v_list_db_host b/bin/v_list_db_host index 7b4ab032c..50bb08b2e 100755 --- a/bin/v_list_db_host +++ b/bin/v_list_db_host @@ -15,9 +15,8 @@ host=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/func/shared.sh +source $VESTA/func/db.sh # Json function json_list_dbhost() { @@ -88,10 +87,10 @@ shell_list_dbhost() { check_args '2' "$#" 'type host [format]' # Checking argument format -format_validation 'host' +validate_format 'host' # Checking db type -is_type_valid 'db' "$type" +is_type_valid "$DB_SYSTEM" "$type" # Checking db host is_db_host_valid @@ -102,7 +101,7 @@ is_db_host_valid #----------------------------------------------------------# # Defining config type -conf=$V_DB/$type.conf +conf=$VESTA/conf/$type.conf # Defining fileds to select fields='$HOST $PORT $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE' diff --git a/bin/v_list_db_hosts b/bin/v_list_db_hosts index f7c271a84..67d9d3761 100755 --- a/bin/v_list_db_hosts +++ b/bin/v_list_db_hosts @@ -14,8 +14,7 @@ type=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -23,13 +22,10 @@ source $V_FUNC/shared.func #----------------------------------------------------------# # Checking args -check_args '1' "$#" 'type [format] [limit] [offset]' - -# Checking argument format -format_validation 'limit' 'offset' +check_args '1' "$#" 'type [format]' # Checking db type -is_type_valid 'db' "$type" +is_type_valid "$DB_SYSTEM" "$type" #----------------------------------------------------------# @@ -37,7 +33,7 @@ is_type_valid 'db' "$type" #----------------------------------------------------------# # Defining config type -conf=$V_DB/$type.conf +conf=$VESTA/conf/$type.conf # Defining fileds to select fields='$HOST $PORT $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE' diff --git a/bin/v_list_dns_domain b/bin/v_list_dns_domain index 01f6ef545..ad640268e 100755 --- a/bin/v_list_dns_domain +++ b/bin/v_list_dns_domain @@ -16,9 +16,7 @@ domain=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/func/shared.sh # Json function json_list_domain() { @@ -82,7 +80,7 @@ shell_list_domain() { check_args '2' "$#" 'user domain [format]' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -93,7 +91,7 @@ is_domain_valid 'dns' #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/dns.conf +conf=$USER_DATA/dns.conf # Defining fileds to select fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $DATE' diff --git a/bin/v_list_dns_domain_records b/bin/v_list_dns_domain_records index 73ff1557a..130b747f9 100755 --- a/bin/v_list_dns_domain_records +++ b/bin/v_list_dns_domain_records @@ -15,9 +15,7 @@ domain=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/func/shared.sh # Json func json_list_dns() { @@ -104,10 +102,10 @@ shell_list_dns() { check_args '2' "$#" 'user domain [format]' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -118,7 +116,7 @@ is_domain_valid 'dns' #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/dns/$domain +conf=$USER_DATA/dns/$domain # Defining fileds to select fields='$ID $RECORD $TYPE $VALUE $SUSPENDED $DATE' diff --git a/bin/v_list_dns_domains b/bin/v_list_dns_domains index 86715364a..8248a8a18 100755 --- a/bin/v_list_dns_domains +++ b/bin/v_list_dns_domains @@ -14,8 +14,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,10 +25,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -37,7 +36,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/dns.conf +conf=$USER_DATA/dns.conf # Defining fileds to select fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $DATE' diff --git a/bin/v_list_dns_template b/bin/v_list_dns_template index d0961dff3..4aab92b6f 100755 --- a/bin/v_list_dns_template +++ b/bin/v_list_dns_template @@ -14,9 +14,8 @@ template=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,10 +26,10 @@ source $V_FUNC/domain.func check_args '1' "$#" 'template [format]' # Checking argument format -format_validation 'template' +validate_format 'template' # Checking template -is_template_valid 'dns' +is_dns_template_valid # Json func json_list_dns() { @@ -112,7 +111,7 @@ shell_list_dns() { #----------------------------------------------------------# # Defining config -conf=$V_DNSTPL/$template.tpl +conf=$DNSTPL/$template.tpl # Defining fileds to select fields='$RECORD $TYPE $VALUE' diff --git a/bin/v_list_dns_templates b/bin/v_list_dns_templates index 5b55d10c8..c3767033b 100755 --- a/bin/v_list_dns_templates +++ b/bin/v_list_dns_templates @@ -13,8 +13,7 @@ format=${1-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_dnstpl() { @@ -22,13 +21,13 @@ json_list_dnstpl() { echo '{' # Count fields - for template in $(ls $V_DNSTPL/| grep '.descr'); do + 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 $V_DNSTPL/$template |grep '#'|tr -d '\n') + 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//# /}\"" @@ -47,9 +46,9 @@ json_list_dnstpl() { # Shell function shell_list_dnstpl() { - for template in $(ls $V_DNSTPL/| grep '.descr'); do + for template in $(ls $DNSTPL/| grep '.descr'); do tpl_name="${template//.descr/}" - tpl_descr=$(cat $V_DNSTPL/$template |grep '#') + tpl_descr=$(cat $DNSTPL/$template |grep '#') # Print result if [ -z "$nohead" ] ; then diff --git a/bin/v_list_mail_accounts b/bin/v_list_mail_accounts new file mode 100755 index 000000000..104f2a7fb --- /dev/null +++ b/bin/v_list_mail_accounts @@ -0,0 +1,62 @@ +#!/bin/bash +# info: list mail domain accounts +# options: user domain [format] +# +# The function of obtaining the list of all user domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Importing variables +source $VESTA/func/shared.sh + + +#----------------------------------------------------------# +# 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 +is_domain_valid 'mail' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/mail/$domain.conf + +# Defining fileds to select +fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$U_DISK \$SUSPENDED \$DATE" + +# Listing domain accounts +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$ACCOUNT $ALIAS $FWD $AUTOREPLY $U_DISK $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'user [format]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v_list_mail_domain b/bin/v_list_mail_domain index d755e1cec..c17a5d94f 100755 --- a/bin/v_list_mail_domain +++ b/bin/v_list_mail_domain @@ -16,9 +16,7 @@ domain=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/func/shared.sh # Json function json_list_domain() { @@ -82,7 +80,7 @@ shell_list_domain() { check_args '2' "$#" 'user domain [format]' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'mail' @@ -93,7 +91,7 @@ is_domain_valid 'mail' #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/mail.conf +conf=$USER_DATA/mail.conf # Defining fileds to select fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL diff --git a/bin/v_list_mail_domain_dkim b/bin/v_list_mail_domain_dkim index dda58ff69..31c928868 100755 --- a/bin/v_list_mail_domain_dkim +++ b/bin/v_list_mail_domain_dkim @@ -15,9 +15,7 @@ domain=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/func/shared.sh # Json function json_list_ssl() { @@ -47,7 +45,7 @@ shell_list_ssl() { check_args '2' "$#" 'user domain [format]' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'mail' @@ -56,12 +54,12 @@ is_domain_valid 'mail' #----------------------------------------------------------# # Action # #----------------------------------------------------------# -if [ -e "$V_USERS/$user/mail/$domain.pem" ]; then - pem=$(cat $V_USERS/$user/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g') +if [ -e "$USER_DATA/mail/$domain.pem" ]; then + pem=$(cat $USER_DATA/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g') fi -if [ -e "$V_USERS/$user/mail/$domain.pub" ]; then - pub=$(cat $V_USERS/$user/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g') +if [ -e "$USER_DATA/mail/$domain.pub" ]; then + pub=$(cat $USER_DATA/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g') fi # Listing domains diff --git a/bin/v_list_mail_domains b/bin/v_list_mail_domains index 5bdd3238f..5d948daa3 100755 --- a/bin/v_list_mail_domains +++ b/bin/v_list_mail_domains @@ -1,6 +1,6 @@ #!/bin/bash # info: list mail domains -# options user [format] +# options: user [format] # # The function of obtaining the list of all user domains. @@ -14,8 +14,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,10 +25,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -37,7 +36,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/mail.conf +conf=$USER_DATA/mail.conf # Defining fileds to select fields="\$DOMAIN \$ANTIVIRUS \$ANTISPAM \$DKIM \$ACCOUNTS \$U_DISK \$CATCHALL" diff --git a/bin/v_list_sys_config b/bin/v_list_sys_config index caad29c4f..47df57ab2 100755 --- a/bin/v_list_sys_config +++ b/bin/v_list_sys_config @@ -12,16 +12,13 @@ # Argument defenition format=${1-shell} -# Importing variables -source $VESTA/conf/vars.conf - # Json function json_list_conf() { - lines=$(wc -l $V_CONF/vesta.conf | cut -f 1 -d ' ') + lines=$(wc -l $VESTA/conf/vesta.conf | cut -f 1 -d ' ') i='0' IFS=$'\n' echo -e "{\n\t\"config\": {" - for str in $(cat $V_CONF/vesta.conf); do + for str in $(cat $VESTA/conf/vesta.conf); do (( ++i)) key=${str%%=*} value=${str#*=} @@ -37,7 +34,7 @@ json_list_conf() { # Shell function shell_list_conf() { IFS=$'\n' - for str in $(cat $V_CONF/vesta.conf); do + for str in $(cat $VESTA/conf/vesta.conf); do key=${str%%=*} value=${str#*=} echo "$key: ${value//\'/}" diff --git a/bin/v_list_sys_interfaces b/bin/v_list_sys_interfaces index f35fb0809..c2ec908e3 100755 --- a/bin/v_list_sys_interfaces +++ b/bin/v_list_sys_interfaces @@ -13,8 +13,7 @@ format=${1-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_iface() { diff --git a/bin/v_list_sys_ip b/bin/v_list_sys_ip index 98744c1f6..e9c274043 100755 --- a/bin/v_list_sys_ip +++ b/bin/v_list_sys_ip @@ -15,15 +15,14 @@ IP=$ip format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/ip.func +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh # Json function json_list_ip() { i=1 fileds_count=$(echo "$fields" | wc -w) - ip_data=$(cat $V_IPS/$IP) + ip_data=$(cat $VESTA/data/ips/$IP) # Print top bracket echo '{' @@ -58,7 +57,7 @@ json_list_ip() { # Shell function shell_list_ip() { - line=$(cat $V_IPS/$IP) + line=$(cat $VESTA/data/ips/$IP) # Assing key=value eval $line @@ -79,7 +78,7 @@ shell_list_ip() { check_args '1' "$#" 'ip [format]' # Checking argument format -format_validation 'ip' +validate_format 'ip' # Checking ip is_sys_ip_valid @@ -87,7 +86,7 @@ is_sys_ip_valid #----------------------------------------------------------# # Action # #----------------------------------------------------------# -conf=$V_IPS/$IP +conf=$VESTA/data/ips/$IP # Defining fileds to select fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS diff --git a/bin/v_list_sys_ips b/bin/v_list_sys_ips index c381da534..2d78b8d18 100755 --- a/bin/v_list_sys_ips +++ b/bin/v_list_sys_ips @@ -13,8 +13,7 @@ format=${1-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_ips() { @@ -22,14 +21,14 @@ json_list_ips() { echo '{' # Definining ip list - ip_list=$(ls $V_IPS/) + ip_list=$(ls $VESTA/data/ips/) fileds_count=$(echo "$fields" | wc -w) # Starting main loop for IP in $ip_list; do # Assing key=value - ip_data=$(cat $V_IPS/$IP) + ip_data=$(cat $VESTA/data/ips/$IP) eval $ip_data # Closing bracket if there already was output @@ -68,7 +67,7 @@ json_list_ips() { # Shell function shell_list_ips() { - ip_list=$(ls $V_IPS/) + ip_list=$(ls $VESTA/data/ips/) if [ -z "$nohead" ]; then # Print brief info @@ -82,7 +81,7 @@ shell_list_ips() { # Starting main loop for IP in $ip_list; do # Reading user data - ip_data=$(cat $V_IPS/$IP) + ip_data=$(cat $VESTA/data/ips/$IP) # Assign key/value config eval $ip_data @@ -96,7 +95,7 @@ shell_list_ips() { #----------------------------------------------------------# # Action # #----------------------------------------------------------# -conf=$V_IPS/* +conf=$VESTA/data/ips/* # Defining fileds to select fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS" diff --git a/bin/v_list_sys_rrd b/bin/v_list_sys_rrd index 433230da4..91486141a 100755 --- a/bin/v_list_sys_rrd +++ b/bin/v_list_sys_rrd @@ -10,17 +10,15 @@ #----------------------------------------------------------# format=${1-shell} - -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf +source $VESTA/conf/vesta.conf +RRD=$VESTA/web/rrd # Define json function json_list_rrd() { i=1 echo "{" for type in $rrd_types; do - for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do + for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do if [ "$i" -ne 1 ]; then echo -e "\t}," fi @@ -73,8 +71,8 @@ shell_list_rrd() { fi for type in $rrd_types; do - for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - echo "$V_RRD/$type/$rrd.rrd" + for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do + echo "$RRD/$type/$rrd.rrd" done done } diff --git a/bin/v_list_user b/bin/v_list_user index bc4ad6e1a..a22a32351 100755 --- a/bin/v_list_user +++ b/bin/v_list_user @@ -15,8 +15,7 @@ USER="$user" format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_user() { @@ -73,10 +72,10 @@ shell_list_user() { check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -84,18 +83,18 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/user.conf +conf=$USER_DATA/user.conf # Defining fileds to select fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_ALIASES $WEB_TPL $DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES - $CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT $REPORTS - $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB $SUSPENDED_DNS - $SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL $IP_OWNED $U_USERS - $U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB $U_BANDWIDTH - $U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS $U_DNS_RECORDS - $U_MAIL_DOMAINS $U_MAIL_ACCOUNTS $U_DATABASES $U_CRON_JOBS $U_BACKUPS - $DATE' + $CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT + $CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB + $SUSPENDED_DNS $SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL + $IP_OWNED $U_USERS $U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB + $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS + $U_DNS_RECORDS $U_MAIL_DOMAINS $U_MAIL_ACCOUNTS $U_DATABASES $U_CRON_JOBS + $U_BACKUPS $TIME $DATE' # Listing user case $format in diff --git a/bin/v_list_user_backups b/bin/v_list_user_backups index 79e703d08..0b3373661 100755 --- a/bin/v_list_user_backups +++ b/bin/v_list_user_backups @@ -14,8 +14,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # @@ -25,10 +24,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -36,7 +35,7 @@ is_user_valid #----------------------------------------------------------# # Checking config -conf=$V_USERS/$user/backup.conf +conf=$USER_DATA/backup.conf if [ ! -e "$conf" ]; then touch $conf fi diff --git a/bin/v_list_user_ips b/bin/v_list_user_ips index da4c701f9..2ec3c49c7 100755 --- a/bin/v_list_user_ips +++ b/bin/v_list_user_ips @@ -1,6 +1,6 @@ #!/bin/bash # info: list user ips -# options user [format] +# options: user [format] # # The function for obtainig the list of available ip addresses. @@ -14,16 +14,15 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_user_ips() { # Print top bracket echo '{' fileds_count=$(echo "$fields" | wc -w) - for IP in $(ls $V_IPS/); do - source $V_IPS/$IP + for IP in $(ls $VESTA/data/ips/); do + source $VESTA/data/ips/$IP if [ "$OWNER" = "$user" ]; then # Closing bracket if there already was output if [ -n "$data" ]; then @@ -83,8 +82,8 @@ json_list_user_ips() { # Shell function shell_list_user_ips() { - for IP in $(ls $V_IPS/); do - source $V_IPS/$IP + for IP in $(ls $VESTA/data/ips/); do + source $VESTA/data/ips/$IP if [ "$OWNER" = "$user" ]; then eval echo "$fields" else @@ -104,10 +103,10 @@ shell_list_user_ips() { check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# diff --git a/bin/v_list_user_ns b/bin/v_list_user_ns index a567ff7fc..d0d8e0420 100755 --- a/bin/v_list_user_ns +++ b/bin/v_list_user_ns @@ -14,12 +14,11 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_ns() { - ns=$(grep "^NS='" $V_USERS/$user/user.conf |cut -f 2 -d \') + ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') # Print top bracket echo '[' i=1 @@ -39,7 +38,7 @@ json_list_ns() { # Shell function shell_list_ns() { - ns=$(grep "^NS='" $V_USERS/$user/user.conf |cut -f 2 -d \') + ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') if [ -z "$nohead" ]; then # Print result echo "NAMESERVER" @@ -60,10 +59,10 @@ shell_list_ns() { check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# diff --git a/bin/v_list_user_packages b/bin/v_list_user_packages index af7b2f675..658b60640 100755 --- a/bin/v_list_user_packages +++ b/bin/v_list_user_packages @@ -13,8 +13,7 @@ format=${1-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_pkgs() { @@ -24,10 +23,10 @@ json_list_pkgs() { fileds_count=$(echo "$fields" | wc -w) # Starting main loop - for package in $(ls $V_DATA/packages); do + for package in $(ls $VESTA/data/packages); do PACKAGE=${package/.pkg/} # Assing key=value - pkg_data=$(cat $V_DATA/packages/$package) + pkg_data=$(cat $VESTA/data/packages/$package) eval $pkg_data # Closing bracket if there already was output @@ -67,10 +66,10 @@ json_list_pkgs() { # Shell fnction shell_list_pkgs() { # Listing pkg files - for package in $(ls $V_DATA/packages); do + for package in $(ls $VESTA/data/packages); do PACKAGE=${package/.pkg/} # Assign key=value - pkg_descr=$(cat $V_DATA/packages/$package) + pkg_descr=$(cat $VESTA/data/packages/$package) eval $pkg_descr diff --git a/bin/v_list_users b/bin/v_list_users index f46ffca59..9fc2030fc 100755 --- a/bin/v_list_users +++ b/bin/v_list_users @@ -13,7 +13,6 @@ format=${1-shell} # Importing variables -source $VESTA/conf/vars.conf # Json function json_list_users() { @@ -21,9 +20,9 @@ json_list_users() { fileds_count=$(echo "$fields" | wc -w) # Starting main loop - for USER in $(ls $V_USERS/); do + for USER in $(ls $VESTA/data/users/); do # Reading user data - source $V_USERS/$USER/user.conf + source $VESTA/data/users/$USER/user.conf # Closing bracket if there already was output if [ -n "$data" ]; then @@ -70,8 +69,8 @@ shell_list_users() { fi # Starting main loop - for USER in $(ls $V_USERS/); do - source $V_USERS/$USER/user.conf + for USER in $(ls $VESTA/data/users/); do + source $VESTA/data/users/$USER/user.conf eval echo "$fields" done } @@ -85,14 +84,14 @@ shell_list_users() { fields="\$USER \$FNAME \$LNAME \$PACKAGE \$WEB_DOMAINS \$WEB_ALIASES \$WEB_TPL" fields="$fields \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS \$MAIL_ACCOUNTS" fields="$fields \$DATABASES \$CRON_JOBS \$DISK_QUOTA \$BANDWIDTH \$NS \$SHELL" -fields="$fields \$BACKUPS \$CONTACT \$REPORTS \$RKEY \$SUSPENDED" +fields="$fields \$BACKUPS \$CONTACT \$CRON_REPORTS \$RKEY \$SUSPENDED" fields="$fields \$SUSPENDED_USERS \$SUSPENDED_WEB \$SUSPENDED_DNS" fields="$fields \$SUSPENDED_MAIL \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL" fields="$fields \$IP_OWNED \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB" fields="$fields \$U_DISK_MAIL \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS" fields="$fields \$U_WEB_SSL \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS" fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS" -fields="$fields \$U_BACKUPS \$DATE" +fields="$fields \$U_BACKUPS \$TIME \$DATE" # Listing domains case $format in diff --git a/bin/v_list_web_domain b/bin/v_list_web_domain index ece8e4920..12e329765 100755 --- a/bin/v_list_web_domain +++ b/bin/v_list_web_domain @@ -16,9 +16,7 @@ domain=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/func/shared.sh # Json function json_list_domain() { @@ -82,7 +80,7 @@ shell_list_domain() { check_args '2' "$#" 'user domain [format]' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -93,7 +91,7 @@ is_domain_valid 'web' #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/web.conf +conf=$USER_DATA/web.conf # Defining fileds to select fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG @@ -103,7 +101,7 @@ fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG case $format in json) json_list_domain ;; plain) nohead=1; shell_list_domain ;; - shell) shell_list_domain |column -t ;; + shell) shell_list_domain ;; *) check_args '2' '0' 'user domain [format]' esac diff --git a/bin/v_list_web_domain_ssl b/bin/v_list_web_domain_ssl index a9cac1b63..3bd6310ff 100755 --- a/bin/v_list_web_domain_ssl +++ b/bin/v_list_web_domain_ssl @@ -15,9 +15,7 @@ domain=$2 format=${3-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/func/shared.sh # Json function json_list_ssl() { @@ -53,7 +51,7 @@ shell_list_ssl() { check_args '2' "$#" 'user domain [format]' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -62,16 +60,16 @@ is_domain_valid 'web' #----------------------------------------------------------# # Action # #----------------------------------------------------------# -if [ -e "$V_USERS/$user/ssl/$domain.crt" ]; then - crt=$(cat $V_USERS/$user/ssl/$domain.crt |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +if [ -e "$USER_DATA/ssl/$domain.crt" ]; then + crt=$(cat $USER_DATA/ssl/$domain.crt |sed -e ':a;N;$!ba;s/\n/\\n/g' ) fi -if [ -e "$V_USERS/$user/ssl/$domain.key" ]; then - key=$(cat $V_USERS/$user/ssl/$domain.key |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +if [ -e "$USER_DATA/ssl/$domain.key" ]; then + key=$(cat $USER_DATA/ssl/$domain.key |sed -e ':a;N;$!ba;s/\n/\\n/g' ) fi -if [ -e "$V_USERS/$user/ssl/$domain.ca" ]; then - ca=$(cat $V_USERS/$user/ssl/$domain.ca |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + ca=$(cat $USER_DATA/ssl/$domain.ca |sed -e ':a;N;$!ba;s/\n/\\n/g' ) fi # Listing domains diff --git a/bin/v_list_web_domains b/bin/v_list_web_domains index dc5c0bfac..4ecf7149f 100755 --- a/bin/v_list_web_domains +++ b/bin/v_list_web_domains @@ -1,6 +1,6 @@ #!/bin/bash # info: list web domains -# options user [format] +# options: user [format] # # The function of obtaining the list of all user domains. @@ -14,8 +14,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,10 +25,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -37,7 +36,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/web.conf +conf=$USER_DATA/web.conf # Defining fileds to select fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$PHP \$CGI" diff --git a/bin/v_list_web_domains_alias b/bin/v_list_web_domains_alias index 112da7b37..779471940 100755 --- a/bin/v_list_web_domains_alias +++ b/bin/v_list_web_domains_alias @@ -16,8 +16,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -28,10 +27,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -39,7 +38,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/web.conf +conf=$USER_DATA/web.conf # Defining fileds to select fields="\$DOMAIN \$ALIAS" diff --git a/bin/v_list_web_domains_elog b/bin/v_list_web_domains_elog index c816f8378..d80b20b4f 100755 --- a/bin/v_list_web_domains_elog +++ b/bin/v_list_web_domains_elog @@ -16,8 +16,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -28,10 +27,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -39,7 +38,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/web.conf +conf=$USER_DATA/web.conf # Defining fileds to select fields="\$DOMAIN \$ELOG" diff --git a/bin/v_list_web_domains_nginx b/bin/v_list_web_domains_nginx index 08b961fe2..355c3cd97 100755 --- a/bin/v_list_web_domains_nginx +++ b/bin/v_list_web_domains_nginx @@ -16,8 +16,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -28,10 +27,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -39,7 +38,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/web.conf +conf=$USER_DATA/web.conf # Defining fileds to select fields="\$DOMAIN \$NGINX \$NGINX_EXT" diff --git a/bin/v_list_web_domains_ssl b/bin/v_list_web_domains_ssl index e95c8feba..3f090777e 100755 --- a/bin/v_list_web_domains_ssl +++ b/bin/v_list_web_domains_ssl @@ -16,8 +16,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -28,10 +27,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -39,7 +38,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/web.conf" +conf="$USER_DATA/web.conf" # Defining fileds to select fields="\$DOMAIN \$IP \$TPL \$SSL \$SSL_HOME" diff --git a/bin/v_list_web_domains_stats b/bin/v_list_web_domains_stats index 7c68f050e..be8850101 100755 --- a/bin/v_list_web_domains_stats +++ b/bin/v_list_web_domains_stats @@ -17,8 +17,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -29,10 +28,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user [format]' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -40,7 +39,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf=$V_USERS/$user/web.conf +conf=$USER_DATA/web.conf # Defining fileds to select fields="\$DOMAIN \$STATS \$STATS_AUTH" diff --git a/bin/v_list_web_templates b/bin/v_list_web_templates index 59e5a52d8..39754854a 100755 --- a/bin/v_list_web_templates +++ b/bin/v_list_web_templates @@ -14,8 +14,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_wtpl() { @@ -24,8 +23,8 @@ json_list_wtpl() { # Listing files by mask for template in $(echo "$templates" |sed -e "s/,/\n/g"); do - if [ -e "$V_WEBTPL/apache_$template.descr" ]; then - descr=$(cat $V_WEBTPL/apache_$template.descr | grep '#'|\ + if [ -e "$WEBTPL/apache_$template.descr" ]; then + descr=$(cat $WEBTPL/apache_$template.descr | grep '#'|\ sed -e ':a;N;$!ba;s/\n/ /g') # Checking !first line to print bracket if [ $i -ne 1 ]; then @@ -48,8 +47,8 @@ json_list_wtpl() { # Shell function shell_list_wtpl() { for template in $(echo "$templates" |sed -e "s/,/\n/g"); do - if [ -e "$V_WEBTPL/apache_$template.descr" ]; then - tpl_descr=$(cat $V_WEBTPL/apache_$template.descr |grep '#') + if [ -e "$WEBTPL/apache_$template.descr" ]; then + tpl_descr=$(cat $WEBTPL/apache_$template.descr |grep '#') if [ -z "$nohead" ]; then echo "----------" fi @@ -68,10 +67,10 @@ shell_list_wtpl() { check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# diff --git a/bin/v_list_web_templates_nginx b/bin/v_list_web_templates_nginx index 3ad321e65..c8b82652e 100755 --- a/bin/v_list_web_templates_nginx +++ b/bin/v_list_web_templates_nginx @@ -14,8 +14,7 @@ user=$1 format=${2-shell} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh # Json function json_list_wtpl() { @@ -24,8 +23,8 @@ json_list_wtpl() { # Listing files by mask for template in $(echo "$templates" |sed -e "s/,/\n/g"); do - if [ -e "$V_WEBTPL/ngingx_vhost_$template.descr" ]; then - descr=$(cat $V_WEBTPL/ngingx_vhost_$template.descr | grep '#'|\ + if [ -e "$WEBTPL/ngingx_vhost_$template.descr" ]; then + descr=$(cat $WEBTPL/ngingx_vhost_$template.descr | grep '#'|\ sed -e ':a;N;$!ba;s/\n/ /g') # Checking !first line to print bracket if [ $i -ne 1 ]; then @@ -48,8 +47,8 @@ json_list_wtpl() { # Shell function shell_list_wtpl() { for template in $(echo "$templates" |sed -e "s/,/\n/g"); do - if [ -e "$V_WEBTPL/ngingx_vhost_$template.descr" ]; then - tpl_descr=$(cat $V_WEBTPL/ngingx_vhost_$template.descr |grep '#') + if [ -e "$WEBTPL/ngingx_vhost_$template.descr" ]; then + tpl_descr=$(cat $WEBTPL/ngingx_vhost_$template.descr |grep '#') if [ -z "$nohead" ]; then echo "----------" fi @@ -68,10 +67,10 @@ shell_list_wtpl() { check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# diff --git a/bin/v_rebuild_cron_jobs b/bin/v_rebuild_cron_jobs index b7059c7ed..2e5c70cfd 100755 --- a/bin/v_rebuild_cron_jobs +++ b/bin/v_rebuild_cron_jobs @@ -12,28 +12,19 @@ # Argument defenition user=$1 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '1' "$#" 'user' - -# Checking argument format -format_validation 'user' - -# Checking cron system -is_system_enabled 'CRON_SYSTEM' - -# Checking user -is_user_valid +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -48,10 +39,10 @@ sync_cron_jobs # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_rebuild_dns_domains b/bin/v_rebuild_dns_domains index c52e76a36..d1097517f 100755 --- a/bin/v_rebuild_dns_domains +++ b/bin/v_rebuild_dns_domains @@ -13,11 +13,10 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh #----------------------------------------------------------# @@ -28,16 +27,16 @@ source $V_FUNC/ip.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking dns system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -49,13 +48,13 @@ user_records=0 suspended_dns=0 # Checking dns folder -if [ ! -d "$V_USERS/$user/dns" ]; then - rm -f $V_USERS/$user/dns - mkdir $V_USERS/$user/dns +if [ ! -d "$USER_DATA/dns" ]; then + rm -f $USER_DATA/dns + mkdir $USER_DATA/dns fi # Defining config -conf="$V_USERS/$user/dns.conf" +conf="$USER_DATA/dns.conf" # Defining search string search_string="DOMAIN" @@ -82,8 +81,8 @@ for domain in $domains; do domain_idn=$(idn -t --quiet -a "$domain") # Checking zone file - if [ ! -e "$V_USERS/$user/dns/$domain" ]; then - cat $V_DNSTPL/$TPL.tpl |\ + if [ ! -e "$USER_DATA/dns/$domain" ]; then + cat $DNSTPL/$TPL.tpl |\ sed -e "s/%ip%/$IP/g" \ -e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain%/$domain/g" \ @@ -95,14 +94,14 @@ for domain in $domains; do -e "s/%ns6%/$ns6/g" \ -e "s/%ns7%/$ns7/g" \ -e "s/%ns8%/$ns8/g" \ - -e "s/%date%/$V_DATE/g" > $V_USERS/$user/dns/$domain + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain fi # Sorting records sort_dns_records # Updating zone - conf="$V_HOME/$user/conf/dns/$domain.db" + conf="$HOMEDIR/$user/conf/dns/$domain.db" update_domain_zone chmod 640 $conf @@ -120,12 +119,12 @@ for domain in $domains; do else if [ -z "$(grep /$domain.db $nconf)" ]; then named="zone \"$domain_idn\" {type master; file" - named="$named \"$V_HOME/$user/conf/dns/$domain.db\";};" + named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" echo "$named" >> /etc/named.conf fi fi user_domains=$((user_domains + 1)) - records=$(wc -l $V_USERS/$user/dns/$domain | cut -f 1 -d ' ') + records=$(wc -l $USER_DATA/dns/$domain | cut -f 1 -d ' ') user_records=$((user_records + records)) update_domain_value 'dns' '$RECORDS' "$records" done @@ -141,9 +140,9 @@ update_user_value "$user" '$U_DNS_RECORDS' "$user_records" update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_rebuild_mail_domains b/bin/v_rebuild_mail_domains index a540486df..53882c82f 100755 --- a/bin/v_rebuild_mail_domains +++ b/bin/v_rebuild_mail_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,16 +26,16 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking mail system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -50,13 +49,13 @@ SUSPENDED_MAIL='0' U_DISK_MAIL='0' # Checking mail folder -if [ ! -d "$V_USERS/$user/mail" ]; then - rm -f $V_USERS/$user/mail - mkdir $V_USERS/$user/mail +if [ ! -d "$USER_DATA/mail" ]; then + rm -f $USER_DATA/mail + mkdir $USER_DATA/mail fi # Defining config -conf="$V_USERS/$user/mail.conf" +conf="$USER_DATA/mail.conf" search_string="DOMAIN" field='$DOMAIN' domains=$(dom_clear_search) @@ -68,44 +67,44 @@ for domain in $domains; do get_domain_values 'mail' # Rebuilding config structure - mkdir -p $V_HOME/$user/conf/mail/$domain - rm -f $V_HOME/$user/conf/mail/$domain/aliases - rm -f $V_HOME/$user/conf/mail/$domain/protection - rm -f $V_HOME/$user/conf/mail/$domain/passwd - touch $V_HOME/$user/conf/mail/$domain/aliases - touch $V_HOME/$user/conf/mail/$domain/protection - touch $V_HOME/$user/conf/mail/$domain/passwd - chown -R root:mail $V_HOME/$user/conf/mail/$domain - chmod 770 $V_HOME/$user/conf/mail/$domain - chmod 660 $V_HOME/$user/conf/mail/$domain* + mkdir -p $HOMEDIR/$user/conf/mail/$domain + rm -f $HOMEDIR/$user/conf/mail/$domain/aliases + rm -f $HOMEDIR/$user/conf/mail/$domain/protection + rm -f $HOMEDIR/$user/conf/mail/$domain/passwd + touch $HOMEDIR/$user/conf/mail/$domain/aliases + touch $HOMEDIR/$user/conf/mail/$domain/protection + touch $HOMEDIR/$user/conf/mail/$domain/passwd + chown -R root:mail $HOMEDIR/$user/conf/mail/$domain + chmod 770 $HOMEDIR/$user/conf/mail/$domain + chmod 660 $HOMEDIR/$user/conf/mail/$domain* # Adding antispam protection if [ "$ANTISPAM" = 'yes' ]; then - echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection fi # Adding antivirus protection if [ "$ANTIVIRUS" = 'yes' ]; then - echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection fi # Adding dkim if [ "$DKIM" = 'yes' ]; then - pem="$V_USERS/$user/mail/$domain.pem" - pub="$V_USERS/$user/mail/$domain.pub" - openssl genrsa -out $pem 512 2>/dev/null - openssl rsa -pubout -in $pem -out $pub 2>/dev/null - chmod 660 $V_USERS/$user/mail/$domain.* + pem="$USER_DATA/mail/$domain.pem" + pub="$USER_DATA/mail/$domain.pub" + openssl genrsa -out $pem 512 &>/dev/null + openssl rsa -pubout -in $pem -out $pub &>/dev/null + chmod 660 $USER_DATA/mail/$domain.* - cp $pem $V_HOME/$user/conf/mail/$domain/dkim.pem - chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem - chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem + cp $pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem # Deleting old dkim records - records=$($V_BIN/v_list_dns_domain_records $user $domain plain) + records=$($BIN/v_list_dns_domain_records $user $domain plain) dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ') for id in $dkim_records; do - $V_BIN/v_delete_dns_domain_record $user $domain $id + $BIN/v_delete_dns_domain_record $user $domain $id done # Adding dkim dns records @@ -114,24 +113,24 @@ for domain in $domains; do p=$(cat $pub|grep -v ' KEY---'|tr -d '\n') record='_domainkey' policy="\"t=y; o=~;\"" - $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$policy" + $BIN/v_add_dns_domain_record $user $domain $record TXT "$policy" record='mail._domainkey' slct="\"k=rsa\; p=$p\"" - $V_BIN/v_add_dns_domain_record $user $domain $record TXT "$slct" + $BIN/v_add_dns_domain_record $user $domain $record TXT "$slct" fi fi # Adding antispam protection if [ "$SUSPENDED" != 'yes' ]; then - ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/ + ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ fi - if [ ! -e $V_HOME/$user/mail/$domain ]; then - mkdir $V_HOME/$user/mail/$domain + if [ ! -e $HOMEDIR/$user/mail/$domain ]; then + mkdir $HOMEDIR/$user/mail/$domain fi - chown $user:mail $V_HOME/$user/mail/$domain - chmod 770 $V_HOME/$user/mail/$domain + chown $user:mail $HOMEDIR/$user/mail/$domain + chmod 770 $HOMEDIR/$user/mail/$domain # Rebuild counters U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) @@ -155,9 +154,9 @@ update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" # Adding task to the vesta pipe -restart_schedule 'mail' +$BIN/v_restart_mail # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_rebuild_web_domains b/bin/v_rebuild_web_domains index b5cdf78d2..e8ca878d4 100755 --- a/bin/v_rebuild_web_domains +++ b/bin/v_rebuild_web_domains @@ -13,13 +13,12 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/ip.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh -url=${2-$V_SUSPEND_URL} +url=${2-$SUSPEND_URL} #----------------------------------------------------------# # Verifications # @@ -29,16 +28,16 @@ url=${2-$V_SUSPEND_URL} check_args '1' "$#" 'user [suspend_url]' # Checking argument format -format_validation 'user' 'url' +validate_format 'user' 'url' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" #----------------------------------------------------------# @@ -51,10 +50,10 @@ user_aliases=0 suspended_web=0 # Clean up old config -rm -f $V_HOME/$user/conf/tmp_*.conf +rm -f $HOMEDIR/$user/conf/tmp_*.conf # Defining config -conf=$V_USERS/$user/web.conf +conf=$USER_DATA/web.conf fields='$DOMAIN' nohead=1 @@ -69,15 +68,15 @@ for domain in $(shell_list) ; do upd_web_domain_values # Adding domain to the tmp_httpd.conf - tpl_file="$V_WEBTPL/apache_$TPL.tpl" - conf="$V_HOME/$user/conf/web/tmp_httpd.conf" + tpl_file="$WEBTPL/apache_$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" add_web_config chown root:apache $conf chmod 640 $conf # Running template trigger - if [ -x $V_WEBTPL/apache_$TPL.sh ]; then - $V_WEBTPL/apache_$TPL.sh $user $domain $ip $V_HOME $docroot + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot fi # Checking aliases @@ -88,7 +87,7 @@ for domain in $(shell_list) ; do # Checking stats if [ ! -z "$STATS" ]; then - cat $V_WEBTPL/$STATS.tpl |\ + cat $WEBTPL/$STATS.tpl |\ sed -e "s/%ip%/$ip/g" \ -e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ @@ -97,12 +96,12 @@ for domain in $(shell_list) ; do -e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain%/$domain/g" \ -e "s/%user%/$user/g" \ - -e "s/%home%/${V_HOME////\/}/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ -e "s/%alias%/${aliases//,/ }/g" \ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $V_HOME/$user/conf/web/$STATS.$domain.conf + > $HOMEDIR/$user/conf/web/$STATS.$domain.conf - stats_string="$V_BIN/v_update_web_domain_stat $user $domain" + stats_string="$BIN/v_update_web_domain_stat $user $domain" check_stats_pipe=$(grep "$stats_string" $V_QUEUE/stats.pipe) if [ -z "$check_stats_pipe" ]; then echo "$stats_string" >> $V_QUEUE/stats.pipe @@ -112,26 +111,26 @@ for domain in $(shell_list) ; do # Checking ssl if [ "$SSL" = 'yes' ]; then # Adding domain to the shttpd.conf - conf="$V_HOME/$user/conf/web/tmp_shttpd.conf" - tpl_file="$V_WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" add_web_config chown root:apache $conf chmod 640 $conf - cp -f $V_USERS/$user/ssl/$domain.crt \ - $V_HOME/$user/conf/web/ssl.$domain.crt - cp -f $V_USERS/$user/ssl/$domain.key \ - $V_HOME/$user/conf/web/ssl.$domain.key - cp -f $V_USERS/$user/ssl/$domain.pem \ - $V_HOME/$user/conf/web/ssl.$domain.pem - if [ -e "$V_USERS/$user/ssl/$domain.ca" ]; then - cp -f $V_USERS/$user/ssl/$domain.ca \ - $V_HOME/$user/conf/web/ssl.$domain.ca + cp -f $USER_DATA/ssl/$domain.crt \ + $HOMEDIR/$user/conf/web/ssl.$domain.crt + cp -f $USER_DATA/ssl/$domain.key \ + $HOMEDIR/$user/conf/web/ssl.$domain.key + cp -f $USER_DATA/ssl/$domain.pem \ + $HOMEDIR/$user/conf/web/ssl.$domain.pem + if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca \ + $HOMEDIR/$user/conf/web/ssl.$domain.ca fi # Running template trigger - if [ -x $V_WEBTPL/apache_$TPL.sh ]; then - $V_WEBTPL/apache_$TPL.sh $user $domain $ip $V_HOME $docroot + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot fi user_ssl=$((user_ssl + 1)) @@ -140,8 +139,8 @@ for domain in $(shell_list) ; do # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/tmp_nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" add_web_config chown root:nginx $conf chmod 640 $conf @@ -153,8 +152,8 @@ for domain in $(shell_list) ; do proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" fi - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/tmp_snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" add_web_config chown root:nginx $conf chmod 640 $conf @@ -168,8 +167,8 @@ for domain in $(shell_list) ; do done # Renaming tmp config -tmp_conf="$V_HOME/$user/conf/web/tmp_httpd.conf" -conf="$V_HOME/$user/conf/web/httpd.conf" +tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" +conf="$HOMEDIR/$user/conf/web/httpd.conf" if [ -e "$tmp_conf" ]; then mv $tmp_conf $conf fi @@ -183,8 +182,8 @@ fi # Checking ssl if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$V_HOME/$user/conf/web/tmp_shttpd.conf" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" mv $tmp_conf $conf # Checking include in main httpd.conf @@ -197,8 +196,8 @@ fi # Checking nginx if [ "$ngix_change" = 'yes' ]; then nginx_conf='/etc/nginx/conf.d/vesta_users.conf' - tmp_conf="$V_HOME/$user/conf/web/tmp_nginx.conf" - conf="$V_HOME/$user/conf/web/nginx.conf" + tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" + conf="$HOMEDIR/$user/conf/web/nginx.conf" mv $tmp_conf $conf nginx_conf_check=$(grep "$conf" $nginx_conf ) @@ -208,8 +207,8 @@ if [ "$ngix_change" = 'yes' ]; then # Checking ssl for nginx if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$V_HOME/$user/conf/web/tmp_snginx.conf" - conf="$V_HOME/$user/conf/web/snginx.conf" + tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" + conf="$HOMEDIR/$user/conf/web/snginx.conf" mv $tmp_conf $conf nginx_conf_check=$(grep "$conf" $nginx_conf ) if [ -z "$nginx_conf_check" ]; then @@ -229,9 +228,9 @@ update_user_value "$user" '$U_WEB_SSL' "$user_ssl" update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases" # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_restart_cron b/bin/v_restart_cron index 9361baa0b..8f0b3c144 100755 --- a/bin/v_restart_cron +++ b/bin/v_restart_cron @@ -9,10 +9,8 @@ # Variable&Function # #----------------------------------------------------------# -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf - +# Includes +source $VESTA/conf/vesta.conf #----------------------------------------------------------# # Action # @@ -20,7 +18,7 @@ source $V_CONF/vesta.conf # Parsing config / or just source config if [ "$CRON_SYSTEM" = 'crond' ]; then - /etc/init.d/crond 'reload' >/dev/null 2>&1 + /etc/init.d/crond 'reload' &>/dev/null if [ $? -ne 0 ]; then echo "$E_RESTART $1" exit $E_RESTART diff --git a/bin/v_restart_dns b/bin/v_restart_dns index 7816b1dfc..e79599b7a 100755 --- a/bin/v_restart_dns +++ b/bin/v_restart_dns @@ -11,8 +11,7 @@ # Importing variables source /etc/profile.d/vesta.sh -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf +source $VESTA/conf/vesta.conf #----------------------------------------------------------# @@ -20,9 +19,9 @@ source $V_CONF/vesta.conf #----------------------------------------------------------# if [ "$DNS_SYSTEM" = 'bind' ]; then - /etc/init.d/named reload >/dev/null 2>&1 + /etc/init.d/named reload &>/dev/null if [ $? -ne 0 ]; then - #$V_FUNC/report_issue 'sys' 'cron' + #$VESTA/func/report_issue 'sys' 'cron' echo "$E_RESTART $1" exit $E_RESTART fi diff --git a/bin/v_restart_web b/bin/v_restart_web index 34fea61b9..68096d527 100755 --- a/bin/v_restart_web +++ b/bin/v_restart_web @@ -10,20 +10,19 @@ #----------------------------------------------------------# # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf +source $VESTA/conf/vesta.conf # Restart functions apache() { - /etc/init.d/httpd status >/dev/null 2>&1 + /etc/init.d/httpd status &>/dev/null if [ $? -eq 0 ]; then - /etc/init.d/httpd graceful >/dev/null 2>&1 + /etc/init.d/httpd graceful &>/dev/null if [ $? -ne 0 ]; then echo "$E_RESTART $1" exit $E_RESTART fi else - /etc/init.d/httpd start >/dev/null 2>&1 + /etc/init.d/httpd start &>/dev/null if [ $? -ne 0 ]; then echo "$E_RESTART $1" exit $E_RESTART @@ -32,15 +31,15 @@ apache() { } nginx() { - /etc/init.d/nginx status >/dev/null 2>&1 + /etc/init.d/nginx status &>/dev/null if [ $? -eq 0 ]; then - /etc/init.d/nginx reload >/dev/null 2>&1 + /etc/init.d/nginx reload &>/dev/null if [ $? -ne 0 ]; then echo "$E_RESTART $1" exit $E_RESTART fi else - /etc/init.d/nginx start >/dev/null 2>&1 + /etc/init.d/nginx start &>/dev/null if [ $? -ne 0 ]; then echo "$E_RESTART $1" exit $E_RESTART diff --git a/bin/v_restore_user b/bin/v_restore_user index e48d72766..883629fdf 100755 --- a/bin/v_restore_user +++ b/bin/v_restore_user @@ -14,11 +14,10 @@ user=$1 backup=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh # Defining ftp command function ftpc() { @@ -34,11 +33,11 @@ EOF init_ftp_variables() { # Checking config - source $V_CONF/ftp.backup.conf + source $VESTA/conf/ftp.backup.conf if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\ [ -z "$BPATH" ]; then echo "Error: Parsing error" - log_event 'debug' "$E_PARSING $V_EVENT" + log_event 'debug' "$E_PARSING $EVENT" exit $E_PARSING fi } @@ -51,7 +50,7 @@ check_ftp_connection(){ rm $ftmpdir" if [ ! -z "$(ftpc "$command")" ] ; then echo "Error: FTP error" - log_event 'debug' "$E_FTP $V_EVENT" + log_event 'debug' "$E_FTP $EVENT" exit $E_FTP fi } @@ -70,7 +69,7 @@ echo check_args '2' "$#" 'user backup' # Checking argument format -format_validation 'user' 'backup' +validate_format 'user' 'backup' # Checking backup system is enabled is_system_enabled 'BACKUP_SYSTEM' @@ -78,35 +77,35 @@ is_system_enabled 'BACKUP_SYSTEM' # Checking load averages la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.') i=0 -while [ "$la" -ge "$V_BACKUP_LA_LIMIT" ]; do +while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do echo "$(date "+%F %T") Load Average $la" echo sleep 60 if [ "$i" -ge "15" ]; then echo "Error: LA is too high" - log_event 'debug' "$E_LA $V_EVENT" + log_event 'debug' "$E_LA $EVENT" exit $E_LA fi (( ++i)) done # Checking local backup existance -if [ ! -e "$V_BACKUP/$user.$backup.tar" ]; then +if [ ! -e "$BACKUP/$user.$backup.tar" ]; then if [ ! -z "$(echo $BACKUP_SYSTEM | grep -w ftp)" ]; then init_ftp_variables check_ftp_connection if [ ! -z "$(ftpc ls |awk '{print $9}' |grep $user.$backup.)" ]; then - cd $V_BACKUP + cd $BACKUP echo "$(date "+%F %T") Downloading ftp backup" - ftpc "get $user.$backup.tar" >> /dev/null 2>/dev/null + ftpc "get $user.$backup.tar" &>/dev/null echo "$(date "+%F %T") Downloaded $user.$backup.tar" fi fi fi -if [ ! -e "$V_BACKUP/$user.$backup.tar" ]; then - echo "Error: $V_BACKUP/$user.$backup.tar backup not found" - log_event 'debug' "$E_NOTEXIST $V_EVENT" +if [ ! -e "$BACKUP/$user.$backup.tar" ]; then + echo "Error: $BACKUP/$user.$backup.tar backup not found" + log_event 'debug' "$E_NOTEXIST $EVENT" exit $E_NOTEXIST fi @@ -141,11 +140,11 @@ fi #----------------------------------------------------------# # Creating temporary directory -tmpdir=$(mktemp -p $V_BACKUP -d) +tmpdir=$(mktemp -p $BACKUP -d) echo "TMPDIR is $tmpdir" cd $tmpdir echo "$(date "+%F %T") Extracting files from backup" -tar -xf $V_BACKUP/$user.$backup.tar +tar -xf $BACKUP/$user.$backup.tar echo "$(date "+%F %T") Backup has been unpacked" # Checking Vesta @@ -157,6 +156,6 @@ echo "$(date "+%F %T") Backup has been unpacked" #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_cron_job b/bin/v_suspend_cron_job index 1e0a1c5fe..688f32179 100755 --- a/bin/v_suspend_cron_job +++ b/bin/v_suspend_cron_job @@ -1,6 +1,6 @@ #!/bin/bash # info: suspend cron job -# options: user job +# options: user job [restart] # # The function suspends a certain job of the cron scheduler. @@ -12,32 +12,22 @@ # Argument defenition user=$1 job=$2 +restart=$3 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Inlcudes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number -check_args '2' "$#" 'user job' - -# Checking argument format -format_validation 'user' 'job' - -# Checking user -is_user_valid - -# Checking cron job -is_job_valid - -# Checking suspend status -is_job_suspended +check_args '2' "$#" 'user job [restart]' +validate_format 'user' 'job' 'rstart' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_suspended 'cron' 'JOB' "$job" #----------------------------------------------------------# @@ -45,7 +35,7 @@ is_job_suspended #----------------------------------------------------------# # Suspending job -update_cron_job_value '$SUSPENDED' 'yes' +update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'yes' increase_user_value "$user" '$SUSPENDED_CRON' # Sync system cron with user @@ -56,12 +46,12 @@ sync_cron_jobs # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -if [ "$3" != 'no_restart' ]; then - restart_schedule 'cron' +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v_restart_cron fi # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_cron_jobs b/bin/v_suspend_cron_jobs index 74bc439aa..fb9408571 100755 --- a/bin/v_suspend_cron_jobs +++ b/bin/v_suspend_cron_jobs @@ -12,54 +12,38 @@ # Argument defenition user=$1 -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '1' "$#" 'user' - -# Checking argument format -format_validation 'user' - -# Checking user -is_user_valid +validate_format 'user' +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# # Action # #----------------------------------------------------------# -# Searching jobs -conf="$V_USERS/$user/cron.conf" -field='$JOB' -search_string="SUSPENDED='no'" -jobs=$(cron_clear_search) - -# Suspendning -for job in $jobs; do - $V_BIN/v_suspend_cron_job $user $job 'no_restart' +# Suspendn all jobs +for job in $(search_objects 'cron' 'SUSPENDED' 'no' 'JOB'); do + $BIN/v_suspend_cron_job $user $job 'no' done -# Sync system cron with user -sync_cron_jobs "$user" - #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_db_base b/bin/v_suspend_db_base index 331a9915a..33f78d53f 100755 --- a/bin/v_suspend_db_base +++ b/bin/v_suspend_db_base @@ -14,10 +14,9 @@ user=$1 database=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -28,13 +27,13 @@ source $V_FUNC/db.func check_args '2' "$#" 'user db_name' # Checking argument format -format_validation 'user' 'database' +validate_format 'user' 'database' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking db existance is_db_valid @@ -68,6 +67,6 @@ update_db_base_value '$SUSPENDED' 'yes' increase_user_value "$user" '$SUSPENDED_DB' # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_db_bases b/bin/v_suspend_db_bases index cde3115ad..9ead11c4e 100755 --- a/bin/v_suspend_db_bases +++ b/bin/v_suspend_db_bases @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/db.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/db.conf" +conf="$USER_DATA/db.conf" # Defining fileds to select field='$DB' @@ -54,7 +53,7 @@ databases=$(db_clear_search) # Starting suspend loop for database in $databases; do - $V_BIN/v_suspend_db_base "$user" "$database" + $BIN/v_suspend_db_base "$user" "$database" done @@ -63,6 +62,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_dns_domain b/bin/v_suspend_dns_domain index 4fcce5598..6f1d2442e 100755 --- a/bin/v_suspend_dns_domain +++ b/bin/v_suspend_dns_domain @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,13 +28,13 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -66,9 +65,9 @@ update_domain_value 'dns' '$SUSPENDED' 'yes' increase_user_value "$user" '$SUSPENDED_DNS' # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_dns_domains b/bin/v_suspend_dns_domains index f407d8401..8361ef751 100755 --- a/bin/v_suspend_dns_domains +++ b/bin/v_suspend_dns_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking dns system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/dns.conf" +conf="$USER_DATA/dns.conf" # Defining fileds to select field='$DOMAIN' @@ -50,7 +49,7 @@ domains=$(dom_clear_search) # Starting suspend loop for domain in $domains; do - $V_BIN/v_suspend_dns_domain "$user" "$domain" + $BIN/v_suspend_dns_domain "$user" "$domain" done @@ -59,9 +58,9 @@ done #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_mail_domain b/bin/v_suspend_mail_domain index daae4ea20..4dffe7a41 100755 --- a/bin/v_suspend_mail_domain +++ b/bin/v_suspend_mail_domain @@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -64,6 +63,6 @@ rm -f /etc/exim/domains/$domain update_domain_value 'mail' '$SUSPENDED' 'yes' # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_mail_domains b/bin/v_suspend_mail_domains index ee9cbbeee..2594d53a0 100755 --- a/bin/v_suspend_mail_domains +++ b/bin/v_suspend_mail_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/mail.conf" +conf="$USER_DATA/mail.conf" # Defining fileds to select field='$DOMAIN' @@ -50,7 +49,7 @@ domains=$(dom_clear_search) # Starting suspend loop for domain in $domains; do - $V_BIN/v_suspend_mail_domain "$user" "$domain" + $BIN/v_suspend_mail_domain "$user" "$domain" done @@ -59,6 +58,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_user b/bin/v_suspend_user index b76e3b986..95870ea0a 100755 --- a/bin/v_suspend_user +++ b/bin/v_suspend_user @@ -13,9 +13,8 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,13 +25,13 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user status -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking user admin if [ "$user" = 'admin' ]; then @@ -49,12 +48,12 @@ fi # Suspending web domains if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $V_BIN/v_suspend_web_domains $user + $BIN/v_suspend_web_domains $user fi # Suspending dns domains if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $V_BIN/v_suspend_dns_domains $user + $BIN/v_suspend_dns_domains $user fi # Suspending mail domains @@ -62,12 +61,12 @@ fi # Suspending datbabases if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $V_BIN/v_suspend_db_bases $user + $BIN/v_suspend_db_bases $user fi # Suspending cron jobs if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $V_BIN/v_suspend_cron_jobs $user + $BIN/v_suspend_cron_jobs $user fi @@ -76,15 +75,15 @@ fi #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'cron' -restart_schedule 'web' -restart_schedule 'dns' +$BIN/v_restart_cron +$BIN/v_restart_web +$BIN/v_restart_dns # Changing suspend value update_user_value "$user" '$SUSPENDED' 'yes' increase_user_value 'admin' '$SUSPENDED_USERS' # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_web_domain b/bin/v_suspend_web_domain index f3b06fb98..bbc88d120 100755 --- a/bin/v_suspend_web_domain +++ b/bin/v_suspend_web_domain @@ -17,13 +17,12 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh # Defining url -url="${3-$V_SUSPEND_URL}" +url="${3-$SUSPEND_URL}" #----------------------------------------------------------# @@ -34,13 +33,13 @@ url="${3-$V_SUSPEND_URL}" check_args '2' "$#" 'user domain [suspend_url]' # Checking argument format -format_validation 'user' 'domain' 'url' +validate_format 'user' 'domain' 'url' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -55,8 +54,8 @@ is_domain_suspended 'web' # Parsing domain values get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" SUSPENDED='yes' # Preparing domain values for the template substitution @@ -68,23 +67,23 @@ add_web_config # Check ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" del_web_config add_web_config if [ "$SSL" = 'yes' ]; then proxy_string="rewrite ^(.*)\$ http://$url;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config add_web_config fi @@ -100,9 +99,9 @@ update_domain_value 'web' '$SUSPENDED' 'yes' increase_user_value "$user" '$SUSPENDED_WEB' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_suspend_web_domains b/bin/v_suspend_web_domains index d80393066..80fd3e0f3 100755 --- a/bin/v_suspend_web_domains +++ b/bin/v_suspend_web_domains @@ -13,13 +13,12 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh # Defining url -url="${2-$V_SUSPEND_URL}" +url="${2-$SUSPEND_URL}" #----------------------------------------------------------# @@ -30,13 +29,13 @@ url="${2-$V_SUSPEND_URL}" check_args '1' "$#" 'user [suspend_url]' # Checking argument format -format_validation 'user' 'url' +validate_format 'user' 'url' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -44,7 +43,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/web.conf" +conf="$USER_DATA/web.conf" # Defining fileds to select field='$DOMAIN' @@ -53,7 +52,7 @@ domains=$(dom_clear_search) # Starting suspend loop for domain in $domains; do - $V_BIN/v_suspend_web_domain "$user" "$domain" "$url" + $BIN/v_suspend_web_domain "$user" "$domain" "$url" done @@ -62,6 +61,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_cron_job b/bin/v_unsuspend_cron_job index f3f1325f9..d5a2db37b 100755 --- a/bin/v_unsuspend_cron_job +++ b/bin/v_unsuspend_cron_job @@ -1,6 +1,6 @@ #!/bin/bash # info: unuspend cron job -# options: user job +# options: user job [restart] # # The function unsuspen certain cron job. @@ -12,32 +12,22 @@ # Argument defenition user=$1 job=$2 +restart="$3" -# Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number -check_args '2' "$#" 'user job' - -# Checking argument format -format_validation 'user' 'job' - -# Checking user -is_user_valid - -# Checking cron job -is_job_valid - -# Check job is suspened -is_job_unsuspended +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" #----------------------------------------------------------# @@ -45,7 +35,7 @@ is_job_unsuspended #----------------------------------------------------------# # Unsuspending job -update_cron_job_value '$SUSPENDED' 'no' +update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'no' decrease_user_value "$user" '$SUSPENDED_CRON' # Sync system cron with user @@ -56,12 +46,12 @@ sync_cron_jobs # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -if [ "$3" != 'no_restart' ]; then - restart_schedule 'cron' +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v_restart_cron fi # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_cron_jobs b/bin/v_unsuspend_cron_jobs index 82c0f8ef8..189e136d9 100755 --- a/bin/v_unsuspend_cron_jobs +++ b/bin/v_unsuspend_cron_jobs @@ -13,53 +13,37 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/cron.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# -# Checking arg number check_args '1' "$#" 'user' - -# Checking argument format -format_validation 'user' - -# Checking user -is_user_valid +validate_format 'user' +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# # Action # #----------------------------------------------------------# -# Searching jobs -conf="$V_USERS/$user/cron.conf" -field='$JOB' -search_string="SUSPENDED='yes'" -jobs=$(cron_clear_search) - # Unsuspendning jobs -for job in $jobs; do - $V_BIN/v_unsuspend_cron_job $user $job 'no_restart' +for job in $(search_objects 'cron' 'SUSPENDED' 'yes' 'JOB'); do + $BIN/v_unsuspend_cron_job $user $job 'no' done -# Sync system cron with user -sync_cron_jobs - #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# -# Adding task to the vesta pipe -restart_schedule 'cron' +# Restart crond +$BIN/v_restart_cron # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_db_base b/bin/v_unsuspend_db_base index 957f0bb9c..ea380ebf7 100755 --- a/bin/v_unsuspend_db_base +++ b/bin/v_unsuspend_db_base @@ -14,10 +14,9 @@ user=$1 database=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -28,13 +27,13 @@ source $V_FUNC/db.func check_args '2' "$#" 'user db_name' # Checking argument format -format_validation 'user' 'database' +validate_format 'user' 'database' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking db existance is_db_valid @@ -68,6 +67,6 @@ update_db_base_value '$SUSPENDED' 'no' decrease_user_value "$user" '$SUSPENDED_DB' # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_db_bases b/bin/v_unsuspend_db_bases index ee53f3b95..9827e7399 100755 --- a/bin/v_unsuspend_db_bases +++ b/bin/v_unsuspend_db_bases @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/db.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking db system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/db.conf" +conf="$USER_DATA/db.conf" # Defining fileds to select field='$DB' @@ -54,7 +53,7 @@ databases=$(db_clear_search) # Starting suspend loop for database in $databases; do - $V_BIN/v_unsuspend_db_base "$user" "$database" + $BIN/v_unsuspend_db_base "$user" "$database" done @@ -63,6 +62,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_dns_domain b/bin/v_unsuspend_dns_domain index ca92ee0db..fe791ccfa 100755 --- a/bin/v_unsuspend_dns_domain +++ b/bin/v_unsuspend_dns_domain @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,13 +28,13 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'dns' @@ -64,9 +63,9 @@ update_domain_value 'dns' '$SUSPENDED' 'no' decrease_user_value "$user" '$SUSPENDED_DNS' # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_dns_domains b/bin/v_unsuspend_dns_domains index 82909688a..3b45fef10 100755 --- a/bin/v_unsuspend_dns_domains +++ b/bin/v_unsuspend_dns_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking dns system is enabled is_system_enabled 'DNS_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/dns.conf" +conf="$USER_DATA/dns.conf" # Defining fileds to select field='$DOMAIN' @@ -55,7 +54,7 @@ domains=$(dom_clear_search) # Starting unsuspend loop for domain in $domains; do - $V_BIN/v_unsuspend_dns_domain "$user" "$domain" + $BIN/v_unsuspend_dns_domain "$user" "$domain" done @@ -64,9 +63,9 @@ done #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'dns' +$BIN/v_restart_dns # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_mail_domain b/bin/v_unsuspend_mail_domain index 5e836ae76..d6ee683da 100755 --- a/bin/v_unsuspend_mail_domain +++ b/bin/v_unsuspend_mail_domain @@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -30,16 +29,16 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user is active -is_user_suspended +is_object_suspended 'user' 'USER' "$user" # Checking domain is_domain_valid 'mail' @@ -53,7 +52,7 @@ is_domain_value_exist 'mail' '$SUSPENDED' #----------------------------------------------------------# # Add symbolic link -ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/ +ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ #----------------------------------------------------------# @@ -64,6 +63,6 @@ ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/ update_domain_value 'mail' '$SUSPENDED' 'no' # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_mail_domains b/bin/v_unsuspend_mail_domains index 3957219df..d7ec3d25f 100755 --- a/bin/v_unsuspend_mail_domains +++ b/bin/v_unsuspend_mail_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking dns system is enabled is_system_enabled 'MAIL_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/mail.conf" +conf="$USER_DATA/mail.conf" # Defining fileds to select field='$DOMAIN' @@ -55,7 +54,7 @@ domains=$(dom_clear_search) # Starting unsuspend loop for domain in $domains; do - $V_BIN/v_unsuspend_mail_domain "$user" "$domain" + $BIN/v_unsuspend_mail_domain "$user" "$domain" done @@ -64,6 +63,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_user b/bin/v_unsuspend_user index a72293f32..ed7f5f0f8 100755 --- a/bin/v_unsuspend_user +++ b/bin/v_unsuspend_user @@ -13,9 +13,8 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,10 +25,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking user admin if [ "$user" = 'admin' ]; then @@ -46,12 +45,12 @@ fi # Unsuspending web domains if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_web_domains $user + $BIN/v_unsuspend_web_domains $user fi # Unsuspending dns domains if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_dns_domains $user + $BIN/v_unsuspend_dns_domains $user fi # Unsuspending mail domains @@ -59,12 +58,12 @@ fi # Unsuspending datbabases if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_db_bases $user + $BIN/v_unsuspend_db_bases $user fi # Unsuspending cron jobs if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $V_BIN/v_unsuspend_cron_jobs $user + $BIN/v_unsuspend_cron_jobs $user fi @@ -73,15 +72,15 @@ fi #----------------------------------------------------------# # Adding task to the vesta pipe -restart_schedule 'cron' -restart_schedule 'web' -restart_schedule 'dns' +$BIN/v_restart_cron +$BIN/v_restart_web +$BIN/v_restart_dns # Changing suspend value update_user_value "$user" '$SUSPENDED' 'no' decrease_user_value 'admin' '$SUSPENDED_USERS' # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_web_domain b/bin/v_unsuspend_web_domain index 4bed74081..ce15bbf9a 100755 --- a/bin/v_unsuspend_web_domain +++ b/bin/v_unsuspend_web_domain @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,13 +28,13 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -50,8 +49,8 @@ is_domain_unsuspended 'web' # Parsing domain values get_domain_values 'web' -tpl_file="$V_WEBTPL/apache_$TPL.tpl" -conf="$V_HOME/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" SUSPENDED='no' # Preparing domain values for the template substitution @@ -63,23 +62,23 @@ add_web_config # Check ssl if [ "$SSL" = 'yes' ]; then - tpl_file="$V_WEBTPL/apache_$TPL.stpl" - conf="$V_HOME/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" del_web_config add_web_config fi # Checking nginx if [ ! -z "$NGINX" ]; then - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl" - conf="$V_HOME/$user/conf/web/nginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" del_web_config add_web_config if [ "$SSL" = 'yes' ]; then proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;" - tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl" - conf="$V_HOME/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" del_web_config add_web_config fi @@ -95,9 +94,9 @@ update_domain_value 'web' '$SUSPENDED' 'no' decrease_user_value "$user" '$SUSPENDED_WEB' # Adding task to the vesta pipe -restart_schedule 'web' +$BIN/v_restart_web # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_unsuspend_web_domains b/bin/v_unsuspend_web_domains index 6c6c2f7e2..3fd495402 100755 --- a/bin/v_unsuspend_web_domains +++ b/bin/v_unsuspend_web_domains @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/domain.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,14 +40,14 @@ is_user_valid #----------------------------------------------------------# # Defining fileds to select -conf="$V_USERS/$user/web.conf" +conf="$USER_DATA/web.conf" field='$DOMAIN' search_string="SUSPENDED='yes'" domains=$(dom_clear_search) # Starting unsuspend loop for domain in $domains; do - $V_BIN/v_unsuspend_web_domain "$user" "$domain" + $BIN/v_unsuspend_web_domain "$user" "$domain" done @@ -57,6 +56,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_db_base_disk b/bin/v_update_db_base_disk index a405b5d2a..0fc0491da 100755 --- a/bin/v_update_db_base_disk +++ b/bin/v_update_db_base_disk @@ -14,10 +14,9 @@ user=$1 database=$2 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -28,13 +27,13 @@ source $V_FUNC/db.func check_args '2' "$#" 'user db_name' # Checking argument format -format_validation 'user' 'database' +validate_format 'user' 'database' # Checking web system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking db existance is_db_valid @@ -72,10 +71,9 @@ fi update_db_base_value '$U_DISK' "$disk_usage" # Recalculating user disk space -disk_size=$(get_usr_disk) -update_user_value "$user" '$U_DISK' "$disk_size" +recalc_user_disk_usage # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_db_bases_disk b/bin/v_update_db_bases_disk index 3f1dca33b..b433a5b2f 100755 --- a/bin/v_update_db_bases_disk +++ b/bin/v_update_db_bases_disk @@ -13,10 +13,9 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/db.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/db.sh #----------------------------------------------------------# @@ -27,13 +26,13 @@ source $V_FUNC/db.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking web system is enabled is_system_enabled 'DB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,7 +40,7 @@ is_user_valid #----------------------------------------------------------# # Defining config -conf="$V_USERS/$user/db.conf" +conf="$USER_DATA/db.conf" # Defining fileds to select field='$DB' @@ -76,10 +75,9 @@ done #----------------------------------------------------------# # Recalculating user disk space -disk_size=$(get_usr_disk) -update_user_value "$user" '$U_DISK' "$disk_size" +recalc_user_disk_usage # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_sys_ip b/bin/v_update_sys_ip index d92808b43..667afa73b 100755 --- a/bin/v_update_sys_ip +++ b/bin/v_update_sys_ip @@ -16,11 +16,10 @@ user=${1-admin} ip_status=${2-shared} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf # include for internal func -source $V_FUNC/shared.func -source $V_FUNC/ip.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf # include for internal func +source $VESTA/func/shared.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -32,13 +31,13 @@ check_args '0' "$#" '[user] [ip_status]' # Checking user if [ ! -z "$1" ]; then - format_validation 'user' - is_user_valid "$user" + validate_format 'user' + is_object_valid 'user' 'USER' "$user" "$user" fi # Checking ip_status if [ ! -z "$2" ]; then - format_validation 'ip_status' + validate_format 'ip_status' fi @@ -51,7 +50,7 @@ ip_list=$(/sbin/ifconfig |grep 'inet addr:'|cut -f 2 -d :|\ cut -f 1 -d ' '| grep -v 127.0.0.1) # Get vesta registered ip list -vesta_ip_list=$(ls $V_IPS/) +vesta_ip_list=$(ls $VESTA/data/ips/) # Defining config paths conf='/etc/httpd/conf.d/vesta.conf' @@ -96,10 +95,10 @@ increase_user_value "$user" '$IP_OWNED' # Adding task to the vesta pipe if [ "$web_restart" = 'yes' ]; then - restart_schedule 'web' + $BIN/v_restart_web fi # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_sys_queue b/bin/v_update_sys_queue index ab2f4e6cb..addebcd2c 100755 --- a/bin/v_update_sys_queue +++ b/bin/v_update_sys_queue @@ -13,46 +13,40 @@ # Variable&Function # #----------------------------------------------------------# # Argument defenition -pipe=$1 +queue=$1 # Importing system enviroment as we run this script # mostly by cron wich not read it by itself source /etc/profile.d/vesta.sh # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh # Export PATH for cron -PATH=$PATH:$V_BIN +PATH=$PATH:$BIN # Defining pipe functions restart_pipe() { - for service in $(cat $V_QUEUE/restart.pipe |awk '!x[$0]++'); do - v_restart_$service - done - echo > $V_QUEUE/restart.pipe + bash $VESTA/data/queue/restart.pipe + rm $VESTA/data/queue/restart.pipe + touch $VESTA/data/queue/restart.pipe } stats_pipe() { - bash $V_QUEUE/stats.pipe + bash $VESTA/data/queue/stats.pipe } disk_pipe() { - bash $V_QUEUE/disk.pipe + bash $VESTA/data/queue/disk.pipe } traff_pipe() { - bash $V_QUEUE/traffic.pipe + bash $VESTA/data/queue/traffic.pipe } backup_pipe() { - for user in $(cat $V_QUEUE/backup.pipe |awk '!x[$0]++' ); do - sed -i "/^$user$/d" $V_QUEUE/backup.pipe - v_backup_user $user - # Send notification to user - done + bash $VESTA/data/queue/backup.pip } @@ -62,23 +56,20 @@ backup_pipe() { #----------------------------------------------------------# # Checking arg number -check_args '1' "$#" 'pipe' - -# Checking argument format -format_validation 'pipe' +check_args '1' "$#" 'queue' #----------------------------------------------------------# # Action # #----------------------------------------------------------# -case $pipe in +case $queue in restart) restart_pipe ;; stats) stats_pipe ;; backup) backup_pipe ;; disk) disk_pipe ;; traffic) traff_pipe ;; - *) check_args '1' '0' 'pipe' + *) check_args '1' '0' 'queue' esac @@ -87,6 +78,6 @@ esac #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_sys_rrd b/bin/v_update_sys_rrd index c69f57b8b..ddf26ea0a 100755 --- a/bin/v_update_sys_rrd +++ b/bin/v_update_sys_rrd @@ -16,20 +16,19 @@ source /etc/profile.d/vesta.sh # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh # Another workaround for cron enviroment -PATH="$PATH:$V_BIN" +PATH="$PATH:$BIN" export PATH # Argument defenition period=$1 # Checking rrddir -if [ ! -d "$V_RRD" ]; then - mkdir -p $V_RRD +if [ ! -d "$RRD" ]; then + mkdir -p $RRD fi @@ -38,23 +37,23 @@ fi #----------------------------------------------------------# # Updateing system stats -$V_BIN/v_update_sys_rrd_la $period -$V_BIN/v_update_sys_rrd_net $period -$V_BIN/v_update_sys_rrd_mem $period -$V_BIN/v_update_sys_rrd_ssh $period +$BIN/v_update_sys_rrd_la $period +$BIN/v_update_sys_rrd_net $period +$BIN/v_update_sys_rrd_mem $period +$BIN/v_update_sys_rrd_ssh $period # Updating web stats if [ "$WEB_SYSTEM" = 'apache' ]; then - $V_BIN/v_update_sys_rrd_httpd $period + $BIN/v_update_sys_rrd_httpd $period fi if [ "$PROXY_SYSTEM" = 'nginx' ]; then - $V_BIN/v_update_sys_rrd_nginx $period + $BIN/v_update_sys_rrd_nginx $period fi # Updating ftp stats if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then - $V_BIN/v_update_sys_rrd_ftp $period + $BIN/v_update_sys_rrd_ftp $period fi # Updating db stats @@ -62,8 +61,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then for type in ${DB_SYSTEM//,/ }; do # Switching on db type case $type in - mysql) $V_BIN/v_update_sys_rrd_mysql $period ;; - pgsql) $V_BIN/v_update_sys_rrd_pgsql $period ;; + mysql) $BIN/v_update_sys_rrd_mysql $period ;; + pgsql) $BIN/v_update_sys_rrd_pgsql $period ;; esac done fi @@ -74,6 +73,6 @@ fi #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_sys_rrd_ftp b/bin/v_update_sys_rrd_ftp index 506926c8d..5efe51781 100755 --- a/bin/v_update_sys_rrd_ftp +++ b/bin/v_update_sys_rrd_ftp @@ -14,8 +14,7 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf +source $VESTA/conf/vesta.conf #----------------------------------------------------------# @@ -32,14 +31,14 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/ftp" ]; then - mkdir $V_RRD/ftp +if [ ! -d "$RRD/ftp" ]; then + mkdir $RRD/ftp fi # Checking database -if [ ! -e "$V_RRD/ftp/ftp.rrd" ]; then +if [ ! -e "$RRD/ftp/ftp.rrd" ]; then # Adding database - rrdtool create $V_RRD/ftp/ftp.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/ftp/ftp.rrd --step $RRD_STEP \ DS:A:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ @@ -58,11 +57,11 @@ if [ -z "$update" ]; then grep -v root|wc -l) # Updating rrd database - rrdtool update $V_RRD/ftp/ftp.rrd N:$a + rrdtool update $RRD/ftp/ftp.rrd N:$a fi # Updating rrd graph -rrdtool graph $V_RRD/ftp/$period-ftp.png \ +rrdtool graph $RRD/ftp/$period-ftp.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -79,12 +78,12 @@ rrdtool graph $V_RRD/ftp/$period-ftp.png \ -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:a=$V_RRD/ftp/ftp.rrd:A:AVERAGE \ + DEF:a=$RRD/ftp/ftp.rrd:A:AVERAGE \ COMMENT:'\r' \ LINE1:a#fefda0:"Users " \ GPRINT:a:'LAST:Current\:''%8.0lf' \ GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? #----------------------------------------------------------# diff --git a/bin/v_update_sys_rrd_httpd b/bin/v_update_sys_rrd_httpd index 2b47f320d..e64b4d5c3 100755 --- a/bin/v_update_sys_rrd_httpd +++ b/bin/v_update_sys_rrd_httpd @@ -14,7 +14,6 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf #----------------------------------------------------------# @@ -32,14 +31,14 @@ esac # Checking directory -if [ ! -d "$V_RRD/web" ]; then - mkdir $V_RRD/web +if [ ! -d "$RRD/web" ]; then + mkdir $RRD/web fi # Checking database -if [ ! -e "$V_RRD/web/httpd.rrd" ]; then +if [ ! -e "$RRD/web/httpd.rrd" ]; then # Adding database - rrdtool create $V_RRD/web/httpd.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/web/httpd.rrd --step $RRD_STEP \ DS:A:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ @@ -63,11 +62,11 @@ if [ -z "$update" ]; then a=$((active + idle)) # Updating rrd database - rrdtool update $V_RRD/web/httpd.rrd N:$a + rrdtool update $RRD/web/httpd.rrd N:$a fi # Updating rrd graph -rrdtool graph $V_RRD/web/$period-httpd.png \ +rrdtool graph $RRD/web/$period-httpd.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -84,12 +83,12 @@ rrdtool graph $V_RRD/web/$period-httpd.png \ -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:a=$V_RRD/web/httpd.rrd:A:AVERAGE \ + DEF:a=$RRD/web/httpd.rrd:A:AVERAGE \ COMMENT:'\r' \ LINE1:a#fefda0:"Connections " \ GPRINT:a:'LAST:Current\:''%8.0lf' \ GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? #----------------------------------------------------------# diff --git a/bin/v_update_sys_rrd_la b/bin/v_update_sys_rrd_la index d4e60a9ad..687604735 100755 --- a/bin/v_update_sys_rrd_la +++ b/bin/v_update_sys_rrd_la @@ -14,7 +14,6 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf #----------------------------------------------------------# @@ -31,14 +30,14 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/la" ]; then - mkdir $V_RRD/la +if [ ! -d "$RRD/la" ]; then + mkdir $RRD/la fi # Checking database -if [ ! -e "$V_RRD/la/la.rrd" ]; then +if [ ! -e "$RRD/la/la.rrd" ]; then # Adding database - rrdtool create $V_RRD/la/la.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/la/la.rrd --step $RRD_STEP \ DS:LA:GAUGE:600:U:U \ DS:PR:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:600 \ @@ -58,11 +57,11 @@ if [ -z "$update" ]; then pr=$(echo "$loadavg"|cut -f 4 -d ' '|cut -f 2 -d /) # Updating rrd database - rrdtool update $V_RRD/la/la.rrd N:${la//./}:$pr + rrdtool update $RRD/la/la.rrd N:${la//./}:$pr fi # Updating graph -rrdtool graph $V_RRD/la/$period-la.png \ +rrdtool graph $RRD/la/$period-la.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -79,8 +78,8 @@ rrdtool graph $V_RRD/la/$period-la.png \ -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:la=$V_RRD/la/la.rrd:LA:AVERAGE \ - DEF:pr=$V_RRD/la/la.rrd:PR:AVERAGE \ + DEF:la=$RRD/la/la.rrd:LA:AVERAGE \ + DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \ COMMENT:'\r' \ AREA:la#C8EA2E:"LA * 100"\ GPRINT:la:'LAST: Current\:''%8.0lf' \ @@ -89,7 +88,7 @@ rrdtool graph $V_RRD/la/$period-la.png \ LINE1:pr#1c74cd:"Procs # " \ GPRINT:pr:'LAST:Current\:''%8.0lf' \ GPRINT:pr:'MIN:Min\:''%8.0lf' \ - GPRINT:pr:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:pr:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? #----------------------------------------------------------# diff --git a/bin/v_update_sys_rrd_mem b/bin/v_update_sys_rrd_mem index 124ba3c42..4c901938a 100755 --- a/bin/v_update_sys_rrd_mem +++ b/bin/v_update_sys_rrd_mem @@ -14,7 +14,6 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf #----------------------------------------------------------# @@ -31,14 +30,14 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/mem" ]; then - mkdir $V_RRD/mem +if [ ! -d "$RRD/mem" ]; then + mkdir $RRD/mem fi # Checking database -if [ ! -e "$V_RRD/mem/mem.rrd" ]; then +if [ ! -e "$RRD/mem/mem.rrd" ]; then # Adding database - rrdtool create $V_RRD/mem/mem.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/mem/mem.rrd --step $RRD_STEP \ DS:RAM:GAUGE:600:U:U \ DS:SWAP:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:600 \ @@ -58,11 +57,11 @@ if [ -z "$update" ]; then swap=$(echo "$mem" |awk '{print $3}'|tail -n1) # Updating rrd - rrdtool update $V_RRD/mem/mem.rrd N:$ram:$swap + rrdtool update $RRD/mem/mem.rrd N:$ram:$swap fi # Updating rrd graph -rrdtool graph $V_RRD/mem/$period-mem.png \ +rrdtool graph $RRD/mem/$period-mem.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -79,8 +78,8 @@ rrdtool graph $V_RRD/mem/$period-mem.png \ -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:ram=$V_RRD/mem/mem.rrd:RAM:AVERAGE \ - DEF:swap=$V_RRD/mem/mem.rrd:SWAP:AVERAGE \ + DEF:ram=$RRD/mem/mem.rrd:RAM:AVERAGE \ + DEF:swap=$RRD/mem/mem.rrd:SWAP:AVERAGE \ COMMENT:'\r' \ AREA:ram#867995:"RAM "\ GPRINT:ram:'LAST: Current\:''%8.0lf' \ @@ -89,7 +88,7 @@ rrdtool graph $V_RRD/mem/$period-mem.png \ LINE1:swap#f57900:"SWAP" \ GPRINT:swap:'LAST:Current\:''%8.0lf' \ GPRINT:swap:'MIN:Min\:''%8.0lf' \ - GPRINT:swap:'MAX:Max\:''%8.0lf\j' >/dev/null 2> /dev/null; result=$? + GPRINT:swap:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? #----------------------------------------------------------# diff --git a/bin/v_update_sys_rrd_mysql b/bin/v_update_sys_rrd_mysql index 7e7238c97..b5d269f99 100755 --- a/bin/v_update_sys_rrd_mysql +++ b/bin/v_update_sys_rrd_mysql @@ -14,8 +14,7 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -32,12 +31,12 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/db" ]; then - mkdir $V_RRD/db +if [ ! -d "$RRD/db" ]; then + mkdir $RRD/db fi # Parsing db hosts -conf="$V_DB/mysql.conf" +conf="$VESTA/conf/mysql.conf" fields='$HOST' nohead=1 hosts=$(shell_list) @@ -47,15 +46,15 @@ if [ 0 -eq "$check_row" ]; then fi # Parsing excludes -for exclude in $(echo ${V_RRD_MYSQL_EXCLUDE//,/ }); do +for exclude in $(echo ${RRD_MYSQL_EXCLUDE//,/ }); do hosts=$(echo "$hosts" |grep -vw "$exclude" ) done for host in $hosts; do # Checking database - if [ ! -e "$V_RRD/db/mysql_$host.rrd" ]; then + if [ ! -e "$RRD/db/mysql_$host.rrd" ]; then # Adding database - rrdtool create $V_RRD/db/mysql_$host.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/db/mysql_$host.rrd --step $RRD_STEP \ DS:A:COUNTER:600:U:U \ DS:S:COUNTER:600:U:U \ RRA:AVERAGE:0.5:1:600 \ @@ -80,12 +79,12 @@ for host in $hosts; do if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ] then echo "Error: config is broken" - log_event 'debug' "$E_PARSING $V_EVENT" + log_event 'debug' "$E_PARSING $EVENT" exit $E_PARSING fi # Parsing data - status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?" + status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?" if [ '0' -ne "$code" ]; then active=0 slow=0 @@ -95,11 +94,11 @@ for host in $hosts; do fi # Updating rrd - rrdtool update $V_RRD/db/mysql_$host.rrd N:$active:$slow + rrdtool update $RRD/db/mysql_$host.rrd N:$active:$slow fi # Updating daily graph - rrdtool graph $V_RRD/db/$period-mysql_$host.png \ + rrdtool graph $RRD/db/$period-mysql_$host.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -116,8 +115,8 @@ for host in $hosts; do -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:a=$V_RRD/db/mysql_$host.rrd:A:AVERAGE \ - DEF:s=$V_RRD/db/mysql_$host.rrd:S:AVERAGE \ + DEF:a=$RRD/db/mysql_$host.rrd:A:AVERAGE \ + DEF:s=$RRD/db/mysql_$host.rrd:S:AVERAGE \ COMMENT:'\r' \ LINE1:a#fefda0:"Queries"\ GPRINT:a:'LAST: Current\:''%8.0lf' \ @@ -126,7 +125,7 @@ for host in $hosts; do AREA:s#f57900:"Slow " \ GPRINT:s:'LAST:Current\:''%8.0lf' \ GPRINT:s:'MIN:Min\:''%8.0lf' \ - GPRINT:s:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:s:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? if [ "$result" -ne 0 ]; then exit $E_RRD diff --git a/bin/v_update_sys_rrd_net b/bin/v_update_sys_rrd_net index 0c48a46b9..35b6d6886 100755 --- a/bin/v_update_sys_rrd_net +++ b/bin/v_update_sys_rrd_net @@ -14,7 +14,6 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf #----------------------------------------------------------# @@ -31,23 +30,23 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/net" ]; then - mkdir $V_RRD/net +if [ ! -d "$RRD/net" ]; then + mkdir $RRD/net fi # Parsing network interfaces ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g") # Parsing excludes -for exclude in $(echo ${V_RRD_IFACE_EXCLUDE//,/ }); do +for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do ifaces=$(echo "$ifaces" |grep -vw "$exclude" ) done for iface in $ifaces; do # Checking database - if [ ! -e "$V_RRD/net/$iface.rrd" ]; then + if [ ! -e "$RRD/net/$iface.rrd" ]; then # Adding database - rrdtool create $V_RRD/net/$iface.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \ DS:RX:COUNTER:600:U:U \ DS:TX:COUNTER:600:U:U \ RRA:AVERAGE:0.5:1:600 \ @@ -67,11 +66,11 @@ for iface in $ifaces; do tx=$(echo "$raw_iface" |awk '{print $10}') # Updating rrd database - rrdtool update $V_RRD/net/$iface.rrd N:$rx:$tx + rrdtool update $RRD/net/$iface.rrd N:$rx:$tx fi # Updating rrd graph - rrdtool graph $V_RRD/net/$period-$iface.png \ + rrdtool graph $RRD/net/$period-$iface.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -88,8 +87,8 @@ for iface in $ifaces; do -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:inoctets=$V_RRD/net/$iface.rrd:RX:AVERAGE \ - DEF:outoctets=$V_RRD/net/$iface.rrd:TX:AVERAGE \ + DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \ + DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \ "CDEF:in=inoctets,8,*" \ "CDEF:out=outoctets,8,*" \ COMMENT:'\r' \ @@ -100,7 +99,7 @@ for iface in $ifaces; do LINE1:out#1c74cd:"Output (tx)" \ GPRINT:out:'LAST:Current\:''%8.0lf' \ GPRINT:out:'MIN:Min\:''%8.0lf' \ - GPRINT:out:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? if [ "$result" -ne 0 ]; then exit $E_RRD diff --git a/bin/v_update_sys_rrd_nginx b/bin/v_update_sys_rrd_nginx index eafb47a10..a75d6f232 100755 --- a/bin/v_update_sys_rrd_nginx +++ b/bin/v_update_sys_rrd_nginx @@ -14,7 +14,6 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf #----------------------------------------------------------# @@ -31,14 +30,14 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/web" ]; then - mkdir $V_RRD/web +if [ ! -d "$RRD/web" ]; then + mkdir $RRD/web fi # Checking database -if [ ! -e "$V_RRD/web/nginx.rrd" ]; then +if [ ! -e "$RRD/web/nginx.rrd" ]; then # Adding database - rrdtool create $V_RRD/web/nginx.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/web/nginx.rrd --step $RRD_STEP \ DS:A:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ @@ -55,11 +54,11 @@ if [ -z "$update" ]; then a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ') # Updating rrd database - rrdtool update $V_RRD/web/nginx.rrd N:$a + rrdtool update $RRD/web/nginx.rrd N:$a fi # Updating rrd graph -rrdtool graph $V_RRD/web/$period-nginx.png \ +rrdtool graph $RRD/web/$period-nginx.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -76,12 +75,12 @@ rrdtool graph $V_RRD/web/$period-nginx.png \ -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:a=$V_RRD/web/nginx.rrd:A:AVERAGE \ + DEF:a=$RRD/web/nginx.rrd:A:AVERAGE \ COMMENT:'\r' \ LINE1:a#fefda0:"Connections " \ GPRINT:a:'LAST:Current\:''%8.0lf' \ GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? #----------------------------------------------------------# diff --git a/bin/v_update_sys_rrd_pgsql b/bin/v_update_sys_rrd_pgsql index 278b7023a..0da1f6d99 100755 --- a/bin/v_update_sys_rrd_pgsql +++ b/bin/v_update_sys_rrd_pgsql @@ -14,8 +14,7 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf -source $V_FUNC/shared.func +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -32,12 +31,12 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/db" ]; then - mkdir $V_RRD/db +if [ ! -d "$RRD/db" ]; then + mkdir $RRD/db fi # Parsing db hosts -conf="$V_DB/pgsql.conf" +conf="$VESTA/conf/pgsql.conf" fields='$HOST' nohead=1 hosts=$(shell_list) @@ -47,15 +46,15 @@ if [ 0 -eq "$check_row" ]; then fi # Parsing excludes -for exclude in $(echo ${V_RRD_PGSQL_EXCLUDE//,/ }); do +for exclude in $(echo ${RRD_PGSQL_EXCLUDE//,/ }); do hosts=$(echo "$hosts" |grep -vw "$exclude" ) done for host in $hosts; do # Checking database - if [ ! -e "$V_RRD/db/pgsql_$host.rrd" ]; then + if [ ! -e "$RRD/db/pgsql_$host.rrd" ]; then # Adding database - rrdtool create $V_RRD/db/pgsql_$host.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/db/pgsql_$host.rrd --step $RRD_STEP \ DS:A:GAUGE:600:U:U \ DS:T:COUNTER:600:U:U \ RRA:AVERAGE:0.5:1:600 \ @@ -82,7 +81,7 @@ for host in $hosts; do if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ] then echo "Error: config is broken" - log_event 'debug' "$E_PARSING $V_EVENT" + log_event 'debug' "$E_PARSING $EVENT" exit $E_PARSING fi @@ -101,11 +100,11 @@ for host in $hosts; do # Updating rrd export PGPASSWORD='pgsql' - rrdtool update $V_RRD/db/pgsql_$host.rrd N:$active:$trans + rrdtool update $RRD/db/pgsql_$host.rrd N:$active:$trans fi # Updating rrd graph - rrdtool graph $V_RRD/db/$period-pgsql_$host.png \ + rrdtool graph $RRD/db/$period-pgsql_$host.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -122,8 +121,8 @@ for host in $hosts; do -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:a=$V_RRD/db/pgsql_$host.rrd:A:AVERAGE \ - DEF:t=$V_RRD/db/pgsql_$host.rrd:T:AVERAGE \ + DEF:a=$RRD/db/pgsql_$host.rrd:A:AVERAGE \ + DEF:t=$RRD/db/pgsql_$host.rrd:T:AVERAGE \ COMMENT:'\r' \ LINE1:a#fefda0:"Queries "\ GPRINT:a:'LAST: Current\:''%8.0lf' \ @@ -132,7 +131,7 @@ for host in $hosts; do LINE2:t#f57900:"Transactions" \ GPRINT:t:'LAST:Current\:''%8.0lf' \ GPRINT:t:'MIN:Min\:''%8.0lf' \ - GPRINT:t:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:t:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? if [ "$result" -ne 0 ]; then exit $E_RRD diff --git a/bin/v_update_sys_rrd_ssh b/bin/v_update_sys_rrd_ssh index a577b78c1..b99d431a3 100755 --- a/bin/v_update_sys_rrd_ssh +++ b/bin/v_update_sys_rrd_ssh @@ -14,7 +14,6 @@ update=$1 period=${1-daily} # Importing variables -source $VESTA/conf/vars.conf #----------------------------------------------------------# @@ -31,14 +30,14 @@ case $period in esac # Checking directory -if [ ! -d "$V_RRD/ssh" ]; then - mkdir $V_RRD/ssh +if [ ! -d "$RRD/ssh" ]; then + mkdir $RRD/ssh fi # Checking database -if [ ! -e "$V_RRD/ssh/ssh.rrd" ]; then +if [ ! -e "$RRD/ssh/ssh.rrd" ]; then # Adding database - rrdtool create $V_RRD/ssh/ssh.rrd --step $V_RRD_STEP \ + rrdtool create $RRD/ssh/ssh.rrd --step $RRD_STEP \ DS:A:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:600 \ RRA:AVERAGE:0.5:6:700 \ @@ -56,11 +55,11 @@ if [ -z "$update" ]; then a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l) # Updating rrd database - rrdtool update $V_RRD/ssh/ssh.rrd N:$a + rrdtool update $RRD/ssh/ssh.rrd N:$a fi # Updating daily graph -rrdtool graph $V_RRD/ssh/$period-ssh.png \ +rrdtool graph $RRD/ssh/$period-ssh.png \ --imgformat PNG \ --height="120" \ --width="440" \ @@ -77,12 +76,12 @@ rrdtool graph $V_RRD/ssh/$period-ssh.png \ -c "MGRID#AAAAAA" \ -c "FRAME#202020" \ -c "ARROW#FFFFFF" \ - DEF:a=$V_RRD/ssh/ssh.rrd:A:AVERAGE \ + DEF:a=$RRD/ssh/ssh.rrd:A:AVERAGE \ COMMENT:'\r' \ LINE1:a#fefda0:"Users " \ GPRINT:a:'LAST:Current\:''%8.0lf' \ GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' >/dev/null 2>/dev/null; result=$? + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? #----------------------------------------------------------# diff --git a/bin/v_update_sys_vesta b/bin/v_update_sys_vesta index a749ade65..90d1626e7 100755 --- a/bin/v_update_sys_vesta +++ b/bin/v_update_sys_vesta @@ -18,9 +18,8 @@ updates='' source /etc/profile.d/vesta.sh # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -40,12 +39,12 @@ if [ "$version" != "$VERSION" ]; then # Downloading version tree upd_host="yum.vestacp.com" wget -O "/tmp/versions" http://$V_UPD_HOST/upd_scripts/version_tree.txt \ - >/dev/null 2>&1 + &>/dev/null # Checking download result if [ "$?" -ne "0" ]; then echo "Error: version tree update failed" - log_event 'debug' "$E_UPDATE $V_EVENT" + log_event 'debug' "$E_UPDATE $EVENT" exit $E_UPDATE fi @@ -82,25 +81,25 @@ if [ "$version" != "$VERSION" ]; then # Executing update scripts if [ ! -z "$updates" ]; then - mkdir $V_BIN/updates >/dev/null 2>&1 + mkdir $BIN/updates &>/dev/null for update in $updates; do - wget -O $V_BIN/updates/$update.sh \ - http://$V_UPD_HOST/upd_scripts/$update.sh >/dev/null 2>&1 + wget -O $BIN/updates/$update.sh \ + http://$V_UPD_HOST/upd_scripts/$update.sh &>/dev/null # Checking download result if [ "$?" -ne "0" ]; then echo "Error: version tree update failed" - log_event 'debug' "$E_UPDATE $V_EVENT" + log_event 'debug' "$E_UPDATE $EVENT" exit $E_UPDATE fi - bash $V_BIN/updates/$update.sh + bash $BIN/updates/$update.sh done - rm -rf $V_BIN/updates + rm -rf $BIN/updates fi # Updating config version - sed -i "s/VERSION='$VERSION'/VERSION='$version'/g" $V_CONF/vesta.conf + sed -i "s/VERSION='$VERSION'/VERSION='$version'/g" $VESTA/conf/vesta.conf fi @@ -109,6 +108,6 @@ fi #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_user_backups b/bin/v_update_user_backups index 26b52069c..4cd82bff9 100755 --- a/bin/v_update_user_backups +++ b/bin/v_update_user_backups @@ -10,9 +10,8 @@ #----------------------------------------------------------# # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh # Argument defenition user=$1 @@ -158,11 +157,11 @@ EOF init_ftp_variables() { # Checking config - source $V_CONF/ftp.backup.conf + source $VESTA/conf/ftp.backup.conf if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\ [ -z "$BPATH" ]; then echo "Error: Parsing error" - log_event 'debug' "$E_PARSING $V_EVENT" + log_event 'debug' "$E_PARSING $EVENT" exit $E_PARSING fi } @@ -175,7 +174,7 @@ check_ftp_connection(){ rm $ftmpdir" if [ ! -z "$(ftpc "$command")" ] ; then echo "Error: FTP error" - log_event 'debug' "$E_FTP $V_EVENT" + log_event 'debug' "$E_FTP $EVENT" exit $E_FTP fi } @@ -193,15 +192,15 @@ check_args '1' "$#" 'user' is_system_enabled 'BACKUP_SYSTEM' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking load averages la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.') -if [ "$la" -ge "$V_BACKUP_LA_LIMIT" ]; then - log_event 'debug' "$E_LA $V_EVENT" +if [ "$la" -ge "$BACKUP_LA_LIMIT" ]; then + log_event 'debug' "$E_LA $EVENT" exit $E_LA fi @@ -211,22 +210,22 @@ fi #----------------------------------------------------------# # Checking tmp file -tmp_file="$V_USERS/$user/backup.conf_tmp" +tmp_file="$USER_DATA/backup.conf_tmp" if [ -e "$tmp_file" ]; then rm -f $tmp_file fi # Checking local if [ "$type" = 'local' ]; then - backups=$(ls $V_BACKUP |grep "^$user."|sort) + backups=$(ls $BACKUP |grep "^$user."|sort) for backup in $backups; do - get_backup_info $V_BACKUP/$backup $type >> $tmp_file + get_backup_info $BACKUP/$backup $type >> $tmp_file done fi # Checking ftp if [ "$type" = 'ftp' ]; then - tmpdir=$(mktemp -p $V_BACKUP -d) + tmpdir=$(mktemp -p $BACKUP -d) ftmpdir=$(basename $tmpdir) init_ftp_variables check_ftp_connection @@ -236,7 +235,7 @@ if [ "$type" = 'ftp' ]; then cd $tmpdir if [ ! -z "$(ftpc "get $backup")" ]; then echo "Error: FTP transfer error" - log_event 'debug' "$E_FTP $V_EVENT" + log_event 'debug' "$E_FTP $EVENT" exit $E_FTP fi get_backup_info $tmpdir/$backup $type >> $tmp_file @@ -248,12 +247,12 @@ fi # Checking both local and ftp if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then - tmpdir=$(mktemp -p $V_BACKUP -d) + tmpdir=$(mktemp -p $BACKUP -d) ftmpdir=$(basename $tmpdir) init_ftp_variables check_ftp_connection ftp_backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") - local_backups=$(ls $V_BACKUP/ |grep "^$user." |sort) + local_backups=$(ls $BACKUP/ |grep "^$user." |sort) backups=$(echo -e "$local_backups\n$ftp_backups" |\ sort |uniq -c | awk '{print $1" "$2}') @@ -263,29 +262,29 @@ if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then cd $tmpdir if [ ! -z "$(ftpc "get $backup")" ]; then echo "Error: FTP transfer error" - log_event 'debug' "$E_FTP $V_EVENT" + log_event 'debug' "$E_FTP $EVENT" exit $E_FTP fi get_backup_info $tmpdir/$backup ftp >> $tmp_file rm -f $tmpdir/$backup else - get_backup_info $V_BACKUP/$backup local >> $tmp_file + get_backup_info $BACKUP/$backup local >> $tmp_file fi done for backup in $(echo "$backups"|grep "^2 "|cut -f 2 -d ' '); do - get_backup_info $V_BACKUP/$backup $type >> $tmp_file + get_backup_info $BACKUP/$backup $type >> $tmp_file done rm -rf $tmpdir fi # Checking if there was any output if [ -e "$tmp_file" ]; then - cat $tmp_file | sort > $V_USERS/$user/backup.conf + cat $tmp_file | sort > $USER_DATA/backup.conf rm $tmp_file else - rm $V_USERS/$user/backup.conf - touch $V_USERS/$user/backup.conf + rm $USER_DATA/backup.conf + touch $USER_DATA/backup.conf fi @@ -294,6 +293,6 @@ fi #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_user_counters b/bin/v_update_user_counters index b091fcf32..28cc9f633 100755 --- a/bin/v_update_user_counters +++ b/bin/v_update_user_counters @@ -13,9 +13,8 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -28,10 +27,10 @@ check_args '0' "$#" 'user' # If user specified if [ ! -z "$user" ]; then # Checking argument format - format_validation 'user' + validate_format 'user' # Checking user - is_user_valid + is_object_valid 'user' 'USER' "$user" fi @@ -90,8 +89,8 @@ for user in $user_list; do fi # Checking ip - for ip in $(ls $V_IPS) ;do - source $V_IPS/$ip + for ip in $(ls $VESTA/data/ips) ;do + source $VESTA/data/ips/$ip if [ "$OWNER" = "$user" ]; then IP_OWNED=$((IP_OWNED + 1)) IP_AVAIL=$((IP_AVAIL + 1)) @@ -101,12 +100,12 @@ for user in $user_list; do fi done if [ "$user" = 'admin' ]; then - IP_AVAIL=$(ls $V_IPS | wc -l) + IP_AVAIL=$(ls $VESTA/data/ips | wc -l) fi # Checking web system U_WEB_DOMAINS=0 - for domain_str in $(cat $V_USERS/$user/web.conf) ;do + for domain_str in $(cat $USER_DATA/web.conf) ;do eval $domain_str U_DISK_WEB=$((U_DISK_WEB + U_DISK)) U_WEB_DOMAINS=$((U_WEB_DOMAINS + 1)) @@ -126,10 +125,10 @@ for user in $user_list; do DISK=$((DISK + U_DISK_WEB)) # Checking dns system - for domain_str in $(cat $V_USERS/$user/dns.conf); do + for domain_str in $(cat $USER_DATA/dns.conf); do eval $domain_str U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1)) - records=$(wc -l $V_USERS/$user/dns/$DOMAIN| cut -f 1 -d ' ') + records=$(wc -l $USER_DATA/dns/$DOMAIN| cut -f 1 -d ' ') U_DNS_RECORDS=$((U_DNS_RECORDS + records)) if [ "$SUSPENDED" = 'yes' ]; then SUSPENDED_DNS=$((SUSPENDED_DNS + 1)) @@ -141,7 +140,7 @@ for user in $user_list; do DISK=$((DISK + U_DISK_MAIL)) # Checking db system - for db_str in $(cat $V_USERS/$user/db.conf); do + for db_str in $(cat $USER_DATA/db.conf); do eval $db_str U_DISK_DB=$((U_DISK_DB + U_DISK)) U_DATABASES=$((U_DATABASES + 1)) @@ -152,7 +151,7 @@ for user in $user_list; do DISK=$((DISK + U_DISK_DB)) # Checking mail system - for cron_str in $(cat $V_USERS/$user/cron.conf);do + for cron_str in $(cat $USER_DATA/cron.conf);do eval $cron_str U_CRON_JOBS=$((U_CRON_JOBS + 1)) if [ "$SUSPENDED" = 'yes' ]; then @@ -195,6 +194,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_user_disk b/bin/v_update_user_disk index b3e612879..6eb88f18e 100755 --- a/bin/v_update_user_disk +++ b/bin/v_update_user_disk @@ -13,9 +13,8 @@ user=$1 # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh #----------------------------------------------------------# @@ -26,10 +25,10 @@ source $V_FUNC/shared.func check_args '1' "$#" 'user' # Checking argument format -format_validation 'user' +validate_format 'user' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" #----------------------------------------------------------# @@ -41,13 +40,13 @@ OLDIFS=$IFS IFS=$(echo -en "\n\b") # Defining directory list -dir_list=$(ls $V_HOME/$user/ |grep -v '^web$' | grep -v '^mail$' |\ +dir_list=$(ls $HOMEDIR/$user/ |grep -v '^web$' | grep -v '^mail$' |\ grep -v '^conf$') # Starting update disk loop disk_usage='0' for dir in $dir_list; do - dir_disk=$(du -shm "$V_HOME/$user/$dir"|cut -f 1 ) + dir_disk=$(du -shm "$HOMEDIR/$user/$dir"|cut -f 1 ) disk_usage=$((disk_usage + dir_disk)) done @@ -63,10 +62,9 @@ update_user_value "$user" '$U_DIR_DISK' "$disk_usage" #----------------------------------------------------------# # Recalculating user disk space -disk_size=$(get_usr_disk) -update_user_value "$user" '$U_DISK' "$disk_size" +recalc_user_disk_usage # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_user_stats b/bin/v_update_user_stats index 9c7ebacee..22a361aa2 100755 --- a/bin/v_update_user_stats +++ b/bin/v_update_user_stats @@ -17,10 +17,9 @@ user=$1 source /etc/profile.d/vesta.sh # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -33,10 +32,10 @@ check_args '0' "$#" 'user' # If user specified if [ ! -z "$user" ]; then # Checking argument format - format_validation 'user' + validate_format 'user' # Checking user - is_user_valid + is_object_valid 'user' 'USER' "$user" fi @@ -55,7 +54,7 @@ fi for user in $user_list; do # Importing user values - source $V_USERS/$user/user.conf + source $USER_DATA/user.conf DATE=$(date -d "$(date +'%m/01') -1day" +%F) # Compiling report string @@ -71,7 +70,7 @@ for user in $user_list; do s="$s U_CRON_JOBS='$U_CRON_JOBS'" # Updating user stats log - stats="$V_USERS/$user/stats.log" + stats="$USER_DATA/stats.log" if [ -e "$stats" ]; then # Checking dublicates check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) @@ -96,6 +95,6 @@ done #----------------------------------------------------------# # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_web_domain_disk b/bin/v_update_web_domain_disk index 51f675745..a2f49c002 100755 --- a/bin/v_update_web_domain_disk +++ b/bin/v_update_web_domain_disk @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,13 +28,13 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -49,7 +48,7 @@ is_domain_suspended 'web' #----------------------------------------------------------# # Defining home directory -home_dir="$V_HOME/$user/web/$domain/" +home_dir="$HOMEDIR/$user/web/$domain/" # Checking home directory exist if [ -e "$home_dir" ]; then @@ -65,10 +64,9 @@ fi update_domain_value 'web' '$U_DISK' "$disk_usage" # Recalculating user disk space -disk_size=$(get_usr_disk) -update_user_value "$user" '$U_DISK' "$disk_size" +recalc_user_disk_usage # Logging -log_event 'system' "$V_EVENT" +log_event "$OK" "$EVENT" exit diff --git a/bin/v_update_web_domain_stat b/bin/v_update_web_domain_stat index 2df513740..1e7d8776f 100755 --- a/bin/v_update_web_domain_stat +++ b/bin/v_update_web_domain_stat @@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" ) domain_idn=$(idn -t --quiet -a "$domain") # Importing variables -source $VESTA/conf/vars.conf -source $V_CONF/vesta.conf -source $V_FUNC/shared.func -source $V_FUNC/domain.func +source $VESTA/conf/vesta.conf +source $VESTA/func/shared.sh +source $VESTA/func/domain.sh #----------------------------------------------------------# @@ -29,13 +28,13 @@ source $V_FUNC/domain.func check_args '2' "$#" 'user domain' # Checking argument format -format_validation 'user' 'domain' +validate_format 'user' 'domain' # Checking web system is enabled is_system_enabled 'WEB_SYSTEM' # Checking user -is_user_valid +is_object_valid 'user' 'USER' "$user" # Checking domain exist is_domain_valid 'web' @@ -54,15 +53,15 @@ is_domain_value_exist 'web' '$STATS' stats=$(get_domain_value 'web' '$STATS') # Checking config -config="$V_HOME/$user/conf/web/$stats.$domain.conf" +config="$HOMEDIR/$user/conf/web/$stats.$domain.conf" if [ ! -e "$config" ]; then echo "Error: Parsing error" - log_event 'debug' "$E_PARSING $V_EVENT" + log_event 'debug' "$E_PARSING $EVENT" exit $E_PARSING fi # Checking statistics directory -dir="$V_HOME/$user/web/$domain/stats" +dir="$HOMEDIR/$user/web/$domain/stats" if [ ! -e "$dir" ]; then mkdir -p $dir fi @@ -102,7 +101,7 @@ build_awstats() { done # Creating index page - cat $V_WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" \ + cat $WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" \ > $dir/index.html # Creating navigation page @@ -111,7 +110,7 @@ build_awstats() { for link in $months; do select_m="$select_m\t