Created
December 15, 2022 21:06
-
-
Save dcode/4216283865f888022ca41f77c8e813a4 to your computer and use it in GitHub Desktop.
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 | |
# Place at /etc/NetworkManager/dispatcher.d/15-activate_home_vlans.sh | |
# chown root:root | |
# chmod 0755 | |
# This is the UUID for the connection entry representing your home network (mine is called "Wired - Home") | |
HOME_UUID="c09ab0ba-58e0-4c89-ad52-58bd39a63ad4" | |
# This is an array listing all the VLAN connections (or others, I guess) | |
# that you want to de/activate when you connect to the home network | |
declare -a VLAN_UUIDS=("744ebcbc-bdd8-4040-874e-5b366b1d7f30") | |
if [ "$CONNECTION_UUID" = "${HOME_UUID}" ]; then | |
# Loop over all the connection UUIDs for VLANs | |
for VLAN_UUID in "${VLAN_UUIDS[@]}"; do | |
if [ "$2" = "down" ]; then | |
nmcli connection down "${VLAN_UUID}" | |
elif [ "$2" = "up" ]; then | |
nmcli connection up "${VLAN_UUID}" | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment