Skip to content

Instantly share code, notes, and snippets.

@tskrynnyk
Created December 6, 2012 19:19
Show Gist options
  • Select an option

  • Save tskrynnyk/4227436 to your computer and use it in GitHub Desktop.

Select an option

Save tskrynnyk/4227436 to your computer and use it in GitHub Desktop.
NetworkManager dispatcher for connect to a VPN after a network-connection is established.
#! /bin/bash
IF_NAME="Ifupdown (eth0)"
VPN_NAME="My VPN" # default VPN
active_if=$(nmcli con status | grep "${IF_NAME}")
#active_vpn=$(nmcli con status | grep "${VPN_NAME}")
active_vpn=$(nmcli -t -f VPN con status | grep 'yes')
if [ "${active_if}" -a ! "${active_vpn}" ]; then
su tomasz -c "nmcli con up id \"${VPN_NAME}\""
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment