[ Take me back! | To Do List | Stuff I'm Working on Now | Completed Projects ]
...nothing at this moment, besides this website...
For reasons I can't fathom, Discord goes through the trouble of packaging their application in the .deb format, however;
when a new update is released for linux, you're forced to download and install the application again. I'm lazy, so I tried to automate that process.
The script starts by assigning network_status to the output of network manager command line interface. -t means that the command will not
output labels for each field. -f STATE means that the command will only output the information in the state field. When there is an internet
connection, network_status will be assigned to the string 'connected' and if there is no internet it will be assigned to the string 'disconnected'.
The until loop therefore will prevent the rest of the program from running until there is an internet connection. Then, /usr/bin/wget
is called to download the latest linux release for Discord, outputting it to a file called 'discord.deb' in the directory /tmp.
This directory is used because it clears after every reboot. /usr/bin/apt-get is then called to install the downloaded package.
The snippet || echo "install failed, attemping again..." means that if apt-get fails the script will print that text in the terminal.
The whole script is an infinetely looping while loop, so the script will attempt to download a viable package again.
&& break will run when apt-get exits successfully, either installing the updated version of Discord, or seeing that the latest version is installed already.
Break exits the infintely running loop, allowing the script to end.
All this happens automatically in the background by adding it to the root crontab and telling the system to run the script @reboot, so I never have to give it a second thought
While this script isn't particularly graceful or optimized, to me that's the beauty of a scripting language. You can use a relatively simple language to automate
a relatively simple task. I'm proud of this work as my first functional Bash script because I learned so much figuring out how to make it work.