mirror of
https://github.com/serghey-rodin/vesta.git
synced 2026-02-17 20:07:23 +01:00
93 lines
2.3 KiB
Bash
Executable File
93 lines
2.3 KiB
Bash
Executable File
#!/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 #
|
|
#----------------------------------------------------------#
|
|
# Argument defenition
|
|
pipe=$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
|
|
|
|
# Export PATH for cron
|
|
PATH=$PATH:$V_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
|
|
}
|
|
|
|
stats_pipe() {
|
|
bash $V_QUEUE/stats.pipe
|
|
}
|
|
|
|
disk_pipe() {
|
|
bash $V_QUEUE/disk.pipe
|
|
}
|
|
|
|
traff_pipe() {
|
|
bash $V_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
|
|
}
|
|
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
# Checking arg number
|
|
check_args '1' "$#" 'pipe'
|
|
|
|
# Checking argument format
|
|
format_validation 'pipe'
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
case $pipe in
|
|
restart) restart_pipe ;;
|
|
stats) stats_pipe ;;
|
|
backup) backup_pipe ;;
|
|
disk) disk_pipe ;;
|
|
traffic) traff_pipe ;;
|
|
*) check_args '1' '0' 'pipe'
|
|
esac
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_event 'system' "$V_EVENT"
|
|
|
|
exit
|