3 ms·
I started off with a shell script full of comments with quick step-by-step notes to myself on how I setup my laptop. Here's a sample: #!/bin/sh # TODO: i
by mikem170 5y ago
I started off with a shell script full of comments with quick step-by-step notes to myself on how I setup my laptop. Here's a sample:
#!/bin/sh
# TODO: install openbsd, from prepared usb or ethernet
# full disk encryption, openbsd.org/faq/faq14.html#softraid
# accept install defaults, including disk layout
# update operating system (if needed) and firmware
if [ "`syspatch -c`" ]; then syspatch; fi
fw_update
# update /etc/ntpd.conf, remove google entries
sed -i '/google/d' /etc/ntpd.conf
These scripts start as a lot of TODO entries that I'd have to manually follow when setting up a new pc. But over time I replace my TODO notes with actual shell code. Nothing wrong with having to manually do a few steps if you don't have time to automate everything. I never planned on trying to automate the bsd install to encrypted disk, for example. For quite a while mine seemed mostly manual, copy pasting shell commands for some of the steps. Now it's mostly automated, with a few manual callouts.
It's easy to put the steps in order, and natural to configure the operating system before your home directory. I ended up splitting these into separate scripts, then eventually smaller component scripts in directories. So now I have a master ~/bin/setup/setup.sh script that autodetects the system (based on vps ip or laptop ethernet mac) and calls the correct componenant scripts, like pc/audio.sh, pc/pkg_add.sh, openbsd/etc_myname.sh, openbsd/etc_xenodm.sh, home/ dot_fvwmrc.sh, and so on. Each of these component shell scripts can update config files, enable daemons, copy things, etc. I made functions for some of these things. I can pass arguments to component scripts or set environment variables, for things like ip addresses and usernames. Minimally you need to be sure the automated scripts are idempotent, meaning you can run them repeatedly without harm. Things like trapping errors and testing in qmenu would be good. A lot of it is easy, copying in a file or appending to a file, running a chmod or rcctl command, etc.
It's nice to have this master copy of all my config. When I want to change something I edit the appropriate setup script then re-run it to push the change.