diff -up e-smith-base-5.8.0/root/sbin/e-smith/service.bz9672.servicesystemd e-smith-base-5.8.0/root/sbin/e-smith/service --- e-smith-base-5.8.0/root/sbin/e-smith/service.bz9672.servicesystemd 2016-02-04 18:14:13.000000000 -0500 +++ e-smith-base-5.8.0/root/sbin/e-smith/service 2016-07-23 09:28:59.034000000 -0400 @@ -1,13 +1,53 @@ #! /bin/sh +# prevent initscript to use systemctl +export SYSTEMCTL_SKIP_REDIRECT=1 +. /etc/rc.d/init.d/functions -runlevel=$(runlevel | cut -d" " -f2) +# what is our current runlevel +runlevel=$(systemctl get-default) +SERVICE=$1 +USAGE="Usage: service SERVICENAME [ACTION]" -if [ "$runlevel" = "4" ] +#if no servicename is provided return usage +if [[ "${SERVICE}" == "" ]] +then + echo ${USAGE} >&2 + exit +fi + +if [ "$runlevel" = "multi-user.target" ] then if ls /etc/rc7.d/S??$1 >/dev/null 2>/dev/null then script=$(ls /etc/rc7.d/S??$1 | head -1) exec $script $2 + + elif ls /usr/lib/systemd/system/${SERVICE}.service >/dev/null 2>/dev/null || ls /etc/systemd/system/${SERVICE}.service >/dev/null 2>/dev/null + then + if [[ "$2" == "" ]] ; then + echo "'$1' requires an action" 1>&2 + echo ${USAGE} >&2 + exit + elif [[ $2 == "status" ]] ; then + exec /bin/systemctl status -n0 ${SERVICE} + exit + elif [[ $2 == "start" ]] ; then + echo -n "Starting ${SERVICE}" 2>/dev/null + elif [[ $2 == "stop" ]] ; then + echo -n "Stopping ${SERVICE}" 2>/dev/null + elif [[ $2 == "restart" ]] ; then + echo -n "Restarting ${SERVICE}" 2>/dev/null + else + echo -n "Sending $2 signal to ${SERVICE}" 2>/dev/null + fi + /bin/systemctl $2 ${SERVICE}.service> /dev/null + if [ $? -ne 0 ]; then + echo_failure + else + echo_success + fi + echo + exit fi echo "'$1' is not a valid service name" 1>&2