Control: reassign -1 src:sysvinit 2.88dsf-43
Control: retitle -1 service incorrectly handles console-screen.service
Control: affects console-tools -1

On Wed, Oct 16, 2013 at 09:50:15AM +0200, David Weinehall wrote:
> When upgrading to the latest version of console-tools, I received the
> following error message:
> 
> Setting up console-tools (2:0.2.3-71) ...
> update-rc.d: warning: start and stop actions are no longer supported;
> falling back to defaults
> Failed to issue method call: Unit console-screen.sh.service failed to
> load: No such file or directory. See system logs and 'systemctl status
> console-screen.sh.service' for details.

“/etc/init.d/console-screen.sh start” works fine but neither “service
console-screen.sh start” nor the equivalent invoke-rc.d does.

The difference is that /lib/lsb/init-functions.d/40-systemd correctly
trims the .sh off the service name while service does not.  The attached
patch addresses the issue in both service and invoke-rc.d

James
diff -Nru sysvinit-2.88dsf/debian/changelog sysvinit-2.88dsf/debian/changelog
--- sysvinit-2.88dsf/debian/changelog	2013-07-16 16:10:10.000000000 -0400
+++ sysvinit-2.88dsf/debian/changelog	2013-10-17 09:47:20.000000000 -0400
@@ -1,3 +1,12 @@
+sysvinit (2.88dsf-43.1) UNRELEASED; urgency=low
+
+  * Non-maintainer upload.
+  * sysv-rc:
+    - Update invoke-rc.d and service to trim .sh from service names when
+      calling systemctl.
+
+ -- James McCoy <james...@debian.org>  Thu, 17 Oct 2013 09:42:55 -0400
+
 sysvinit (2.88dsf-43) unstable; urgency=low
 
   [ Roger Leigh ]
diff -Nru sysvinit-2.88dsf/debian/service/service sysvinit-2.88dsf/debian/service/service
--- sysvinit-2.88dsf/debian/service/service	2013-07-14 16:57:26.000000000 -0400
+++ sysvinit-2.88dsf/debian/service/service	2013-10-17 09:40:50.000000000 -0400
@@ -163,9 +163,10 @@
 # systemctl calls.
 if [ -n "$is_systemd" ]
 then
+   UNIT="${SERVICE%.sh}.service"
    case "${ACTION}" in
       restart|status)
-         exec systemctl ${ACTION} ${SERVICE}.service
+         exec systemctl ${ACTION} ${UNIT}
       ;;
       start|stop)
          # Follow the principle of least surprise for SysV people:
@@ -173,32 +174,32 @@
          # has one or more .socket files, we also stop the .socket units.
          # Users who need more control will use systemctl directly.
          for unit in $(systemctl list-unit-files --full --type=socket 2>/dev/null | sed -ne 's/\.socket\s*[a-z]*\s*$/.socket/p'); do
-             if [ "$(systemctl -p Triggers show $unit)" = "Triggers=${SERVICE}.service" ]; then
+             if [ "$(systemctl -p Triggers show $unit)" = "Triggers=${UNIT}" ]; then
                 systemctl ${ACTION} $unit
              fi
          done
-         exec systemctl ${ACTION} ${SERVICE}.service
+         exec systemctl ${ACTION} ${UNIT}
       ;;
       reload)
-         _canreload="$(systemctl -p CanReload show ${SERVICE}.service 2>/dev/null)"
+         _canreload="$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
          if [ "$_canreload" = "CanReload=no" ]; then
             # The reload action falls back to the sysv init script just in case
             # the systemd service file does not (yet) support reload for a
             # specific service.
             run_via_sysvinit
          else
-            exec systemctl reload "${SERVICE}.service"
+            exec systemctl reload "${UNIT}"
          fi
          ;;
       force-stop)
-         exec systemctl --signal=KILL kill "${SERVICE}.service"
+         exec systemctl --signal=KILL kill "${UNIT}"
          ;;
       force-reload)
-         _canreload="$(systemctl -p CanReload show ${SERVICE}.service 2>/dev/null)"
+         _canreload="$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
          if [ "$_canreload" = "CanReload=no" ]; then
-            exec systemctl restart "${SERVICE}.service"
+            exec systemctl restart "${UNIT}"
          else
-            exec systemctl reload "${SERVICE}.service"
+            exec systemctl reload "${UNIT}"
          fi
          ;;
       *)
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 16:57:26.000000000 -0400
+++ sysvinit-2.88dsf/debian/src/sysv-rc/sbin/invoke-rc.d	2013-10-17 09:42:46.000000000 -0400
@@ -276,6 +276,7 @@
     is_upstart=1
 elif test -d /run/systemd/system ; then
     is_systemd=1
+    UNIT="${INITSCRIPTID%.sh}.service"
 elif test ! -f "${INITDPREFIX}${INITSCRIPTID}" ; then
     ## Verifies if the given initscript ID is known
     ## For sysvinit, this error is critical
@@ -390,7 +391,7 @@
 if [ -n "$is_upstart" ]; then
     _executable=1
 elif [ -n "$is_systemd" ]; then
-    _state=$(systemctl -p LoadState show "${INITSCRIPTID}.service" 2>/dev/null)
+    _state=$(systemctl -p LoadState show "${UNIT}" 2>/dev/null)
     if [ "$_state" != "LoadState=masked" ]; then
         _executable=1
     fi
@@ -519,25 +520,25 @@
                 fi
                 case $saction in
                     start|stop|restart|status)
-                        systemctl "${saction}" "${INITSCRIPTID}.service" && exit 0
+                        systemctl "${saction}" "${UNIT}" && exit 0
                         ;;
                     reload)
-                        _canreload="$(systemctl -p CanReload show ${INITSCRIPTID}.service 2>/dev/null)"
+                        _canreload="$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
                         if [ "$_canreload" = "CanReload=no" ]; then
                             "${INITDPREFIX}${INITSCRIPTID}" "${saction}" "$@" && exit 0
                         else
-                            systemctl reload "${INITSCRIPTID}.service" && exit 0
+                            systemctl reload "${UNIT}" && exit 0
                         fi
                         ;;
                     force-stop)
-                        systemctl --signal=KILL kill "${INITSCRIPTID}.service" && exit 0
+                        systemctl --signal=KILL kill "${UNIT}" && exit 0
                         ;;
                     force-reload)
-                        _canreload="$(systemctl -p CanReload show ${INITSCRIPTID}.service 2>/dev/null)"
+                        _canreload="$(systemctl -p CanReload show ${UNIT} 2>/dev/null)"
                         if [ "$_canreload" = "CanReload=no" ]; then
-                           systemctl restart "${INITSCRIPTID}.service" && exit 0
+                           systemctl restart "${UNIT}" && exit 0
                         else
-                           systemctl reload "${INITSCRIPTID}.service" && exit 0
+                           systemctl reload "${UNIT}" && exit 0
                         fi
                         ;;
                     *)

Reply via email to