]> git.pld-linux.org Git - projects/rc-scripts.git/blob - service
Drop obsolete msg_() functions.
[projects/rc-scripts.git] / service
1 #!/bin/sh
2
3 # Set up a default search path.
4 PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
5 export PATH
6
7 VERSION="`basename $0` ver. 0.91"
8 USAGE="Usage: `basename $0` < option > | --status-all | \
9 [ service_name [ command | --full-restart ] ]"
10
11 SERVICE=
12
13 if [ -d /etc/rc.d/init.d ]; then
14     SERVICEDIR="/etc/rc.d/init.d"
15 else
16     SERVICEDIR="/etc/init.d"
17 fi
18
19 if [ $# -eq 0 ]; then
20    echo "${USAGE}" >&2
21    exit 1
22 fi
23
24 cd /
25 while [ $# -gt 0 ]; do
26   case "${1}" in
27     --help | -h | --h* )
28        echo "${USAGE}" >&2
29        exit 0
30        ;;
31     --version | -V )
32        echo "${VERSION}" >&2
33        exit 0
34        ;;
35     *)
36        if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
37           cd ${SERVICEDIR}
38           for SERVICE in * ; do
39             case "${SERVICE}" in
40               functions | halt | killall | single| linuxconf| kudzu | \
41                   *rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
42                   ;;
43               *)
44                 if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
45                   env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" status
46                 fi
47                 ;;
48             esac
49           done
50           exit 0
51        elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
52           SERVICE="${1}"
53           if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
54             env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" stop
55             env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" start
56             exit $?
57           fi
58        elif [ -z "${SERVICE}" ]; then
59          SERVICE="${1}"
60        else
61          OPTIONS="${OPTIONS} ${1}"
62        fi
63        shift
64        ;;
65    esac
66 done
67
68 if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
69    env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${OPTIONS}
70 else
71    echo "${SERVICE}: unrecognized service" >&2
72    exit 1
73 fi
This page took 0.102574 seconds and 3 git commands to generate.