Skip to content

Instantly share code, notes, and snippets.

@stigok
Created July 13, 2017 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stigok/51eff22ed2ddf5137b807f49ce951e60 to your computer and use it in GitHub Desktop.
Save stigok/51eff22ed2ddf5137b807f49ce951e60 to your computer and use it in GitHub Desktop.
Make openvpn reconnect when a network interface goes up
#!/bin/bash
# Initiates reconnect of the openvpn process
#
# Made for /etc/NetworkManager/dispatcher.d/, but should be working
# for /etc/network/if-up.d/ as well.
#
IFACE=$1
ACTION=$2
# If a device has gone up and it's not a tun device, send SIGHUP to openvpn
if [[ "${IFACE:0:3}" != 'tun' && "${ACTION}" = 'up' ]]; then
logger 'Restarting openvpn process (if running).'
pkill -SIGHUP openvpn
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment