]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - service
point out the parameters use fact
[projects/rc-scripts.git] / service
diff --git a/service b/service
index 7112460bf4c85e2ca294e549c20992cef1350432..5567c74488c8cd835648ae62d77f7831f3cb8c62 100755 (executable)
--- a/service
+++ b/service
@@ -16,6 +16,46 @@ is_ignored_file() {
        return 1
 }
 
+status_all() {
+       local SERVICE TYPE
+       cd ${SERVICEDIR}
+       for SERVICE in *; do
+               case "${SERVICE}" in
+               functions | halt | killall | single| linuxconf| kudzu)
+                       ;;
+               *)
+               if ! is_ignored_file "${SERVICE}" \
+                               && [ -x "${SERVICEDIR}/${SERVICE}" ]; then
+                       if [ -f /etc/init/${SERVICE}.conf ]; then
+                               # U for upstart
+                               TYPE='U'
+                       else
+                               # S for SysVinit
+                               TYPE='S'
+                       fi
+                       if ! grep -qs "\Wstatus)" "$SERVICE"; then
+                               #printf " %s %-60s %s\n" "[?]" "$SERVICE:" "unknown" 1>&2
+                               echo " [ ? ]{$TYPE} $SERVICE"
+                               continue
+                       else
+                               out=$(env -i USE_UPSTART=$USE_UPSTART LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
+                               if [ "$?" = "0" -a -n "$out" ]; then
+                                       #printf " %s %-60s %s\n" "[+]" "$SERVICE:" "running"
+                                       echo " [ + ]{$TYPE} $SERVICE"
+                                       continue
+                               else
+                                       #printf " %s %-60s %s\n" "[-]" "$SERVICE:" "NOT running"
+                                       echo " [ - ]{$TYPE} $SERVICE"
+                                       continue
+                               fi
+                       fi
+                       #env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status
+               fi
+               ;;
+               esac
+       done
+}
+
 VERSION="$(basename $0) ver. 0.91-pld"
 USAGE="Usage: $(basename $0) < option > | --status-all | \
 [ service_name [ command | --full-restart ] ]"
@@ -45,45 +85,17 @@ while [ $# -gt 0 ]; do
                echo "${VERSION}" >&2
                exit 0
                ;;
-         --upstart)
-               USE_UPSTART=yes
+       --upstart)
+               USE_UPSTART=yes
                shift
                ;;
-         --no-upstart)
-               USE_UPSTART=no
+       --no-upstart)
+               USE_UPSTART=no
                shift
                ;;
          *)
                if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
-                       cd ${SERVICEDIR}
-                       for SERVICE in *; do
-                               case "${SERVICE}" in
-                               functions | halt | killall | single| linuxconf| kudzu)
-                                       ;;
-                               *)
-                               if ! is_ignored_file "${SERVICE}" \
-                                               && [ -x "${SERVICEDIR}/${SERVICE}" ]; then
-                                       if ! grep -qs "\Wstatus)" "$SERVICE"; then
-                                               #printf " %s %-60s %s\n" "[?]" "$SERVICE:" "unknown" 1>&2
-                                               echo " [ ? ]  $SERVICE" 1>&2
-                                               continue
-                                       else
-                                               out=$(env -i USE_UPSTART=$USE_UPSTART LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
-                                               if [ "$?" = "0" -a -n "$out" ]; then
-                                                       #printf " %s %-60s %s\n" "[+]" "$SERVICE:" "running"
-                                                       echo " [ + ]  $SERVICE"
-                                                       continue
-                                               else
-                                                       #printf " %s %-60s %s\n" "[-]" "$SERVICE:" "NOT running"
-                                                       echo " [ - ]  $SERVICE"
-                                                       continue
-                                               fi
-                                       fi
-                                       #env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status
-                               fi
-                               ;;
-                               esac
-                       done
+                       status_all
                        exit 0
                elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
                        SERVICE="${1}"
This page took 0.051133 seconds and 4 git commands to generate.