فهرست منبع

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 سال پیش
والد
کامیت
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"
                 fi
 		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
                 SERVICETOOL="service $SERVICE status"
                 LISTTOOL="service --status-all"
@@ -92,6 +85,13 @@ if [[ $OS == linux ]]; then
                     SERVICETOOL="sudo -u $USERNAME service $SERVICE status"
                     LISTTOOL="sudo -u $USERNAME service --status-all"
                 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
                 SERVICETOOL=chkconfig
                 LISTTOOL="chkconfig --list"