]> git.pld-linux.org Git - projects/rc-scripts.git/blame - service
- setuidgid tool added (from freedt) as upstart doesn't provide facilities to
[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
bf14fcab
JR
7VERSION="$(basename $0) ver. 0.91"
8USAGE="Usage: $(basename $0) < option > | --status-all | \
763b88c2 9[ service_name [ command | --full-restart ] ]"
3b917b57 10
763b88c2 11SERVICE=
9fb27aac 12USE_UPSTART=
3b917b57 13
763b88c2 14if [ -d /etc/rc.d/init.d ]; then
1050f687 15 SERVICEDIR="/etc/rc.d/init.d"
763b88c2 16else
1050f687 17 SERVICEDIR="/etc/init.d"
763b88c2
AM
18fi
19
20if [ $# -eq 0 ]; then
1050f687
JR
21 echo "${USAGE}" >&2
22 exit 1
763b88c2
AM
23fi
24
a6c22d3d
AM
25cd /
26while [ $# -gt 0 ]; do
1050f687
JR
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 ;;
9fb27aac
JK
36 --upstart)
37 USE_UPSTART=yes
38 shift
39 ;;
40 --no-upstart)
41 USE_UPSTART=no
42 shift
43 ;;
1050f687
JR
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
9fb27aac 54 env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" status
1050f687
JR
55 fi
56 ;;
57 esac
58 done
59 exit 0
60 elif [ $# -eq 2 -a "${2}" = "--full-restart" ]; then
61 SERVICE="${1}"
55a9aa59 62 if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
9fb27aac
JK
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
1050f687
JR
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
763b88c2
AM
75done
76
77if [ -x "${SERVICEDIR}/${SERVICE}" ]; then
9fb27aac 78 env -i USE_UPSTART=$USE_UPSTART LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}" ${OPTIONS}
763b88c2 79else
1050f687
JR
80 echo "${SERVICE}: unrecognized service" >&2
81 exit 1
763b88c2 82fi
This page took 0.050717 seconds and 4 git commands to generate.