Raspberry Pi Preparation Scripts

Raspberry Pi Preparation Scripts

The Raspberry Pi Boot Guide remains one of our blog's most popular articles. This past January, I created a series of shell scripts to ease implementing network based-booting configuration, as well as automating other common administrative tasks, for Raspberry Pi users. I have setup a public GitLab project called rpi-prep to ease distribution and will be discussing how to make use of these scripts in this article.

Installation

The only current prerequisite to run these scripts is Fish Shell v3.0+; however, some scripts may automatically install additional dependencies.

While I recommend using Fish Shell over bash, zsh, and other shells as a default, I understand that this is a very personal preference for most folks. All of that said, you should only have to clone the git repository or manually download the individual scripts that you require and then make them executable with chmod +x. Afterwards, simply execute the script in your favorite shell as long as Fish shell is installed locally.

Why Fish Shell?

Fish Shell, or Friendly Interactive Shell, is a great more modern shell that has gained a lot of support from members of the Linux/Unix community. I have been actively promoting its use at work and with other friends/colleagues because I've found it to be much easier to use, configure, and extend than bash, zsh, etc.

A shell is a program that helps you operate your computer by starting other programs. fish offers a command-line interface focused on usability and interactive use.

Unlike other shells, fish does not follow the POSIX standard, but still uses roughly the same model.

Some of the special features of fish are:

  • Extensive UI: Syntax highlighting, Autosuggestions, tab completion and selection lists that can be navigated and filtered.
  • No configuration needed: fish is designed to be ready to use immediately, without requiring extensive configuration.
  • Easy scripting: New functions can be added on the fly. The syntax is easy to learn and use.

- fish-shell documentation, 2022

Use Cases

Inside the scripts folder, this project contains the following Fish Shell scripts:

  1. manage-tempuser.fish - Interactive script that adds or removes a tempuer user with sudo access to your RPis.
  2. prep-k3s-install.fish - Non-interactive script that modifies RPis to meet the current prerequisites in order to support K3s (https://k3s.io)
  3. prep-storage.fish - Interactive script to bootstrap an RPi SDCARD to Netboot via NFS/iSCSI.
  4. rename-piuser.fish - Interactive script to rename the default pi user and modify all other relevant configuration.

The most complicated of these scripts is the prep-storage.fish script. It will install all prerequisite software required to automate the Final Steps section from the Raspberry Pi Boot Guide and will configure open-iscsi, report the iSCSI Initiator and RPi serial number for completing the NAS configuration, and then ask all the required inputs to configure the NFS and iSCSI target information.

This script, if used properly, will eliminate human error in modifying configuration files, synchronizing data, etc.

I've used this script repeatedly in my homelab with Raspberry Pi OS (Debian Bullseye) 64-bit edition without fail; however, I hope to keep improving the script with undo functionality, as well as better error handling.

Conclusion

I hope to add additional scripts over time to rpi-prep , as my end-goal is to automate all of my most common administrative tasks in software moving forward, so that rebuilding the homelab is trivial and more consistent.





Raspberry Pi Power Savings and LED Configuration

Raspberry Pi Power Savings and LED Configuration

Blog User Experience

Blog User Experience