initscripts/sbin/service

46 lines
818 B
Plaintext
Raw 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 [ -d /run/systemd ]; then
systemctl ${OPTIONS} ${SERVICE}.service
elif [ -x "${INITDDIR}/${SERVICE}" ]; then
2011-04-26 12:26:24 +02:00
env -i PATH="$PATH" TERM="$TERM" "${INITDDIR}/${SERVICE}" ${OPTIONS}
else
echo "${SERVICE}: "$"unrecognized service" >&2
exit 1
fi