diff --git a/service/service b/service/service index 2e5b421..ef1f017 100644 --- a/service/service +++ b/service/service @@ -9,6 +9,8 @@ export PATH VERSION="service version 0.91-alt" SERVICEDIR="/etc/init.d" +SYSTEMCTL="/bin/systemctl" +SYSTEMDSERVICEDIR="/lib/systemd/system" SERVICE= OPTIONS= @@ -35,7 +37,7 @@ check_service() [ -n "${SERVICE##*/*}" ] || fatal "$SERVICE: Invalid service name" - [ -x "$SERVICEDIR/$SERVICE" ] || + [ -x "$SERVICEDIR/$SERVICE" ] || [ -x "$SYSTEMCTL" -a -f "$SYSTEMDSERVICEDIR/${SERVICE}.service" ] || fatal "$SERVICE: Unrecognized service" } @@ -69,7 +71,13 @@ case "$1" in shift check_service cd / || exit - "$SERVICEDIR/$SERVICE" "$@" + if [ -x "$SYSTEMCTL" ]; then + if [-f "$SYSTEMDSERVICEDIR/${SERVICE}.service" -o -x "$SERVICEDIR/$SERVICE" ]; then + exec $SYSTEMCTL "$@" ${SERVICE}.service + fi + elif [ -x "$SERVICEDIR/$SERVICE" ]; then + "$SERVICEDIR/$SERVICE" "$@" + fi exit $? ;; esac