SVN: rc-scripts/trunk/service

glen glen at pld-linux.org
Wed Apr 21 20:26:16 CEST 2010


Author: glen
Date: Wed Apr 21 20:26:16 2010
New Revision: 11339

Modified:
   rc-scripts/trunk/service
Log:
- nicer output (brief) for --status-all ported from ubuntu

Modified: rc-scripts/trunk/service
==============================================================================
--- rc-scripts/trunk/service	(original)
+++ rc-scripts/trunk/service	Wed Apr 21 20:26:16 2010
@@ -4,6 +4,18 @@
 PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
 export PATH
 
+is_ignored_file() {
+	case "$1" in
+	skeleton | README | *.dpkg-dist | *.dpkg-old | rc | rcS | single | reboot | bootclean.sh)
+		return 0
+		;;
+	*rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
+		return 0
+		;;
+	esac
+	return 1
+}
+
 VERSION="$(basename $0) ver. 0.91-pld"
 USAGE="Usage: $(basename $0) < option > | --status-all | \
 [ service_name [ command | --full-restart ] ]"
@@ -37,14 +49,30 @@
 			cd ${SERVICEDIR}
 			for SERVICE in *; do
 				case "${SERVICE}" in
-				  functions | halt | killall | single| linuxconf| kudzu | \
-				  *rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
+				functions | halt | killall | single| linuxconf| kudzu)
 					;;
-				  *)
-					if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
-						env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" status
+				*)
+				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 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
 			exit 0


More information about the pld-cvs-commit mailing list