You are not logged in.

#1 2017-10-18 19:08:52

naamkyda
Member
Registered: 2017-10-01
Posts: 1

Restart openvpn-client service after resume

Hi,

I want to restart openvpn service unit after resume from sleep, because connection is frozen once I suspend and then resume normally. (However I've run into some problems I list below...)
This is my systemd resume hook:

[Unit]
Description=User resume actions
After=suspend.target
Before=openvpn-client@protonvpn.service

[Service]
Type=oneshot
ExecStart=

[Install]
Wants=openvpn-client@protonvpn.service
WantedBy=suspend.target

This is my openvpn-client template:

[Unit]
Description=OpenVPN tunnel for %I
After=syslog.target network-online.target
Wants=network-online.target
Documentation=man:openvpn(8)
Documentation=https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
Documentation=https://community.openvpn.net/openvpn/wiki/HOWTO

[Service]
Type=notify
PrivateTmp=true
WorkingDirectory=/etc/openvpn/client
ExecStart=+/usr/bin/openvpn --suppress-timestamps --nobind --config %i.conf
ExecStartPre=+/home/adam/my_scripts/IPv6Disable
ExecStopPost=+/home/adam/my_scripts/IPv6Enable
CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_DAC_OVERRIDE
LimitNPROC=10
DeviceAllow=/dev/null rw
DeviceAllow=/dev/net/tun rw
ProtectSystem=true
ProtectHome=true
KillMode=process

[Install]
WantedBy=multi-user.target

However, I get this errors with

systemctl status openvpn-client@protonvpn.service

:

Oct 18 20:55:07 archmachine systemd[1]: /etc/systemd/system/resume@.service:11: Unknown lvalue 'Wants' in section 'Install'
Oct 18 20:55:07 archmachine systemd[1]: resume@adam.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

Since resume service type is oneshot, it should be ok to not list any commands (quote from systemd.service man page):

When Type=oneshot is used, zero or more commands may be specified...If the empty string is assigned to this option, the list of commands to start is reset, prior assignments of this option will have no effect.

Also, I can't understand, why 'Wants' is unknown, since the same string is in the Unit section and it doesn't complain about it there...

I would appreciate any help or ideas why these issues could arise, thanks in advance!

Offline

#2 2022-11-19 06:37:14

mikael
Member
From: Slovakia
Registered: 2011-05-22
Posts: 27
Website

Re: Restart openvpn-client service after resume

Offline

Board footer

Powered by FluxBB