Apr 27
My simple goal is to check what my IP is and run a command correspondingly. My reason is that my laptop's IP is always assigned by DHCP and when I am at home it is always 192.168.0.5. Assume I want to update my Ubuntu regularly but only when I am at home.
To automate the above task I would add the following to /etc/rc.local:
ip a |grep 192.168.0.15 && apt-get update; apt-get upgrade -y
This means that the command (apt-get update; apt-get upgrade -y) will be run only if the previous command is successful. You could grep not only for an IP, but for a whole network or any relative hint.


