Просмотр исходного кода

Check for service state before performing reload

Kristan Kenney 6 лет назад
Родитель
Сommit
144affa4c4
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      bin/v-restart-service

+ 7 - 0
bin/v-restart-service

@@ -23,11 +23,16 @@ PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 #----------------------------------------------------------#
 
 check_args '1' "$#" 'SERVICE'
+service_status=$(pgrep $service)
 
 #----------------------------------------------------------#
 #                       Action                             #
 #----------------------------------------------------------#
 
+if [ -z "$service_status" ]; then
+    force="yes"
+fi
+
 if [ "$service" = "iptables" ]; then
     # Run the restart rules for iptables firewall
     $BIN/v-stop-firewall
@@ -38,7 +43,9 @@ elif [ -z "$force" -o "$force" = "no" ] && [ \
         "$service" = "exim4" -o     \
         "$service" = "dovecot" -o   \
         "$service" = "bind9" -o     \
+        "$service" = "named" -o     \
         "$service" = "vsftpd" -o    \
+        "$service" = "proftpd" -o    \
         "$service" = "ssh" -o       \
         "$service" = "fail2ban" ]; then
     systemctl reload $service > /dev/null 2>&1