Omakub Commands - Deep Dive
Note: this post is a work in progress
DHH has released another solution - this time to set up an Ubuntu PC. With just a single command, everything should be ready to go.
He is prolific. I have no idea how he manages to do it all so efficiently. The thought of compiling and sharing a turn-key solution seemed like a lot of energy to me when I thought of it. So I didn’t bother - very rarely do I change PCs, and when I do, I would assess and manually download what I want, at the time I need it.
Not only did DHH write all the code (it looks to be in bash), he is sharing it with the world, for free. Yes, he too does gain, in a sense, but all credit to him. I never bothered to do the same. I justify it by saying - my preferences are solely mine, and it’s dubious whether others would be interested.
It makes sense though - compile a solution for yourself and then share that with others - if they’re interested. We see the same theme again: ‘omakese’ + convention over configuration.
With 10000s of choices that need to be made, it is impossible to experiment with each one.
We will take a deep dive into how it works.
1. The Starting Command
wget -qO- https://omakub.org/install | bash
What is wget
?
wget is a program that downloads stuff.
-q
it downloads it quietly.-O-
redirects the output to standard output. Think of like this - ordinarily when you download via wget - it would download to a file. In this case, rather than the result being “outputted” to a file, we want the result “printed to your screen” or printed to “standard output” .- Check out the file here: https://omakub.org/install
Loudly
If you want to download it loudly, try this
wget https://omakub.org/install
You see a progress bar downloading the file. And then you will notice a new file downloaded in your “working directory”.
We don’t want that.
Output
We want to “output” the result of the downloading to “standard output”. Think of it as putting the results onto your screen:
wget -O- https://omakub.org/install
But then it includes all this other stuff we don’t want - because we want to run commands:
0%[ ] 0 --.-KB/s eval "$(wget -qO- https://raw.githubusercontent.com/basecamp/omakub/stable/boot.sh)"
100%[========================================================================>] 85 --.-KB/s in 0s
So we want:
- to download it queitly.
- and to download the results to “the screen”.
What was the original command?
wget -qO- https://omakub.org/install | bash
2. Piped to bash
Notice the final part:
| bash
- the
|
is the “pipe” command. You will see this concept bandied around a lot in other languages as “piping” or “currying”. The concept is mathematical.
# psuedo code
def hello
"hello"
end
def say
puts
end
hello | say # is the same as saying
say(hello)
some_input | bash # is the equivalent of:
bash some_input
It basically means: download all the stuff in install
and send it to bash.
When you download https://omakub.org/install you get the following:
eval "$(wget -qO- https://raw.githubusercontent.com/basecamp/omakub/stable/boot.sh)"
- eval: takes an argument, constructs a command and executes it. For more info on eval review these answers..
Omakub calls scripts which call other scripts
- You run install script
- Install script downloads and runs the boot script
- The boot script donwnloads basecamp’s omakub repo
- And then starts installing it.
In other words you can download scripts, which download other scripts, which download git repositories, and then runs the whole lot. It seems simpler to have the install script which simply downloads the omakub repo and starts installing it.
The Boot Script:
## omakub
wget -qO- https://omakub.org/install | bash
# translates to downloading the bootscript
eval $(wget -qO- https://raw.githubusercontent.com/basecamp/omakub/stable/boot.sh) | bash
# which then gives you:
set -e
ascii_art='________ __ ___.
\_____ \ _____ _____ | | ____ _\_ |__
/ | \ / \\__ \ | |/ / | \ __ \
/ | \ Y Y \/ __ \| <| | / \_\ \
\_______ /__|_| (____ /__|_ \____/|___ /
\/ \/ \/ \/ \/
'
echo -e "$ascii_art"
echo "=> Omakub is for fresh Ubuntu 24.04 installations only!"
echo -e "\nBegin installation (or abort with ctrl+c)..."
sudo apt-get update >/dev/null # >/dev/null removes the noise in standard output
sudo apt-get install -y git >/dev/null
echo "Cloning Omakub..."
rm -rf ~/.local/share/omakub
git clone https://github.com/basecamp/omakub.git ~/.local/share/omakub >/dev/null
if [[ $OMAKUB_REF != "master" ]]; then
cd ~/.local/share/omakub
git fetch origin "${OMAKUB_REF:-stable}" && git checkout "${OMAKUB_REF:-stable}"
cd -
fi
echo "Installation starting..."
source ~/.local/share/omakub/install.sh
# which then leads you to the omakub repo install script
Omakub repo Install Script
The install script