You are not logged in.
I'm trying to stop any running openvpn@ service either prior to suspend or immediately after resume. I've got a service file enabled:
[Unit]
Description=Root suspend actions
Before=sleep.target
[Service]
Type=forking
ExecStart=-/home/firecat53/.local/bin/suspend.sh
[Install]
WantedBy=sleep.target
and the helper script suspend.sh:
#!/bin/sh
# Helper script to stop openvpn on suspend
/usr/bin/systemctl stop $(/usr/bin/systemctl | grep openvpn@ | awk '{print $1}')
The helper script works fine when run by itself, but it fails when run from the service file, and openvpn is still running. I've also tried it post-resume, with the same results.
# journalctl
....
Sep 18 19:56:54 scotty suspend.sh[10544]: Failed to issue method call: Invalid argument
$ systemctl status suspend.sh
suspend.service - Root suspend actions
Loaded: loaded (/etc/systemd/system/suspend.service; enabled)
Active: inactive (dead) since Wed 2013-09-18 19:56:54 PDT; 6min ago
Process: 10544 ExecStart=/home/firecat53/.local/bin/suspend.sh (code=exited, status=1/FAILURE)
Am I doing something wrong here, or is there another way to accomplish this?
Thanks!
Scott
Last edited by firecat53 (2013-09-20 03:52:57)
Offline
Maybe you could add
Conflicts=sleep.target
to the openvpn@ template?
Offline
Thanks for the tip! Solved by extending openvpn@.service in /etc/systemd/system/openvpn@.service.d/suspend_conflict.conf
[Unit]
Conflicts=suspend.target sleep.target
Now it kills the openvpn@ service on suspend and doesn't restart it automatically on resume, which is the behavior I was looking for.
Scott
Offline