From b54210c1e18b2ae4d075572ff955fdc7c56b8d98 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Tue, 10 Dec 2019 11:40:51 +0100 Subject: Fix service network stop cmd --- usr/sbin/service | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usr/sbin/service b/usr/sbin/service index 31d8f3e1..b4712002 100755 --- a/usr/sbin/service +++ b/usr/sbin/service @@ -78,6 +78,13 @@ if [ -f "${SERVICEDIR}/${SERVICE}" ]; then systemctl show -p SubState ${SERVICE}.service | grep -q '=exited$' ; then /bin/systemctl stop ${SERVICE}.service fi + # Workaround to be able to "stop" network.service when it's in inactive state using service instead of systemctl + # Useful for manual testing of network + if [ "${SERVICE}" = 'network' ] && [ "${ACTION}" = 'stop' ] && \ + [ "$(systemctl show -p ActiveState network.service --value)" = 'inactive' ] && \ + [ "$(systemctl show -p SourcePath network.service --value)" = '/etc/rc.d/init.d/network' ]; then + export SYSTEMCTL_SKIP_REDIRECT=1 + fi env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${SERVICEDIR}/${SERVICE}" ${ACTION} ${OPTIONS} elif [ -n "${ACTION}" ] && [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" ]; then env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS} -- cgit v1.2.1