Skip to content

Instantly share code, notes, and snippets.

View o-kotb's full-sized avatar

Omar Kotb o-kotb

View GitHub Profile
@o-kotb
o-kotb / setoldnmdefault.sh
Last active January 7, 2024 20:13
Sets all existing wifi networks' cloned-mac-address to preserve, the previous default, if they didn't have one set already.
#!/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"