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

Gives "service $foo status" priority over "status $foo".

Ref https://github.com/jonschipp/nagios-plugins/issues/35, on Ubuntu Trusty, "status $foo" yields results only for a subset of the services running, while "service $foo status" seems to yield results for all services running.

This commit has the potential to disrupt other distributions where the service command exists, but the status command is the right one to use - though hopefully there are no such distributions out there.
Tobias Brox 8 лет назад
Родитель
Сommit
07a6fc653d
1 измененных файлов с 7 добавлено и 7 удалено
  1. 7 7
      check_service.sh

+ 7 - 7
check_service.sh

@@ -78,13 +78,6 @@ if [[ $OS == linux ]]; then
                     LISTTOOL="sudo -u $USERNAME systemctl"
                     LISTTOOL="sudo -u $USERNAME systemctl"
                 fi
                 fi
 		TRUST_EXIT_CODE=1
 		TRUST_EXIT_CODE=1
-        elif command -v initctl >/dev/null 2>&1; then
-                SERVICETOOL="status $SERVICE"
-                LISTTOOL="initctl list"
-                if [ $USERNAME ]; then
-                    SERVICETOOL="sudo -u $USERNAME status $SERVICE"
-                    LISTTOOL="sudo -u $USERNAME initctl list"
-                fi
         elif command -v service >/dev/null 2>&1; then
         elif command -v service >/dev/null 2>&1; then
                 SERVICETOOL="service $SERVICE status"
                 SERVICETOOL="service $SERVICE status"
                 LISTTOOL="service --status-all"
                 LISTTOOL="service --status-all"
@@ -92,6 +85,13 @@ if [[ $OS == linux ]]; then
                     SERVICETOOL="sudo -u $USERNAME service $SERVICE status"
                     SERVICETOOL="sudo -u $USERNAME service $SERVICE status"
                     LISTTOOL="sudo -u $USERNAME service --status-all"
                     LISTTOOL="sudo -u $USERNAME service --status-all"
                 fi
                 fi
+        elif command -v initctl >/dev/null 2>&1; then
+                SERVICETOOL="status $SERVICE"
+                LISTTOOL="initctl list"
+                if [ $USERNAME ]; then
+                    SERVICETOOL="sudo -u $USERNAME status $SERVICE"
+                    LISTTOOL="sudo -u $USERNAME initctl list"
+                fi
         elif command -v chkconfig >/dev/null 2>&1; then
         elif command -v chkconfig >/dev/null 2>&1; then
                 SERVICETOOL=chkconfig
                 SERVICETOOL=chkconfig
                 LISTTOOL="chkconfig --list"
                 LISTTOOL="chkconfig --list"