initscripts/sbin/service

44 lines
744 B
Plaintext
Raw Permalink Normal View History

2011-04-26 12:26:24 +02:00
#!/bin/sh
#
# Simple service execution tool
USAGE=$"Usage: ""$0 [service_name [start|stop|restart|..]]"
VERSION="${0##*/} ver. 0.61"
INITDDIR="/etc/init.d"
SERVICE=
OPTIONS=
if [ $# -eq 0 ]; then
echo "${USAGE}" >&2
exit 1
fi
while [ $# -gt 0 ]; do
case "$1" in
--help | -h)
echo "${USAGE}" >&2
exit 0
;;
--version | -V)
echo "${VERSION}" >&2
exit 0
;;
*)
if [ -z "${SERVICE}" ]; then
SERVICE="${1}"
else
OPTIONS="${OPTIONS} ${1}"
fi
shift
;;
esac
done
if [ -x "${INITDDIR}/${SERVICE}" ]; then
env -i PATH="$PATH" TERM="$TERM" "${INITDDIR}/${SERVICE}" ${OPTIONS}
else
echo "${SERVICE}: "$"unrecognized service" >&2
exit 1
fi