Browse Source

Code changes to v-restart-service

Kristan Kenney 6 years ago
parent
commit
17c6a755dd
1 changed files with 12 additions and 19 deletions
  1. 12 19
      bin/v-restart-service

+ 12 - 19
bin/v-restart-service

@@ -23,37 +23,30 @@ PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 
 check_args '1' "$#" 'SERVICE'
 check_args '1' "$#" 'SERVICE'
 
 
-
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-Blacklist=("iptables","cron","mysql","mariadb","hestia")
-
-
-for BannedService in Blackist; do
-    if [ "$service" = "$BannedService" ]; then
-        systemctl restart $service > /dev/null 2>&1
-        check_result $E_RESTART "ERROR: Restart of $service failed."
-        log_history "Restart of $service failed."
-    fi
-done
-
+# Run the restart rules for iptables firewall
 if [ "$service" = "iptables" ]; then
 if [ "$service" = "iptables" ]; then
-    # Restart rules for firewall
     $BIN/v-stop-firewall
     $BIN/v-stop-firewall
     $BIN/v-update-firewall
     $BIN/v-update-firewall
 fi
 fi
 
 
-systemctl reload $service > /dev/null 2>&1
-if [ $? -ne 0 ]; then
-    check_result $E_RESTART "ERROR: Restart of $service failed."
-    log_history "Restart of $service failed."
- fi
-
+if [ "$service" = "hestia" ] || [ "$service" = "iptables" ] || [ "$service" = "mariadb" ] || [ "$service" = "mysql" ] || [ "$service" = "postgresql" ] || [ "$service" = "cron" ]; then
+    systemctl restart $service > /dev/null 2>&1
+else
+    systemctl reload $service > /dev/null 2>&1
+fi
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Hestia                             #
 #                       Hestia                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
+# Check the result of the service restart and report whether it failed.
+if [ $? -ne 0 ]; then
+    check_result $E_RESTART "ERROR: Restart of $service failed."
+    log_history "Restart of $service failed."
+fi
+
 exit
 exit