[systemd-devel] condrestart/try-restart should not fail if service was inactive

Andrey Borzenkov arvidjaar at gmail.com
Mon Nov 1 10:47:54 PDT 2010


[System is Mandriva with systemd initscripts glue enabled]

systemd v11

In legacy initscripts condrestart implied "restart if active". Looking
at style guide (http://fedoraproject.org/wiki/Packaging:SysVInitScript#condrestart_and_try-restart)

condrestart|try-restart)
    rh_status_q || exit 0
    restart
    ;;

systemd unconditionally fails request in this case which is causing
failures in RPM scripts for disabled services:

{pts/1}% LC_ALL=C service cups status
cups.service - LSB: CUPS printing server daemon
          Loaded: loaded (/etc/rc.d/init.d/cups)
          Active: inactive (dead)
          CGroup: name=systemd:/systemd-1/cups.service
{pts/1}% GP_LANG=C sudo service cups condrestart
Restarting cups (via systemctl):  Job failed, see system logs for details.
                                                                [FAILED]
{pts/1}% sudo tail -1 /var/log/messages
Nov  1 20:35:14 cooker dbus-daemon: [system] Rejected send message, 2
matched rules; type="method_call", sender=":1.1173" (uid=501 pid=28397
comm="systemctl) interface="org.freedesktop.systemd1.Manager"
member="LoadUnit" error name="(unset)" requested_reply=0
destination="org.freedesktop.systemd1" (uid=0 pid=1
comm="/bin/systemd))

E.g.

{pts/1}% rpm -q --scripts hplip-hpijs-ppds
postinstall scriptlet (using /bin/sh):
# Restart CUPS to make the printing PPDs known to it
if [ -f /etc/init.d/cups ]; then
        /sbin/service cups condrestart || :
fi
postuninstall scriptlet (using /bin/sh):
# Restart CUPS to make the removal of the printing PPDs known to it
if [ -f /etc/init.d/cups ]; then
        /sbin/service cups condrestart || :
fi

With result

    78/84: hplip-hpijs-ppds      #############################################
Restarting cups (via systemctl):  Job failed, see system logs for details.
                                                                [ ОШИБКА ]


More information about the systemd-devel mailing list