Files
VestaCP/bin/v_update_sys_queue

90 lines
2.2 KiB
Plaintext
Raw Normal View History

2011-06-14 00:22:25 +03: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.
2011-06-14 00:22:25 +03:00
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
2011-11-01 12:27:45 +02:00
pipe=$1
2011-06-14 00:22:25 +03:00
# Importing system enviroment as we run this script
# mostly by cron wich not read it by itself
2011-06-14 00:22:25 +03:00
source /etc/profile.d/vesta.sh
# Importing variables
source $VESTA/conf/vars.conf
2011-11-21 15:46:02 +02:00
source $V_CONF/vesta.conf
2011-11-01 13:02:44 +02:00
source $V_FUNC/shared.func
2011-06-14 00:22:25 +03:00
# Defining pipe functions
restart_pipe() {
2011-12-23 11:54:23 +02:00
for service in $(cat $V_QUEUE/restart.pipe |awk '!x[$0]++'); do
2011-11-01 13:02:44 +02:00
$V_BIN/v_restart_$service
2011-06-14 00:22:25 +03:00
done
2011-11-01 13:02:44 +02:00
echo > $V_QUEUE/restart.pipe
2011-06-14 00:22:25 +03:00
}
stats_pipe() {
bash $V_QUEUE/stats.pipe
}
disk_pipe() {
bash $V_QUEUE/disk.pipe
}
traff_pipe() {
bash $V_QUEUE/traffic.pipe
}
2011-11-23 16:50:56 +02:00
backup_pipe() {
2011-12-23 11:54:23 +02:00
for user in $(cat $V_QUEUE/backup.pipe |awk '!x[$0]++' ); do
2011-11-23 16:50:56 +02:00
sed -i "/^$user$/d" $V_QUEUE/backup.pipe
bash $V_BIN/v_backup_user $user
2011-11-23 16:50:56 +02:00
# Send notification to user
done
}
2011-11-01 13:02:44 +02:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'pipe'
# Checking argument format
format_validation 'pipe'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
2011-06-14 00:22:25 +03:00
case $pipe in
2011-11-01 13:02:44 +02:00
restart) restart_pipe ;;
stats) stats_pipe ;;
backup) backup_pipe ;;
disk) disk_pipe ;;
traffic) traff_pipe ;;
*) check_args '1' '0' 'pipe'
2011-06-14 00:22:25 +03:00
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
2011-11-01 12:27:45 +02:00
exit