]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
move status all to function
authorElan Ruusamäe <glen@pld-linux.org>
Fri, 8 Apr 2011 19:15:05 +0000 (19:15 +0000)
committerElan Ruusamäe <glen@pld-linux.org>
Fri, 8 Apr 2011 19:15:05 +0000 (19:15 +0000)
svn-id: @12223

service

diff --git a/service b/service
index f4488c6c87e6a3b046422322cd0b8d509aafb480..5a67a40c65d2f947d354ed703dd379ee64bf1c65 100755 (executable)
--- a/service
+++ b/service
@@ -1,4 +1,5 @@
 #!/bin/sh
+set -x
 
 # Set up a default search path.
 PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
@@ -16,6 +17,39 @@ is_ignored_file() {
        return 1
 }
 
+status_all() {
+       local SERVICE
+       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
+}
+
 VERSION="$(basename $0) ver. 0.91-pld"
 USAGE="Usage: $(basename $0) < option > | --status-all | \
 [ service_name [ command | --full-restart ] ]"
@@ -53,37 +87,9 @@ while [ $# -gt 0 ]; do
                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.049367 seconds and 4 git commands to generate.