#!/usr/bin/env bash clear if [ "$EUID" -ne '0' ]; then printf "%s\n\n" 'You must run this script as root/sudo.' exit 1 fi fname='/etc/network/interfaces' cnt=0 printf "%s\n\n" 'Disclaimer:' printf "%s\n\n%s\n%s\n\n" \ 'I take NO responsibility for your system'\''s internet not working after running this script. By continuing, you AGREE to this and fully understand the implications, and will not hold me accountable for any damages suffered on your behalf!' \ '[1] I fully understand and agree to continue using this script.' \ '[2] I want to exit this script and not go any further.' read -p 'Your choices are (1 or 2): ' user_agreement clear case "$user_agreement" in 1) clear;; 2) clear printf "%s\n\n" 'You have chosen to exit the script. Thank you for making the choice you believe was in your best interest - slyfox1186' exit 0 ;; esac if [ ! -f "$fname".bak ]; then sudo cp "$fname" "$fname".bak printf "%s\n\n" 'The "interfaces" file was just backed up as: interfaces.bak. You can find it in the same folder as the original.' read -p 'Press enter to continue.' clear fi show_changes_fn() { clear printf "%s\n\n%s\n\n" \ 'The new "interfaces" file contents are shown below.' \ '==================================================================================' cat "$fname" printf "\n%s\n\n%s\n\n%s\n\n%s\n%s\n\n" \ '==================================================================================' \ 'To activate the changes you must reboot your PC or execute commands such as "sudo if down; sudo if up"' \ 'Would you like the script to activate the changes now?' \ '[1] Yes' \ '[2] No' read -p 'Your choices are (1 or 2): ' enable_choice clear case "$enable_choice" in 1) sudo ifdown "$interface" sudo ip addr flush dev "$interface" 2>&1 sudo ifup "$interface" ;; 2) exit 0;; esac } activate_static_fn() { if [ -n "$1" ]; then add_ns="dns-nameservers $1" fi cat > "$fname" < "$fname" <