bash

So I have a couple of routers connected to my network each linking to a different ISP. When an ISP goes down, I want to easily switch ISPs from the command line and these are the couple of lines I use to do so:


#!/bin/bash

sudo ip route del default

if [ $1 == 'isp1' ]
then
echo "Switching ISP to $1"
sudo ip route add default via 192.168.1.1
else
echo "Switch ISP to ISP2"
sudo ip route add default via 192.168.0.1
fi

So, here I was writing a script that would automate the installation of a package in Ubuntu 14.04 and all was going swimmingly. Until I ran it. You know how some apt-get installs sometimes involve a technicolor pop-up that asks you for stuff? Well, those pop-ups interrupted my script which didn't proceed further. After much digging, I found that there are a couple of solutions for this:

All times are UTC. All content licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.