Skip to content

Commit 17c6a75

Browse files
author
Kristan Kenney
committed
Code changes to v-restart-service
1 parent ce327a7 commit 17c6a75

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

bin/v-restart-service

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,30 @@ PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
2323

2424
check_args '1' "$#" 'SERVICE'
2525

26-
2726
#----------------------------------------------------------#
2827
# Action #
2928
#----------------------------------------------------------#
3029

31-
Blacklist=("iptables","cron","mysql","mariadb","hestia")
32-
33-
34-
for BannedService in Blackist; do
35-
if [ "$service" = "$BannedService" ]; then
36-
systemctl restart $service > /dev/null 2>&1
37-
check_result $E_RESTART "ERROR: Restart of $service failed."
38-
log_history "Restart of $service failed."
39-
fi
40-
done
41-
30+
# Run the restart rules for iptables firewall
4231
if [ "$service" = "iptables" ]; then
43-
# Restart rules for firewall
4432
$BIN/v-stop-firewall
4533
$BIN/v-update-firewall
4634
fi
4735

48-
systemctl reload $service > /dev/null 2>&1
49-
if [ $? -ne 0 ]; then
50-
check_result $E_RESTART "ERROR: Restart of $service failed."
51-
log_history "Restart of $service failed."
52-
fi
53-
36+
if [ "$service" = "hestia" ] || [ "$service" = "iptables" ] || [ "$service" = "mariadb" ] || [ "$service" = "mysql" ] || [ "$service" = "postgresql" ] || [ "$service" = "cron" ]; then
37+
systemctl restart $service > /dev/null 2>&1
38+
else
39+
systemctl reload $service > /dev/null 2>&1
40+
fi
5441

5542
#----------------------------------------------------------#
5643
# Hestia #
5744
#----------------------------------------------------------#
5845

46+
# Check the result of the service restart and report whether it failed.
47+
if [ $? -ne 0 ]; then
48+
check_result $E_RESTART "ERROR: Restart of $service failed."
49+
log_history "Restart of $service failed."
50+
fi
51+
5952
exit

0 commit comments

Comments
 (0)