Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save george124816/d254cc335652ddc6e832e257fde25065 to your computer and use it in GitHub Desktop.
Save george124816/d254cc335652ddc6e832e257fde25065 to your computer and use it in GitHub Desktop.
vpn
#!/bin/bash
# Check if exactly one argument is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 {up|down}"
exit 1
fi
# Get the argument
ACTION=$1
# Validate the argument and execute the corresponding nmcli command
case $ACTION in
up)
nmcli connection up work
;;
down)
nmcli connection down work
;;
*)
echo "Invalid argument: $ACTION"
echo "Usage: $0 {up|down}"
exit 1
;;
esac
# Check if the nmcli command succeeded
if [ $? -eq 0 ]; then
echo "Network connection 'work' is $ACTION"
else
echo "Failed to set network connection 'work' to $ACTION"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment