]> git.pld-linux.org Git - projects/rc-scripts.git/blame - service
- nicer output (brief) for --status-all ported from ubuntu
[projects/rc-scripts.git] / service
CommitLineData
763b88c2
AM
1#!/bin/sh
2
3b917b57
AM
3# Set up a default search path.
4PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
5export PATH
6
58f95af1
ER
7is_ignored_file() {
8 case "$1" in
9 skeleton | README | *.dpkg-dist | *.dpkg-old | rc | rcS | single | reboot | bootclean.sh)
10 return 0
11 ;;
12 *rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
13 return 0
14 ;;
15 esac
16 return 1
17}
18
86ae1ad7 19VERSION="$(basename $0) ver. 0.91-pld"
bf14fcab 20USAGE="Usage: $(basename $0) < option > | --status-all | \
763b88c2 21[ service_name [ command | --full-restart ] ]"
3b917b57 22
763b88c2 23SERVICE=
3b917b57 24
763b88c2 25if [ -d /etc/rc.d/init.d ]; then
1050f687 26 SERVICEDIR="/etc/rc.d/init.d"
763b88c2 27else
1050f687 28 SERVICEDIR="/etc/init.d"
763b88c2
AM
29fi
30
31if [ $# -eq 0 ]; then
1050f687
JR
32 echo "${USAGE}" >&2
33 exit 1
763b88c2
AM
34fi
35
a6c22d3d
AM
36cd /
37while [ $# -gt 0 ]; do
1050f687
JR
38 case "${1}" in
39 --help | -h | --h* )
40 echo "${USAGE}" >&2
41 exit 0
42 ;;
43 --version | -V )
44 echo "${VERSION}" >&2
45 exit 0
46 ;;
47 *)
48 if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
49 cd ${SERVICEDIR}
86ae1ad7 50 for SERVICE in *; do
1050f687 51 case "${SERVICE}" in
58f95af1 52 functions | halt | killall | single| linuxconf| kudzu)
1050f687 53 ;;
58f95af1
ER
54 *)
55 if ! is_ignored_file "${SERVICE}" \
56 && [ -x "${SERVICEDIR}/${SERVICE}" ]; then
57 if ! grep -qs "\Wstatus)" "$SERVICE"; then
58 #printf " %s %-60s %s\n" "[?]" "$SERVICE:" "unknown" 1>&2
59 echo " [ ? ] $SERVICE" 1>&2
60 continue
61 else
62 out=$(env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)
63 if [ "$?" = "0" -a -n "$out" ]; then
64 #printf " %s %-60s %s\n" "[+]" "$SERVICE:" "running"
65 echo " [ + ] $SERVICE"
66 continue
67 else
68 #printf " %s %-60s %s\n" "[-]" "$SERVICE:" "NOT running"
69 echo " [ - ] $SERVICE"
70 continue
71 fi
1050f687 72 fi
58f95af1
ER
73 #env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "$SERVICEDIR/$SERVICE" status
74 fi
75 ;;
1050f687
JR
76 esac
77 done
78 exit 0
79 elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
80 SERVICE="${1}"
81 if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
82 env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" stop
83 env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" start
84 exit $?
85 fi
86 elif [ -z "${SERVICE}" ]; then
87 SERVICE="${1}"
88 else
89 OPTIONS="${OPTIONS} ${1}"
90 fi
91 shift
92 ;;
93 esac
763b88c2
AM
94done
95
96if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
1050f687 97 env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${OPTIONS}
763b88c2 98else
1050f687
JR
99 echo "${SERVICE}: unrecognized service" >&2
100 exit 1
763b88c2 101fi
This page took 0.180385 seconds and 4 git commands to generate.