Skip to main content

Automating Crap I Don't Want to Do

You can’t bash Bash. LOL I’m so pun-ny! Also puny. What am I talking about again? Oh yeah automating crap. You know how sometimes you have to do so much clicking and typing, lame. Who does that?
But I know what you’re thinking, I’m not the towering intellect you so clearly are Noki. We worship your wise pearls of words of wisdom and suckle at the teat of the life giving nutrients we crave in this crazy world. How do I even get started making my own scripts, I’m a Windows user, we click next a lot and then things do the do.
Well don’t despair, it’s far easier than it looks. Trouble is you have big ideas, and those big ideas take time and effort. You get started, you see a mountain designed to fix a molehill and you quit. It needn’t be that way though, I mean it.
I had a dream. A dream where every installation, will be automated. No matter the requirements of the machine or the content of their repository. When I began on my adventure I didn’t really plan on making a script. It just grew from a need. Probably why I succeeded (sort of), but i’ll get to that.
Let me introduce you to the almost pointless...
...and it's creation.

Starting off

When I began my switch from Windows to Ubuntu I ended up playing around and breaking things. Making my drivers do nothing when X started, that sort of thing. So I re-installed a bunch of times, sue me right!
As I found applications that I needed and liked I dumped them into a text file. That way I could just copy it into the terminal and install everything in one go. Then one day I said to myself, ein minuten bitte. If I make this executable and dump it in ~/bin/ I have myself a script. I can simply run the son of a gun and boom be back in freaking sweet Linux action.
It was simple yes, but it worked. I found more stuff to bloat it with and it grew like a fat pigeon eating ham sandwiches. But it stayed simple, a few lines of text. Then I made another machine, gave it to my dad and decided he should use Linux being the computer virgin he was at the time. But he wouldn’t need all these apps, if I split it up and I could pick and choose what to install when I run the script. Should be easy right?

Growing Pains

But then I hit a problem. A couple of months in a few packages became obsolete and died. This made the one long apt-get install not bother with anything at all. But I didn’t know what to do to fix it, so my ingenious solution, split it up into smaller chunks and give it more chance to run successfully. At least some of the chunks would work for sure. Plus it would help with different machines having different needs.
This is when I had to learn things. I know ugh right. Putting more things in this already enormous head. Ridiculous. So I learned to ask questions within the script allowing choices. Actually quite easy, read y/n from user and whack in an if statement.
This was a little lazy but then I was inspired, I wanted to do more. I knew it could do more. I could hear the clarient call of destiny beacon me to it’s sweet bosom.
So I added crap it really didn’t need. But it taught me to make loops, and I discovered functions and even made things pretty. You know terminal pretty, the best kind of pretty. It does SO many things now. Stupid pointless things it doesn’t need to do. It’s broken a bunch of times, spent ages tinkering. Long road.

The Bittersweet Taste of Success

But I learned so much, and that’s what counts. But alas I can’t look at this as a successful script, as something that both needs and deserves to exist.
If it had remained a copy and paste list it would still have worked.
It’s got some potentially dangerous stuff in it. In that it might break apt/dpkg things, not kill your sister.
A bloated hot mess that I only I can read and understand easily. Sharing isn’t caring here.
Time wasted on this was immense, I could have worked and paid for an American to go to college!
Through it all I learned how to make functions to save repeating code. Passing data from one app to another so each can do their thing. Even added some help text, who’s that for? But now I can make a reasonable BASH script, nothing crazy but pretty damned useful. It lead to me making other scripts to sync files to my NAS or hide my porn and such.

Bottom Line

I provide you with this zip, a fairly complete history of this magnificent beast under the promise you won’t actually run it. Just stare at it in awe and wonder about the kind of madman that could conceive of such a thing. It’s should be good up to Ubuntu 18.04 and cover a lot of generally useful things. It normally takes me about 20 minutes to run it fully, but that’s my amazing 6 year old beast is still kicking it old skool. Runs fine on my XPS 15 9550 too.
If you want my advise on what functionality to learn about first, if you a more of a learn a big bunch of stuff and then get to work this is what I’ll say. Take a look at this list and learn each of them before making something yourself.
  • Useful apps for simple bash scripts:
  • If statements, followed by reading user input.
    • Read $choice, then determine action using an if statement. Great starting point.
  • Looping, this will mean covering arrays too.
    • Declaring an array can be made more complex if you want to alter it once it’s made...
  • Case statements, and functions.
    • Now that you’ve made a thing, use functions to reduce duplication and make it feel like a pro-script and live out your wildest fantasies.
  • Extended apps for more complex tasks:
    • cURL, AWK, printf, plus stringing these together with operators.
This can be fun and rewarding if you let it be. If you find it dull just stop and rethink your life.
Love, Life and Peace,
Noki

Comments