2013-01-19 23:07:26 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# info: update system queue
|
|
|
|
# options: PIPE
|
|
|
|
#
|
|
|
|
# This function is responsible queue processing. Restarts of services,
|
|
|
|
# scheduled backups, web log parsing and other heavy resource consuming
|
|
|
|
# operations are handled by this script. It helps to optimize system behaviour.
|
|
|
|
# In a nutshell Apache will be restarted only once even if 10 domains are
|
|
|
|
# added or deleted.
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
# Variable&Function #
|
|
|
|
#----------------------------------------------------------#
|
2015-11-06 17:38:58 +02:00
|
|
|
# Argument definition
|
2013-01-19 23:07:26 +02:00
|
|
|
queue=$1
|
|
|
|
|
2015-11-06 17:38:58 +02:00
|
|
|
# Importing system environment as we run this script
|
2013-01-19 23:07:26 +02:00
|
|
|
# mostly by cron wich not read it by itself
|
|
|
|
source /etc/profile
|
|
|
|
|
|
|
|
# Includes
|
|
|
|
source $VESTA/func/main.sh
|
2013-10-09 00:50:08 +03:00
|
|
|
source $VESTA/conf/vesta.conf
|
2013-01-19 23:07:26 +02:00
|
|
|
|
|
|
|
# Export PATH for cron
|
|
|
|
PATH=$PATH:$BIN
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
# Verifications #
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
|
|
check_args '1' "$#" 'QUEUE'
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
# Action #
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
2013-05-28 16:09:07 +03:00
|
|
|
b_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue backup")
|
|
|
|
b_task=$(echo "$b_task" |grep -v sudo |wc -l)
|
|
|
|
d_task=$(ps auxf |grep -v "grep" |grep "$VESTA/bin/v-update-sys-queue dns")
|
|
|
|
d_task=$(echo "$d_task" |grep -v sudo |wc -l)
|
|
|
|
if [ "$b_task" -gt 2 ] || [ "$d_task" -gt 2 ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2013-01-19 23:07:26 +02:00
|
|
|
# Defining pipe functions
|
|
|
|
case $queue in
|
2016-10-31 12:00:14 +02:00
|
|
|
restart) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1;;
|
2013-05-28 16:09:07 +03:00
|
|
|
webstats) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
|
|
|
|
backup) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
|
2016-10-31 12:00:14 +02:00
|
|
|
disk) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1;;
|
|
|
|
traffic) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1;;
|
2013-05-29 14:20:05 +03:00
|
|
|
dns-cluster) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
|
2016-10-31 12:00:14 +02:00
|
|
|
letsencrypt) bash $VESTA/data/queue/$queue.pipe > /dev/null 2>&1 ;;
|
2013-05-28 16:09:07 +03:00
|
|
|
*) check_args '1' '0' 'QUEUE' ;;
|
2013-01-19 23:07:26 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
# Vesta #
|
|
|
|
#----------------------------------------------------------#
|
|
|
|
|
|
|
|
# No Logging
|
2016-06-09 16:31:56 +03:00
|
|
|
#log_event "$OK" "$ARGUMENTS"
|
2013-01-19 23:07:26 +02:00
|
|
|
|
|
|
|
exit
|