Skip to content

Instantly share code, notes, and snippets.

@neuthral
Created November 11, 2018 14:17
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 neuthral/d176e0c8906f8d515417113964fcc512 to your computer and use it in GitHub Desktop.
Save neuthral/d176e0c8906f8d515417113964fcc512 to your computer and use it in GitHub Desktop.
vpn autoconnect #cli #network
#! /bin/bash
REQUIRED_CONNECTION_NAME="Wired connection 1"
VPN_CONNECTION_NAME="bender"
activ_con=$(nmcli con status | grep "${REQUIRED_CONNECTION_NAME}")
activ_vpn=$(nmcli con status | grep "${VPN_CONNECTION_NAME}")
if [ "${activ_con}" -a ! "${activ_vpn}" ];
then
nmcli con up id "${VPN_CONNECTION_NAME}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment