On Mon, Apr 14, 2014 at 11:42:52AM +0000, Sam Morris wrote: > Package: anacron > Version: 2.3-19 > Severity: normal > Tags: patch > > Anacron currently ships a pm-utils hook script that starts the service > when the system is resumed. pm-utils hooks are not executed when the > system resumes, having been suspended by systemd. > > Systemd provides a directory, /usr/lib/systemd/system-sleep that seems > to be the closest equivalent to the pm-utils hook directory. A script > such as the following can be dropped in there (untested!): > > #!/bin/bash > case "$1" in > post) > systemctl --fail --no-block start anacron.service > ;; > suspend|hibernate|hybrid-sleep) > systemctl --fail --no-block stop anacron.service > ;; > esac > > Note that the systemd-sleep(8) man page says that this directory is a > hack for local use only. A better way would be to add this to > anacron.service: > > [Unit] > Conflicts=sleep.target > Before=sleep.target > > Which will stop anacron when the system is suspended/hibernated; and to > create a new unit, anacron-resume.service: > > [Unit] > After=systemd-suspend.service systemd-hibernate.service > systemd-hybrid-sleep.service > [Service] > ExecStart=/bin/systemctl --no-block --fail start anacron.service > [Install] > WantedBy=sleep.target > > Which will start anacron when the system comes back.
I'm not convinced that the second solution is better. Actually, I think the first proposal is probably the slightly less ugly one. I would simplify the first solution a bit though, and simply run a try-restart on post, i.e. something like this #!/bin/bash [ "$1" = "post" ] && systemctl try-restart anacron.service Lennart, do you have better solution for such services which need to be restarted on suspend/resume? Cheers, Michael _______________________________________________ Pkg-systemd-maintainers mailing list Pkg-systemd-maintainers@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-systemd-maintainers