Files
VestaCP/bin/v_update_sys_queue
2011-12-23 11:54:23 +02:00

82 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# info: updating system queue
#----------------------------------------------------------#
# 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
# Defining pipe functions
restart_pipe() {
for service in $(cat $V_QUEUE/restart.pipe |awk '!x[$0]++'); do
$V_BIN/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
bash $V_BIN/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