You are not logged in.

#1 2017-08-15 01:20:12

twifty
Member
Registered: 2017-08-15
Posts: 3

NetworkManager dispatch scripts

I'm moving a networking/if-up.d script over to NetworkManager/dispatcher.d, originally written for Ubuntu.

The script connects to a vpn, which uses the command line expressvpn package, and configures a few iptable rules. The following 3 lines are giving me problems:

systemctl restart expressvpn.service &>> /var/log/net-up.log
/usr/bin/expressvpn disconnect &>> /var/log/net-up.log
/usr/bin/expressvpn connect &>> /var/log/net-up.log

The idea is to restart the service, drop any active connections and then reconnect. Running the commands '/usr/bin/expressvpn *connect' from the terminal as both normal user and sudo work without problems, but from the dispatcher script they cause errors:

"It seems the expressvpn daemon is not running. Please run "sudo service expressvpn restart" to start it."

The "service restart" reference is due to the original package being a .deb

I have a feeling this is a permission issue, but I have no idea how to fix it.

Any help appreciated.

Upon further testing, if I comment the service restart line, the script works. But, I can no longer guarantee that the expressvpn service has been started (only a problem during system boot).

How can I configure the expressvpn.service to always start before NetworkManager.service?

Last edited by twifty (2017-08-15 01:54:58)

Offline

#2 2017-08-15 08:29:18

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,672

Re: NetworkManager dispatch scripts

https://wiki.archlinux.org/index.php/Sy … unit_files

Likely a

...
Wants=NetworkManager.service
Before=NetworkManager.service
...

Offline

Board footer

Powered by FluxBB