Skip to content

Instantly share code, notes, and snippets.

@v2keener
Last active June 16, 2018 13:35
Show Gist options
  • Save v2keener/d08705d11dcd10369b8fba0fa11a3d48 to your computer and use it in GitHub Desktop.
Save v2keener/d08705d11dcd10369b8fba0fa11a3d48 to your computer and use it in GitHub Desktop.
Change /etc/network/interfaces as an idempotent transaction with /etc/network/new-interfaces as the new settings to try
#!/bin/bash
# This takes about 2 minutes, unless the /etc/network/new-interfaces works,
# in which case use atq and atrm to stop the "refresh-network-safely-at.txt"
# commands from happening
d=$(date +%Y%m%d-%H%M)
backup=$d-interfaces
cp /etc/network/interfaces /etc/network/$backup
cp /etc/network/interfaces /etc/network/temp-backup
cp /etc/network/new-interfaces /etc/network/interfaces
service networking restart
at now + 1 minutes -f /home/goose/refresh-network-safely-at.txt
#**
# refresh-network-safely-at.txt contents
#**
#uncomment the following and place into "refresh-network-safely-at.txt
#cp /etc/network/interfaces /etc/network/$(date +%Y%m%d-%H%M)-non-working-interfaces
#cp /etc/network/temp-backup /etc/network/interfaces
#service networking restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment