Last active
January 7, 2024 20:13
-
-
Save o-kotb/59f02fc4de8fea54837333becbb78167 to your computer and use it in GitHub Desktop.
Sets all existing wifi networks' cloned-mac-address to preserve, the previous default, if they didn't have one set already.
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 | |
for nmprofile in /etc/NetworkManager/system-connections/*; do | |
# check if a cloned mac was already set | |
if grep -q "cloned-mac-address" "$nmprofile"; then | |
echo "$(basename "$nmprofile") already has a cloned mac address. No changes." | |
else | |
# If it doesn't have a [wifi] section, it's not a wifi network | |
if grep -q "\[wifi\]" "$nmprofile"; then | |
sed -i '/\[wifi\]/a cloned-mac-address=preserve' "$nmprofile" | |
echo "Set cloned-mac-address=preserve in $(basename "$nmprofile") profile." | |
else | |
echo "$(basename "$nmprofile") isn't a wifi network. No changes." | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment