diff --git a/service/service b/service/service index 2e5b421..577fae9 100644 --- a/service/service +++ b/service/service @@ -8,7 +8,10 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin export PATH VERSION="service version 0.91-alt" -SERVICEDIR="/etc/init.d" +SERVICEDIR=/etc/init.d +SYSTEMCTL=/bin/systemctl +SYSTEMD_SERVICE_DIR=/lib/systemd/system +SYSTEMD_CGROUP_DIR=/sys/fs/cgroup/systemd SERVICE= OPTIONS= @@ -36,6 +39,9 @@ check_service() fatal "$SERVICE: Invalid service name" [ -x "$SERVICEDIR/$SERVICE" ] || + [ -x "$SYSTEMCTL" -a \ + -d "$SYSTEMD_CGROUP_DIR" -a \ + -f "$SYSTEMD_SERVICE_DIR/$SERVICE.service" ] || fatal "$SERVICE: Unrecognized service" } @@ -69,7 +75,11 @@ case "$1" in shift check_service cd / || exit - "$SERVICEDIR/$SERVICE" "$@" - exit $? + if [ -x "$SYSTEMCTL" -a -d "$SYSTEMD_CGROUP_DIR" ]; then + exec "$SYSTEMCTL" "$@" "$SERVICE.service" + else + exec "$SERVICEDIR/$SERVICE" "$@" + fi + exit ;; esac