systemd restart service on resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to find a way to get a service to restart when the system is
resumed from suspend or hibernation. I can get something to run when the
system is put to sleep by using sleep.target (for example, I have an
"ssh-suspend" service that kills all the ssh sessions because they are
always hung after a resume and I have to close the windows manually
anyway), but I haven't figured out the exact incantation to get a
service to restart on resume. Saying "After=sleep.target" has not
worked, and there doesn't seem to be anything like a resume.target or
wakeup.target . Here's an example service file:

[Unit]
Description=Restart IPSEC tunnel on resume
After=sleep.target NetworkManager-wait-online.service

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart racoon
RemainAfterExit=yes

[Install]
WantedBy=sleep.target

(I have tried it both with and without the Install section). 

This service never runs:

# systemctl status racoon-resume.service
racoon-resume.service - Restart IPSEC tunnel on resume
   Loaded: loaded (/etc/systemd/system/racoon-resume.service; enabled)
   Active: active (exited) since Sat 2013-11-23 18:29:48 MST; 2 weeks 0
days ago
 Main PID: 2605 (code=exited, status=0/SUCCESS)
   CGroup: name=systemd:/system/racoon-resume.service

Nov 23 18:29:48 cobweb.gregandeva.net systemd[1]: Starting Restart IPSEC
tunnel on resume...
Nov 23 18:29:48 cobweb.gregandeva.net systemd[1]: Started Restart IPSEC
tunnel on resume.

That was from when I tested it manually. So how to I program it to
restart a service upon resume?

The real problem is that the racoon daemon (which negotiates IKE keys
for an IPSEC tunnel) stops working after a suspend/resume, and needs to
be restarted on resume in order for the tunnel to work again.

I have this service file that starts and stops the tunnel at
boot/shutdown time, and this works fine:

[Unit]
Description=IPSEC Tunnel Service
After=syslog.target
After=network.target

[Service]
Type=forking
ExecStart=/local/etc/racoon.rc
ExecStop=/usr/bin/pkill racoon
ExecStopPost=/usr/sbin/setkey -FP
PIDFile=/var/run/racoon.pid

[Install]
WantedBy=multi-user.target
Alias=racoon.service


--Greg

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux