reassign 732341 initscripts
retitle 732341 initscripts: invoke-rc.d should strip .sh suffix from
name when invoking systemctl
tag 732341 patch
thanks

Hi,

I stumbled upon the same bug as the original bug reporter. Systemd drops
the .sh suffix from init scripts in /etc/init.d when translating sysv
script filenames in /etc/init.d to a corresponding systemd .service name
(see:
http://sources.debian.net/src/systemd/204-5/src/core/service.c?hl=337#L337)

Hence, invoke-rc.d should strip the .sh suffix as well, if present,
before invoking systemctl.

A patch for invoke-rc.d is attached.

Best,
Matthias
diff -Nru sysvinit-2.88dsf/debian/src/sysv-rc/sbin/invoke-rc.d sysvinit-2.88dsf/debian/src/sysv-rc/sbin/invoke-rc.d
--- sysvinit-2.88dsf/debian/src/sysv-rc/sbin/invoke-rc.d	2013-07-14 22:57:26.000000000 +0200
+++ sysvinit-2.88dsf/debian/src/sysv-rc/sbin/invoke-rc.d	2013-12-19 22:20:51.000000000 +0100
@@ -390,7 +390,10 @@
 if [ -n "$is_upstart" ]; then
     _executable=1
 elif [ -n "$is_systemd" ]; then
-    _state=$(systemctl -p LoadState show "${INITSCRIPTID}.service" 2>/dev/null)
+    # For SysV services systemd strips the *.sh suffix
+    SYSTEMDSERVICE="${INITSCRIPTID%.sh}.service"
+
+    _state=$(systemctl -p LoadState show "${SYSTEMDSERVICE}" 2>/dev/null)
     if [ "$_state" != "LoadState=masked" ]; then
         _executable=1
     fi
@@ -517,27 +520,30 @@
                     # pick up any changes.
                     systemctl daemon-reload
                 fi
+		# For SysV services systemd strips the *.sh suffix
+                SYSTEMDSERVICE="${INITSCRIPTID%.sh}.service"
+
                 case $saction in
                     start|stop|restart|status)
-                        systemctl "${saction}" "${INITSCRIPTID}.service" && exit 0
+                        systemctl "${saction}" "${SYSTEMDSERVICE}" && exit 0
                         ;;
                     reload)
-                        _canreload="$(systemctl -p CanReload show ${INITSCRIPTID}.service 2>/dev/null)"
+                        _canreload="$(systemctl -p CanReload show ${SYSTEMDSERVICE} 2>/dev/null)"
                         if [ "$_canreload" = "CanReload=no" ]; then
                             "${INITDPREFIX}${INITSCRIPTID}" "${saction}" "$@" && exit 0
                         else
-                            systemctl reload "${INITSCRIPTID}.service" && exit 0
+                            systemctl reload "${SYSTEMDSERVICE}" && exit 0
                         fi
                         ;;
                     force-stop)
-                        systemctl --signal=KILL kill "${INITSCRIPTID}.service" && exit 0
+                        systemctl --signal=KILL kill "${SYSTEMDSERVICE}" && exit 0
                         ;;
                     force-reload)
-                        _canreload="$(systemctl -p CanReload show ${INITSCRIPTID}.service 2>/dev/null)"
+                        _canreload="$(systemctl -p CanReload show ${SYSTEMDSERVICE} 2>/dev/null)"
                         if [ "$_canreload" = "CanReload=no" ]; then
-                           systemctl restart "${INITSCRIPTID}.service" && exit 0
+                           systemctl restart "${SYSTEMDSERVICE}" && exit 0
                         else
-                           systemctl reload "${INITSCRIPTID}.service" && exit 0
+                           systemctl reload "${SYSTEMDSERVICE}" && exit 0
                         fi
                         ;;
                     *)

Reply via email to