]> git.pld-linux.org Git - projects/rc-scripts.git/blob - service
- --upstart and --no-upstart options to /sbin/service
[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 USE_UPSTART=
13
14 if [ -d /etc/rc.d/init.d ]; then
15         SERVICEDIR="/etc/rc.d/init.d"
16 else
17         SERVICEDIR="/etc/init.d"
18 fi
19
20 if [ $# -eq 0 ]; then
21         echo "${USAGE}" >&2
22         exit 1
23 fi
24
25 cd /
26 while [ $# -gt 0 ]; do
27         case "${1}" in
28           --help | -h | --h* )
29                 echo "${USAGE}" >&2
30                 exit 0
31                 ;;
32           --version | -V )
33                 echo "${VERSION}" >&2
34                 exit 0
35                 ;;
36           --upstart)
37                 USE_UPSTART=yes
38                 shift
39                 ;;
40           --no-upstart)
41                 USE_UPSTART=no
42                 shift
43                 ;;
44           *)
45                 if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
46                         cd ${SERVICEDIR}
47                         for SERVICE in * ; do
48                                 case "${SERVICE}" in
49                                   functions | halt | killall | single| linuxconf| kudzu | \
50                                   *rpmorig | *rpmnew | *rpmsave | *~ | *.orig)
51                                         ;;
52                                   *)
53                                         if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
54                                                 env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" status
55                                         fi
56                                         ;;
57                                 esac
58                         done
59                         exit 0
60                 elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
61                         SERVICE="${1}"
62                         if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
63                                 env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" stop
64                                 env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" start
65                                 exit $?
66                         fi
67                 elif [ -z "${SERVICE}" ]; then
68                         SERVICE="${1}"
69                 else
70                         OPTIONS="${OPTIONS} ${1}"
71                 fi
72                 shift
73                 ;;
74         esac
75 done
76
77 if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
78         env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${OPTIONS}
79 else
80         echo "${SERVICE}: unrecognized service" >&2
81         exit 1
82 fi
This page took 0.065944 seconds and 4 git commands to generate.