Several days ago, I was gazing at the Universal Install Script comic by Randall Munroe, wondering if he may not have solved all the world’s problems, save for the usual famine, war, poverty, education, corruption, and so on. But there’s a certain appeal to having THE one script to rule them all, and in BASH-ness bind them. Yes, I was bored, so I thought, let’s try it out.

This is going to be my attempt to run the Universal Install Script (UIS), not to be confused with the Unwarranted Self-Importance Syndrome, an affliction of many an Internet user, and then modify the script so it works smoothly, elegantly and without errors. Safely too. Let us.

The original (sin)

As conceived by Randall Munroe, UIS is a series of commands, executed one after another, invoking a bunch of package managers and other associated tools, all in order to help you install whatever is the first argument of your script. Hence $1. In the tooltip, he recommends using the -y flag and redirecting errors to /dev/null to minimize noise. I can agree with the latter, but answering Yes blindly to a whole bunch of system commands is probably not a task for the fainthearted. Oh yes, in the best fashion of those sub-100-IQ TV shows, don’t do this at home!

First attempt

I decided to use the script without modifications, only addition the STDERR redirection. To wit:

#!/bin/bash pip install "$1" 2>/dev/null easy_install "$1" 2>/dev/null brew install "$1" 2>/dev/null npm install "$1" 2>/dev/null yum install "$1" 2>/dev/null dnf install "$1" 2>/dev/null docker run "$1" 2>/dev/null pkg install "$1" 2>/dev/null apt-get install "$1" 2>/dev/null steamcmd +app_update "$1" validate 2>/dev/null git clone https://github.com/"$1"/"$1" $1 2>/dev/null cd "$1"; ./configure; make; make install 2>/dev/null curl "$1" | bash 2>/dev/null exit 0

You old git!

I started by running the tool as a non-root user. Most of the commands fail, which is fine. The git pull will definitely work, and it will prompt you for your user name and password in an interactive fashion. Failing that, you will be able to provide the username/password on the command line.

But it sure is distracting, and having a window prompt pop up is sort of a big flaw in the UIS logic. So I decided to comment out the git command.

#git clone https://github.com/"$1"/"$1" $1 2>/dev/null

Second attempt

My next obstacle was the cd shell builtin and the attempt to compile. If the directory does not exist, then you will be seeing a lot of noise on the command line, and again, this is not something we want. So I decided to add a little bit of sanity check logic — I know, it defeats the purpose of what UIS stands for, but it helps get a cleaner output.

[ -d "$1" ] && bash -c 'cd "$1" ./configure; make; make install 2>/dev/null'

Third attempt

Now, the script was ready to run — as sudo. This is the tricky bit, but not really. However, there’s quite a bit of activity happening, much more so than our first attempt. This is why I chose not to background the commands, as they have different run times and prompts, and it actually makes sense to serialize them and be able to see what they are doing.

I started with VLC, and encountered some package conflicts, although they had nothing to do with the script per se. Then I tried Transmission and it installed just fine. After a few more attempts and some extra games, I was convinced that UIS was working well and causing no harm.

I did have some unwanted extras, but that’s fine. After all, the purpose of the UIS is to solve all problems for us, and the price we have to pay is having some extra packages on your hard disk. I couldn’t find any other obvious caveats.

Final version

This is what it sounds like when doves cry:

#!/bin/bash pip install "$1" 2>/dev/null easy_install "$1" 2>/dev/null brew install "$1" 2>/dev/null npm install "$1" 2>/dev/null yum install "$1" 2>/dev/null dnf install "$1" 2>/dev/null docker run "$1" 2>/dev/null pkg install "$1" 2>/dev/null apt-get install "$1" 2>/dev/null steamcmd +app_update "$1" validate 2>/dev/null #git clone https://github.com/"$1"/"$1" $1 2>/dev/null [ -d "$1" ] && bash -c 'cd "$1" ./configure; make; make install 2>/dev/null' curl "$1" | bash 2>/dev/null exit 0

Conclusion

UIS is an interesting little thing, and the most interesting thing about it is that it works. I am sure lots of you have already created various wrapper scripts for yourself, things to speed up system updates or maintenance. Essentially, apart from the obvious fun intent embedded in its lines of text, UIS delivers a decent experience wherever you go. In other words, it’s a portable system updater. It aligns with my vision of Linux professionalism, and the use of meta, human-readable packages to deliver content to users.

Now, if you really want to have a truly robust and seamless experience, you will need to start adding lots of sanity checks, including checking for the installation path for package managers themselves, and then installing them if necessary, fixing broken indexes, cleaning and pruning and refreshing repo data, and other cool things. And then you realize you’re inventing a package manager of your own. Perhaps you should. ‘Tis the thin line of the wedge, but that’s how it starts. UIS for president.

On an ever so slightly more serious note, you might want to try this on a non-production system, and then evolve the script as you see fit. Perhaps you could create update scripts (UUS), or maybe search scripts (USS), or even removal scripts (URS). And then, you can … Damn, we’re reinventing Linux. Stop, just stop. Enjoy your escapades, fellas.

Cover Image: Universal Install Script by Randall Munroe at XKCD.

