From 10f7097c48a6e72d27d17e73800f501bc8613dff Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Sat, 1 Jun 2013 14:25:44 +0300 Subject: [PATCH] implemented scheduled restart --- bin/v-add-cron-job | 7 ++++--- bin/v-add-cron-report | 2 +- bin/v-add-remote-dns-domain | 6 +++--- bin/v-add-remote-dns-record | 4 ++-- bin/v-add-web-domain-proxy | 2 +- bin/v-add-web-domain-ssl | 2 +- bin/v-change-cron-job | 2 +- bin/v-change-dns-domain-soa | 2 +- bin/v-change-dns-domain-ttl | 2 +- bin/v-change-remote-dns-domain-exp | 2 +- bin/v-change-remote-dns-domain-soa | 2 +- bin/v-change-remote-dns-domain-ttl | 2 +- bin/v-change-sys-ip-nat | 2 +- bin/v-delete-cron-job | 2 +- bin/v-delete-cron-reports | 2 +- bin/v-delete-dns-domain | 2 +- bin/v-delete-dns-domains | 2 +- bin/v-delete-dns-domains-src | 2 +- bin/v-delete-remote-dns-domain | 2 +- bin/v-delete-remote-dns-domains | 4 ++-- bin/v-delete-remote-dns-record | 2 +- bin/v-insert-dns-record | 10 ++++++++-- bin/v-insert-dns-records | 10 ++++++++-- bin/v-rebuild-cron-jobs | 2 +- bin/v-rebuild-dns-domains | 2 +- bin/v-restart-cron | 16 ++++++++++++++++ bin/v-restart-dns | 16 ++++++++++++++++ bin/v-restart-ftp | 16 ++++++++++++++++ bin/v-restart-mail | 16 ++++++++++++++++ bin/v-restart-proxy | 16 ++++++++++++++++ bin/v-restart-web | 16 ++++++++++++++++ bin/v-restore-user | 4 ++-- bin/v-suspend-cron-job | 2 +- bin/v-suspend-cron-jobs | 2 +- bin/v-suspend-dns-domain | 2 +- bin/v-suspend-dns-domains | 6 +++--- bin/v-suspend-dns-record | 6 +++--- bin/v-suspend-user | 6 +++--- bin/v-suspend-web-domains | 2 +- bin/v-unsuspend-cron-job | 2 +- bin/v-unsuspend-cron-jobs | 2 +- bin/v-unsuspend-dns-domain | 6 +++--- bin/v-unsuspend-dns-domains | 6 +++--- bin/v-unsuspend-dns-record | 6 +++--- bin/v-unsuspend-user | 6 +++--- bin/v-unsuspend-web-domains | 2 +- 46 files changed, 172 insertions(+), 63 deletions(-) diff --git a/bin/v-add-cron-job b/bin/v-add-cron-job index 703201a5..78a3a3d2 100755 --- a/bin/v-add-cron-job +++ b/bin/v-add-cron-job @@ -1,6 +1,6 @@ #!/bin/bash # info: add cron job -# options: USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] +# options: USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] [RESTART] # # The function adds a job to cron daemon. When executing commands, any output # is mailed to user's email if parameter REPORTS is set to 'yes'. @@ -19,6 +19,7 @@ month=$5 wday=$6 command=$(echo $7 | sed -e "s/'/%quote%/g") job=$8 +restart=$9 # Includes source $VESTA/conf/vesta.conf @@ -32,7 +33,7 @@ A7="$command" # Verifications # #----------------------------------------------------------# -check_args '7' "$#" 'USER MIN HOUR DAY MONTH WDAY COMMAND [JOB]' +check_args '7' "$#" 'USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] [RESTART]' validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' is_system_enabled "$CRON_SYSTEM" 'CRON_SYSTEM' is_object_valid 'user' 'USER' "$user" @@ -72,7 +73,7 @@ sync_cron_jobs increase_user_value $user '$U_CRON_JOBS' # Restart crond -$BIN/v-restart-cron "$EVENT" +$BIN/v-restart-cron # Logging log_history "added cron job $job" diff --git a/bin/v-add-cron-report b/bin/v-add-cron-report index c0376c18..0cf30a22 100755 --- a/bin/v-add-cron-report +++ b/bin/v-add-cron-report @@ -45,7 +45,7 @@ sync_cron_jobs #----------------------------------------------------------# # Restart crond -$BIN/v-restart-cron "$EVENT" +$BIN/v-restart-cron # Logging log_history "enabled cron reporting" diff --git a/bin/v-add-remote-dns-domain b/bin/v-add-remote-dns-domain index ff8e5a49..2be01e5e 100755 --- a/bin/v-add-remote-dns-domain +++ b/bin/v-add-remote-dns-domain @@ -94,13 +94,13 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do # Sync domain str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) eval $str - $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME + $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'flush' 'no' # Sync records if [ "$TYPE" = 'ssh' ]; then tmp=$(mktemp -u) scp_cmd $USER_DATA/dns/$DOMAIN.conf $tmp - $send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp + $send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp 'no' else for str in $(cat $USER_DATA/dns/$DOMAIN.conf); do str=$(echo "$str" | sed 's/"/\\"/g') @@ -109,7 +109,7 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do fi # Rebuild dns zone - $send_cmd v-rebuild-dns-domain $DNS_USER $domain no + $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled' if [ $? -ne 0 ]; then echo "Error: $TYPE connection to $HOST failed (rebuild)" log_event "$E_CONNECT $EVENT" diff --git a/bin/v-add-remote-dns-record b/bin/v-add-remote-dns-record index 97b8ef8a..2676fb19 100755 --- a/bin/v-add-remote-dns-record +++ b/bin/v-add-remote-dns-record @@ -96,10 +96,10 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do # Sync record str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) str=$(echo "$str" | sed 's/"/\\"/g') - $send_cmd v-insert-dns-record $DNS_USER $domain "$str" + $send_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no' # Rebuild dns zone - $send_cmd v-rebuild-dns-domain $DNS_USER $domain no + $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled' if [ $? -ne 0 ]; then echo "Error: $TYPE connection to $HOST failed (rebuild)" log_event "$E_CONNECT $EVENT" diff --git a/bin/v-add-web-domain-proxy b/bin/v-add-web-domain-proxy index ff6325f3..0273ef6a 100755 --- a/bin/v-add-web-domain-proxy +++ b/bin/v-add-web-domain-proxy @@ -97,7 +97,7 @@ update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions" # Restart web server if [ "$restart" != 'no' ]; then - $BIN/v-restart-proxy "$EVENT" + $BIN/v-restart-proxy fi log_history "enabled proxy support for $domain" diff --git a/bin/v-add-web-domain-ssl b/bin/v-add-web-domain-ssl index 5973cec4..9c3a103f 100755 --- a/bin/v-add-web-domain-ssl +++ b/bin/v-add-web-domain-ssl @@ -124,7 +124,7 @@ update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes" # Restart web server if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" + $BIN/v-restart-web fi # Logging diff --git a/bin/v-change-cron-job b/bin/v-change-cron-job index 959e28e1..7d7780e0 100755 --- a/bin/v-change-cron-job +++ b/bin/v-change-cron-job @@ -64,7 +64,7 @@ sync_cron_jobs #----------------------------------------------------------# # Restart crond -$BIN/v-restart-cron "$EVENT" +$BIN/v-restart-cron # Logging log_history "changed cron job $job" diff --git a/bin/v-change-dns-domain-soa b/bin/v-change-dns-domain-soa index 6937547c..5daf5301 100755 --- a/bin/v-change-dns-domain-soa +++ b/bin/v-change-dns-domain-soa @@ -59,7 +59,7 @@ fi # Restart named if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-dns fi # Logging diff --git a/bin/v-change-dns-domain-ttl b/bin/v-change-dns-domain-ttl index 46854463..f812ac35 100755 --- a/bin/v-change-dns-domain-ttl +++ b/bin/v-change-dns-domain-ttl @@ -58,7 +58,7 @@ fi # Restart named if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-dns fi # Logging diff --git a/bin/v-change-remote-dns-domain-exp b/bin/v-change-remote-dns-domain-exp index 81c74424..cb11c729 100755 --- a/bin/v-change-remote-dns-domain-exp +++ b/bin/v-change-remote-dns-domain-exp @@ -94,7 +94,7 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do # Sync domain str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf) eval $str - $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no' + $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'scheduled' done diff --git a/bin/v-change-remote-dns-domain-soa b/bin/v-change-remote-dns-domain-soa index d2ba4119..6b6dfb06 100755 --- a/bin/v-change-remote-dns-domain-soa +++ b/bin/v-change-remote-dns-domain-soa @@ -97,7 +97,7 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no' # Rebuild dns zone - $send_cmd v-rebuild-dns-domain $DNS_USER $domain no + $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled' if [ $? -ne 0 ]; then echo "Error: $TYPE connection to $HOST failed (rebuild)" log_event "$E_CONNECT $EVENT" diff --git a/bin/v-change-remote-dns-domain-ttl b/bin/v-change-remote-dns-domain-ttl index fa7c978f..053a4115 100755 --- a/bin/v-change-remote-dns-domain-ttl +++ b/bin/v-change-remote-dns-domain-ttl @@ -97,7 +97,7 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no' # Rebuild dns zone - $send_cmd v-rebuild-dns-domain $DNS_USER $domain no + $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled' if [ $? -ne 0 ]; then echo "Error: $TYPE connection to $HOST failed (rebuild)" log_event "$E_CONNECT $EVENT" diff --git a/bin/v-change-sys-ip-nat b/bin/v-change-sys-ip-nat index 3529dfb8..d4e1d026 100755 --- a/bin/v-change-sys-ip-nat +++ b/bin/v-change-sys-ip-nat @@ -66,7 +66,7 @@ fi # Restart ftp server if [ "$restart" != 'no' ]; then - $BIN/v-restart-ftp "$EVENT" + $BIN/v-restart-ftp fi # Logging diff --git a/bin/v-delete-cron-job b/bin/v-delete-cron-job index d835528f..f85e04bf 100755 --- a/bin/v-delete-cron-job +++ b/bin/v-delete-cron-job @@ -53,7 +53,7 @@ sync_cron_jobs decrease_user_value "$user" '$U_CRON_JOBS' # Restart crond -$BIN/v-restart-cron "$EVENT" +$BIN/v-restart-cron # Logging log_history "deleted cron job $job" diff --git a/bin/v-delete-cron-reports b/bin/v-delete-cron-reports index 54f54c70..7073d62d 100755 --- a/bin/v-delete-cron-reports +++ b/bin/v-delete-cron-reports @@ -45,7 +45,7 @@ sync_cron_jobs #----------------------------------------------------------# # Restart crond -$BIN/v-restart-cron "$EVENT" +$BIN/v-restart-cron # Logging log_history "disabled cron reporting" diff --git a/bin/v-delete-dns-domain b/bin/v-delete-dns-domain index e1d47568..fb362571 100755 --- a/bin/v-delete-dns-domain +++ b/bin/v-delete-dns-domain @@ -65,7 +65,7 @@ decrease_user_value "$user" '$U_DNS_RECORDS' "$records" # Restart named if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-dns $restart fi # Logging diff --git a/bin/v-delete-dns-domains b/bin/v-delete-dns-domains index d1716938..a425d06f 100755 --- a/bin/v-delete-dns-domains +++ b/bin/v-delete-dns-domains @@ -42,7 +42,7 @@ done #----------------------------------------------------------# # Restart named -$BIN/v-restart-dns "$EVENT" +$BIN/v-restart-dns # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-delete-dns-domains-src b/bin/v-delete-dns-domains-src index 2c135382..fb2b77fc 100755 --- a/bin/v-delete-dns-domains-src +++ b/bin/v-delete-dns-domains-src @@ -45,7 +45,7 @@ done # Restart named if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-dns fi # Logging diff --git a/bin/v-delete-remote-dns-domain b/bin/v-delete-remote-dns-domain index 35f11a8c..c08683bb 100755 --- a/bin/v-delete-remote-dns-domain +++ b/bin/v-delete-remote-dns-domain @@ -90,7 +90,7 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do fi # Sync domain - $send_cmd v-delete-dns-domain $DNS_USER $domain 'no' + $send_cmd v-delete-dns-domain $DNS_USER $domain 'scheduled' done diff --git a/bin/v-delete-remote-dns-domains b/bin/v-delete-remote-dns-domains index 5faa910b..db3a250b 100755 --- a/bin/v-delete-remote-dns-domains +++ b/bin/v-delete-remote-dns-domains @@ -96,7 +96,7 @@ for cluster_str in $hosts; do fi # Clean source records - $send_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME no + $send_cmd v-delete-dns-domains-src $DNS_USER $HOSTNAME 'no' if [ $? -ne 0 ]; then echo "Error: $TYPE connection to $HOST failed (cleanup)" log_event "$E_CONNECT $EVENT" @@ -104,7 +104,7 @@ for cluster_str in $hosts; do fi # Rebuild dns zones - $send_cmd v-rebuild-dns-domains $DNS_USER + $send_cmd v-rebuild-dns-domains $DNS_USER 'scheduled' if [ $? -ne 0 ]; then echo "Error: $TYPE connection to $HOST failed (rebuild)" log_event "$E_CONNECT $EVENT" diff --git a/bin/v-delete-remote-dns-record b/bin/v-delete-remote-dns-record index be9e3111..d4ca9f31 100755 --- a/bin/v-delete-remote-dns-record +++ b/bin/v-delete-remote-dns-record @@ -86,7 +86,7 @@ for cluster_str in $(cat $VESTA/conf/dns-cluster.conf); do fi # Sync domain - $send_cmd v-delete-dns-record $DNS_USER $domain $id 'no' + $send_cmd v-delete-dns-record $DNS_USER $domain $id 'scheduled' done diff --git a/bin/v-insert-dns-record b/bin/v-insert-dns-record index 01ee7e8f..87b433df 100755 --- a/bin/v-insert-dns-record +++ b/bin/v-insert-dns-record @@ -1,6 +1,6 @@ #!/bin/bash # info: insert dns record -# options: USER DOMAIN DATA +# options: USER DOMAIN DATA [RESTART] # # The function inserts raw dns record to the domain conf @@ -13,6 +13,7 @@ user=$1 domain=$2 data=$3 +restart=$4 # Includes source $VESTA/conf/vesta.conf @@ -23,7 +24,7 @@ source $VESTA/func/main.sh # Verifications # #----------------------------------------------------------# -check_args '3' "$#" 'USER DOMAIN DATA' +check_args '3' "$#" 'USER DOMAIN DATA [RESTART]' validate_format 'user' 'domain' 'data' is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' is_object_valid 'user' 'USER' "$user" @@ -43,6 +44,11 @@ echo "$data" >> $USER_DATA/dns/$domain.conf # Vesta # #----------------------------------------------------------# +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns $restart +fi + # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-insert-dns-records b/bin/v-insert-dns-records index c86eeea0..99a48a20 100755 --- a/bin/v-insert-dns-records +++ b/bin/v-insert-dns-records @@ -1,6 +1,6 @@ #!/bin/bash # info: inserts dns records -# options: USER DOMAIN DATA_FILE +# options: USER DOMAIN DATA_FILE [RESTART] # # The function copy dns record to the domain conf @@ -13,6 +13,7 @@ user=$1 domain=$2 data_file=$3 +restart=$4 # Includes source $VESTA/conf/vesta.conf @@ -23,7 +24,7 @@ source $VESTA/func/main.sh # Verifications # #----------------------------------------------------------# -check_args '3' "$#" 'USER DOMAIN DATAFILE' +check_args '3' "$#" 'USER DOMAIN DATAFILE [RESTART]' validate_format 'user' 'domain' 'data_file' is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM' is_object_valid 'user' 'USER' "$user" @@ -46,6 +47,11 @@ fi # Vesta # #----------------------------------------------------------# +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns +fi + # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-rebuild-cron-jobs b/bin/v-rebuild-cron-jobs index cff11ef3..c0ac562e 100755 --- a/bin/v-rebuild-cron-jobs +++ b/bin/v-rebuild-cron-jobs @@ -42,7 +42,7 @@ sync_cron_jobs # Restart crond if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-cron fi # Logging diff --git a/bin/v-rebuild-dns-domains b/bin/v-rebuild-dns-domains index 2f727c00..dcfe2b1f 100755 --- a/bin/v-rebuild-dns-domains +++ b/bin/v-rebuild-dns-domains @@ -68,7 +68,7 @@ update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" # Restart named if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-dns fi # Logging diff --git a/bin/v-restart-cron b/bin/v-restart-cron index aaba3ad2..86ef72cd 100755 --- a/bin/v-restart-cron +++ b/bin/v-restart-cron @@ -18,6 +18,17 @@ source $VESTA/func/main.sh # Action # #----------------------------------------------------------# +# Schedule restart +if [ "$1" = 'scheduled' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi +if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi + +# Restart system if [ ! -z "$CRON_SYSTEM" ]; then /etc/init.d/$CRON_SYSTEM reload >/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -28,6 +39,11 @@ if [ ! -z "$CRON_SYSTEM" ]; then fi fi +# Update restart queue +if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe +fi + #----------------------------------------------------------# # Vesta # diff --git a/bin/v-restart-dns b/bin/v-restart-dns index 49f93662..9fc0dbeb 100755 --- a/bin/v-restart-dns +++ b/bin/v-restart-dns @@ -18,6 +18,17 @@ source $VESTA/func/main.sh # Action # #----------------------------------------------------------# +# Schedule restart +if [ "$1" = 'scheduled' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi +if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi + +# Restart system if [ ! -z "$DNS_SYSTEM" ]; then /etc/init.d/$DNS_SYSTEM reload >/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -28,6 +39,11 @@ if [ ! -z "$DNS_SYSTEM" ]; then fi fi +# Update restart queue +if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe +fi + #----------------------------------------------------------# # Vesta # diff --git a/bin/v-restart-ftp b/bin/v-restart-ftp index a9fa521d..a8e4d8a8 100755 --- a/bin/v-restart-ftp +++ b/bin/v-restart-ftp @@ -18,6 +18,17 @@ source $VESTA/func/main.sh # Action # #----------------------------------------------------------# +# Schedule restart +if [ "$1" = 'scheduled' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi +if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi + +# Restart system if [ ! -z "$FTP_SYSTEM" ]; then /etc/init.d/$FTP_SYSTEM reload >/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -28,6 +39,11 @@ if [ ! -z "$FTP_SYSTEM" ]; then fi fi +# Update restart queue +if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe +fi + #----------------------------------------------------------# # Vesta # diff --git a/bin/v-restart-mail b/bin/v-restart-mail index c39a5e6d..c3c537f9 100755 --- a/bin/v-restart-mail +++ b/bin/v-restart-mail @@ -18,6 +18,17 @@ source $VESTA/func/main.sh # Action # #----------------------------------------------------------# +# Schedule restart +if [ "$1" = 'scheduled' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi +if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi + +# Restart system if [ ! -z "$MAIL_SYSTEM" ]; then /etc/init.d/$MAIL_SYSTEM reload >/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -28,6 +39,11 @@ if [ ! -z "$MAIL_SYSTEM" ]; then fi fi +# Update restart queue +if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe +fi + #----------------------------------------------------------# # Vesta # diff --git a/bin/v-restart-proxy b/bin/v-restart-proxy index dea79990..36363268 100755 --- a/bin/v-restart-proxy +++ b/bin/v-restart-proxy @@ -18,6 +18,17 @@ source $VESTA/func/main.sh # Action # #----------------------------------------------------------# +# Schedule restart +if [ "$1" = 'scheduled' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi +if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi + +# Restart system if [ ! -z "$PROXY_SYSTEM" ]; then /etc/init.d/$PROXY_SYSTEM reload >/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -28,6 +39,11 @@ if [ ! -z "$PROXY_SYSTEM" ]; then fi fi +# Update restart queue +if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe +fi + #----------------------------------------------------------# # Vesta # diff --git a/bin/v-restart-web b/bin/v-restart-web index bcc2b639..337fbc2c 100755 --- a/bin/v-restart-web +++ b/bin/v-restart-web @@ -18,6 +18,17 @@ source $VESTA/func/main.sh # Action # #----------------------------------------------------------# +# Schedule restart +if [ "$1" = 'scheduled' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi +if [ -z "$1" ] && [ "$SCHEDULED_RESTART" = 'yes' ]; then + echo "$BIN/$SCRIPT now" >> $VESTA/data/queue/restart.pipe + exit +fi + +# Restart system if [ ! -z "$WEB_SYSTEM" ]; then /etc/init.d/$WEB_SYSTEM reload >/dev/null 2>&1 if [ $? -ne 0 ]; then @@ -28,6 +39,11 @@ if [ ! -z "$WEB_SYSTEM" ]; then fi fi +# Update restart queue +if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe +fi + #----------------------------------------------------------# # Vesta # diff --git a/bin/v-restore-user b/bin/v-restore-user index f05f362a..79af0a62 100755 --- a/bin/v-restore-user +++ b/bin/v-restore-user @@ -469,7 +469,7 @@ if [ "$dns" != 'no' ]; then done # Restart DNS - $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-dns echo msg="$msg\n" fi @@ -682,7 +682,7 @@ if [ "$cron" != 'no' ]; then sync_cron_jobs # Restart cron - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-cron echo msg="$msg\n" fi diff --git a/bin/v-suspend-cron-job b/bin/v-suspend-cron-job index a9c29019..adeff7d8 100755 --- a/bin/v-suspend-cron-job +++ b/bin/v-suspend-cron-job @@ -48,7 +48,7 @@ sync_cron_jobs # Restart crond if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-cron fi # Logging diff --git a/bin/v-suspend-cron-jobs b/bin/v-suspend-cron-jobs index 5dadc5c6..e8daf6e8 100755 --- a/bin/v-suspend-cron-jobs +++ b/bin/v-suspend-cron-jobs @@ -43,7 +43,7 @@ done # Restart crond if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-cron fi # Logging diff --git a/bin/v-suspend-dns-domain b/bin/v-suspend-dns-domain index 83cd6c1d..059b6532 100755 --- a/bin/v-suspend-dns-domain +++ b/bin/v-suspend-dns-domain @@ -51,7 +51,7 @@ increase_user_value "$user" '$SUSPENDED_DNS' # Restart named #if [ "$restart" != 'no' ]; then -# $BIN/v-restart-dns "$EVENT" +# $BIN/v-restart-dns #fi # Logging diff --git a/bin/v-suspend-dns-domains b/bin/v-suspend-dns-domains index d0e440db..2c54d57e 100755 --- a/bin/v-suspend-dns-domains +++ b/bin/v-suspend-dns-domains @@ -43,9 +43,9 @@ done #----------------------------------------------------------# # Restart dns server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi +#if [ "$restart" != 'no' ]; then +# $BIN/v-restart-dns +#fi # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-suspend-dns-record b/bin/v-suspend-dns-record index 83b39312..f14d89f9 100755 --- a/bin/v-suspend-dns-record +++ b/bin/v-suspend-dns-record @@ -61,9 +61,9 @@ update_domain_zone #----------------------------------------------------------# # Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi +#if [ "$restart" != 'no' ]; then +# $BIN/v-restart-dns +#fi # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-suspend-user b/bin/v-suspend-user index 16c9569a..ed4534b6 100755 --- a/bin/v-suspend-user +++ b/bin/v-suspend-user @@ -70,9 +70,9 @@ fi # Restart web server if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" - $BIN/v-restart-dns "$EVENT" - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-web + $BIN/v-restart-dns + $BIN/v-restart-cron fi # Changing suspend value diff --git a/bin/v-suspend-web-domains b/bin/v-suspend-web-domains index e2ed5919..e772e07f 100755 --- a/bin/v-suspend-web-domains +++ b/bin/v-suspend-web-domains @@ -44,7 +44,7 @@ done # Restart web server if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" + $BIN/v-restart-web fi # Logging diff --git a/bin/v-unsuspend-cron-job b/bin/v-unsuspend-cron-job index 23c45bba..dddb20fe 100755 --- a/bin/v-unsuspend-cron-job +++ b/bin/v-unsuspend-cron-job @@ -48,7 +48,7 @@ sync_cron_jobs # Restart crond if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-cron fi # Logging diff --git a/bin/v-unsuspend-cron-jobs b/bin/v-unsuspend-cron-jobs index 066b6d62..d9fabab4 100755 --- a/bin/v-unsuspend-cron-jobs +++ b/bin/v-unsuspend-cron-jobs @@ -43,7 +43,7 @@ done # Restart crond if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-cron fi # Logging diff --git a/bin/v-unsuspend-dns-domain b/bin/v-unsuspend-dns-domain index e3e5627a..f850ad7c 100755 --- a/bin/v-unsuspend-dns-domain +++ b/bin/v-unsuspend-dns-domain @@ -53,9 +53,9 @@ sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf # Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi +#if [ "$restart" != 'no' ]; then +# $BIN/v-restart-dns +#fi # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-unsuspend-dns-domains b/bin/v-unsuspend-dns-domains index bf98cace..7246cb50 100755 --- a/bin/v-unsuspend-dns-domains +++ b/bin/v-unsuspend-dns-domains @@ -43,9 +43,9 @@ done #----------------------------------------------------------# # Restart dns server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi +#if [ "$restart" != 'no' ]; then +# $BIN/v-restart-dns +#fi # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-unsuspend-dns-record b/bin/v-unsuspend-dns-record index 02d06e33..505b0873 100755 --- a/bin/v-unsuspend-dns-record +++ b/bin/v-unsuspend-dns-record @@ -60,9 +60,9 @@ update_domain_zone #----------------------------------------------------------# # Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi +#if [ "$restart" != 'no' ]; then +# $BIN/v-restart-dns +#fi # Logging log_event "$OK" "$EVENT" diff --git a/bin/v-unsuspend-user b/bin/v-unsuspend-user index 4a0b3e14..5bb8f3eb 100755 --- a/bin/v-unsuspend-user +++ b/bin/v-unsuspend-user @@ -72,9 +72,9 @@ update_user_value "$user" '$SUSPENDED' 'no' decrease_user_value 'admin' '$SUSPENDED_USERS' if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" - $BIN/v-restart-dns "$EVENT" - $BIN/v-restart-cron "$EVENT" + $BIN/v-restart-web + $BIN/v-restart-dns + $BIN/v-restart-cron fi # Logging diff --git a/bin/v-unsuspend-web-domains b/bin/v-unsuspend-web-domains index ca729bf4..f33dd10f 100755 --- a/bin/v-unsuspend-web-domains +++ b/bin/v-unsuspend-web-domains @@ -45,7 +45,7 @@ done # Restart web server if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" + $BIN/v-restart-web fi # Logging