Add /sbin/service helper script

This commit is contained in:
Calin Crisan 2019-12-27 23:34:05 +02:00
parent a686131ce1
commit 6340380d0d

View File

@ -0,0 +1,24 @@
#!/bin/bash
function show_usage() {
echo "Usage: service <service_name> [command]"
echo "Usual commands include: start, stop, restart"
echo "Type 'service <service_name>' without command for service-specific usage"
}
if [[ -z "$1" ]]; then
show_usage 1>&2
exit 1
fi
SERVICE=$1
shift # Remove $1
SCRIPT=(/etc/init.d/S*${SERVICE})
if ! [[ -x "${SCRIPT}" ]]; then
echo "No such service: ${SERVICE}"
exit 1
fi
source ${SCRIPT} "$@"