forked from outroll/vesta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-restart-web-backend
executable file
·65 lines (52 loc) · 1.76 KB
/
v-restart-web-backend
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# info: restart backend server
# options: NONE
#
# The function reloads backend server configuration.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
send_email_report() {
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $WEB_BACKEND restart failed"
service $WEB_BACKEND configtest >> $tmpfile 2>&1
service $WEB_BACKEND restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
rm -f $tmpfile
}
#----------------------------------------------------------#
# 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
if [ -z "$WEB_BACKEND" ] || [ "$WEB_BACKEND" = 'remote' ]; then
exit
fi
# Restart system
service $WEB_BACKEND restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
echo "Error: $WEB_BACKEND restart failed"
exit $E_RESTART
fi
# Update restart queue
if [ -e "$VESTA/data/queue/restart.pipe" ]; then
sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit