@@ -36,7 +36,7 @@ while [ $# -gt 0 ]; do
3636 shift
3737 ;;
3838 * )
39- if [ -z " ${SERVICE} " -a $# -eq 1 -a " ${1} " = " --status-all" ]; then
39+ if [ -z " ${SERVICE} " ] && [ $# -eq 1 ] && [ " ${1} " = " --status-all" ]; then
4040 cd ${SERVICEDIR}
4141 for SERVICE in * ; do
4242 case " ${SERVICE} " in
@@ -51,7 +51,7 @@ while [ $# -gt 0 ]; do
5151 esac
5252 done
5353 exit 0
54- elif [ $# -eq 2 -a " ${2} " = " --full-restart" ]; then
54+ elif [ $# -eq 2 ] && [ " ${2} " = " --full-restart" ]; then
5555 SERVICE=" ${1} "
5656 if [ -x " ${SERVICEDIR} /${SERVICE} " ]; then
5757 env -i PATH=" $PATH " TERM=" $TERM " " ${SERVICEDIR} /${SERVICE} " stop
7373if [ -f " ${SERVICEDIR} /${SERVICE} " ]; then
7474 # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes
7575 # lets reap them before next start
76- if [ " ${ACTION} " = " start" ] && \
77- systemctl show -p ActiveState ${SERVICE} .service | grep -q ' = active$ ' && \
78- systemctl show -p SubState ${SERVICE} .service | grep -q ' = exited$ ' ; then
76+ if [ " ${ACTION} " = ' start' ] && \
77+ [ " $( systemctl show -p ActiveState ${SERVICE} .service --value ) " = ' active' ] && \
78+ [ " $( systemctl show -p SubState ${SERVICE} .service --value ) " = ' exited' ] ; then
7979 /bin/systemctl stop ${SERVICE} .service
8080 fi
81+
82+ # Workaround to be able to "stop" network.service when it's in inactive state using service instead of systemctl
83+ # Useful for manual testing of network
84+ if [ " ${SERVICE} " = ' network' ] && [ " ${ACTION} " = ' stop' ] && \
85+ [ " $( systemctl show -p ActiveState network.service --value) " = ' inactive' ] && \
86+ [ " $( systemctl show -p SourcePath network.service --value) " = ' /etc/rc.d/init.d/network' ]; then
87+ export SYSTEMCTL_SKIP_REDIRECT=1
88+ fi
89+
8190 env -i PATH=" $PATH " TERM=" $TERM " SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} " ${SERVICEDIR} /${SERVICE} " ${ACTION} ${OPTIONS}
8291elif [ -n " ${ACTION} " ] && [ -x " ${ACTIONDIR} /${SERVICE} /${ACTION} " ]; then
8392 env -i PATH=" $PATH " TERM=" $TERM " SYSTEMCTL_IGNORE_DEPENDENCIES=${SYSTEMCTL_IGNORE_DEPENDENCIES} SYSTEMCTL_SKIP_REDIRECT=${SYSTEMCTL_SKIP_REDIRECT} " ${ACTIONDIR} /${SERVICE} /${ACTION} " ${OPTIONS}
84- elif ` echo $ACTION | grep -Eqw " start|stop|restart|try-restart|reload|force-reload|status|condrestart" ` ; then
93+ elif [[ $ACTION =~ start| stop| restart| try-restart| reload| force-reload| status| condrestart ]] ; then
8594 SERVICE_MANGLED=$( /usr/bin/systemd-escape --mangle ${SERVICE} )
8695 echo $" Redirecting to /bin/systemctl ${ACTION}${OPTIONS: + }${OPTIONS} ${SERVICE_MANGLED} " >&2
8796 exec /bin/systemctl ${ACTION} ${OPTIONS} ${SERVICE_MANGLED}
0 commit comments