Created
June 13, 2024 12:17
-
-
Save george124816/d254cc335652ddc6e832e257fde25065 to your computer and use it in GitHub Desktop.
vpn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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