Operations

Raspberry Pi

Raspberry Pi provisioning: imaging cards, Node.js, cameras, Bluetooth, IR, audio.

22 tasks

This page is a scrubbed, public-safe version of an internal AI/SI operations runbook — the command cheat-sheet a systems engineer builds up over years of running Linux servers, virtualisation hosts, firewalls, databases, certificates and Raspberry Pi devices.

It is organised into the same sections as the original workbook, one page each — reach any of them from the AI/SI Prompts menu above. Every task on this page shows three things:

The point of the AI-prompt column is to show how a pile of accumulated tribal knowledge can be turned into something an assistant can reproduce and improve on demand: you keep the intent, and let the model rewrite the mechanics for whatever host you are on today. Nothing on this page should be run without reading it first — several snippets are destructive (dd, rm -rf, postsuper -d ALL, firewall reloads).

Update keyboard map

Switches the keyboard layout to US with setxkbmap, then installs Node.js from the NodeSource repository.

Commands
setxkbmap us
# Install Node.js
curl -sL https://deb.nodesource.com/setup | sudo bash -  for v0.10.x (DO NOT USE)
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install nodejs
node -v
npm -v
AI prompt

Generate a Bash script for the task “Update keyboard map”. Parameterise the keyboard layout and Node.js major version; set the layout with setxkbmap (and persistently in /etc/default/keyboard), add the NodeSource repository for a currently supported version, install nodejs, and print the node and npm versions. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Start VNC

Installs and enables a VNC server as a systemd (or SysV) service for a given display and user, and opens the matching firewall port.

Commands
apt-get install vnc-server
update-rc.d vncboot defaults
AI prompt

Generate a Bash script for the task “Start VNC”. Parameterise the user and display number; install the server, template the vncserver@:N.service unit, open port 590N, and systemctl enable --now it. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Apple program SD card

Uses diskutil and dd on macOS to identify a removable disk, unmount it, and image it to a file or write an image (e.g. a Raspberry Pi card) back to it.

Commands
diskutil list  Find the disk# of the SD card.
diskutil unmountdisk /dev/disk3  Unmount the disk, do not eject
# Save the SD card's image
dd bs=1m if=/dev/disk3 of=raspberry.img
Writing to disk
# Wipe an SD card clean - remove all partitions
diskutil partitionDisk /dev/disk3 1 MBR "Free Space" "%noformat%" 100%  May not be needed before a write. Just in case.
# Write an image to SD card
dd bs=1m if=raspberry.img of=/dev/rdisk3  Notice we're using rdisk#, not disk#
AI prompt

Generate a Bash script for the task “Apple program SD card”. Take the disk identifier and an image path; diskutil list, diskutil unmountDisk, then dd in the requested direction using the raw device — and refuse to run without an explicit disk id. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

New Pi setup

An ad-hoc SQL query kept for reuse — here, shifting stored dates to the current year.

Commands
sudo apt install git subversion
# update /opt/scripts
svn checkout https://<SVN_HOST>/svn/opt-scripts scripts  scp -pr <BASTION_HOST>:/opt/scripts .
svn checkout https://<SVN_HOST>/svn/<APP>.nodejs <APP>  scp -pr <BASTION_HOST>:/opt/<APP> .
sudo mv ~/<APP> /opt;sudo mv ~/scripts /opt
sudo ln -s /opt/scripts/bash_completion.sh /etc/profile.d/<APP>.sh
echo 'cd /opt/<APP>/gero' >> .bashrc
# get on the latest Pi version
sudo apt update
sudo apt upgrade
sudo reboot
AI prompt

Generate the SQL statements for the task “New Pi setup”. Take the table and date column; write a parameterised SELECT / UPDATE and note to test it in a transaction before committing. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

upgrade node.js past 0.10.x

Upgrades Node.js from NodeSource, installs the Bluetooth development libraries, and adds the npm modules the Gero app needs.

Commands
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt install nodejs
sudo reboot
Create a new Gero on https://<APP_HOST>/ using your login
-- Not needed for Pi - Arduino only. sudo systemctl disable bluetooth
sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev
cd /opt/<APP>/gero;npm install websocket;npm install bluetooth-hci-socket;npm install bleno;npm install noble;npm install wiring-pi
AI prompt

Generate a Bash script for the task “upgrade node.js past 0.10.x”. Parameterise the Node.js version and the app directory; install Node.js from NodeSource, install the BlueZ development packages, run npm install for the app’s modules, and reboot only when asked. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

set the gerokey to the Gero GUID

Enables, disables or restarts system services (systemd, SysV chkconfig, or update-rc.d) as part of host setup or hardening.

Commands
nano /opt/<APP>/gero/config.json
sudo cp /opt/<APP>/gero/gero-init-pi /etc/init.d/gero;sudo update-rc.d gero defaults
sudo reboot  Verify the service is running automatically. ps ax | grep 'node'
AI prompt

Generate a Bash script for the task “set the gerokey to the Gero GUID”. Take a service name and desired state; use systemctl enable --now / disable on systemd and fall back to chkconfig / update-rc.d, reporting the resulting status. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Install the camera software (if needed)

Clones a third-party project from GitHub and runs its shell installer.

Commands
git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
chmod u+x *.sh
sudo ./install.sh
AI prompt

Generate a Bash script for the task “Install the camera software (if needed)”. Take the repository URL; git clone, chmod u+x *.sh, read install.sh before trusting it, then run it. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

For SSL Camera serving

Brands the RPi Cam web interface, enables mod_ssl and links the site’s certificates so the camera page is served over HTTPS.

Commands
Create default index.html at /var/www unless you've installed Rpi Cam directly to /var/www, then drop the html
sudo nano /var/www/html/config.php  Set your app and camera names
APP_NAME  <APP> Cam
CAM_NAME
CAMERA_STRING  APP_NAME . ": " . CAM_NAME . '@' . HOST_NAME
sudo nano /var/www/html/index.php
Add to the head tags  <script src="https://<APP_HOST>/Scripts/pi/pi-camera.js"></script>
Near the Annotation Text: line  Replace RPi Cam with <APP> Cam
On the camera web page, press the Full button, go to Camera Settings, and change the annotation to your preference.
sudo a2enmod ssl
cd /home/pi  Create symlinks to <APP> certs.
svn checkout https://<SVN_HOST>/svn/<APP>/IT/<APP>.com.Certs
sudo mv /home/pi/<APP>.com.Certs /opt
cd /etc/ssl/private; sudo ln -s /opt/<APP>.com.Certs/<APP>.com.key
cd /etc/ssl/certs; sudo ln -s /opt/<APP>.com.Certs/<APP>.com.crt;sudo ln -s /opt/<APP>.com.Certs/gd_bundle-g2-g1.crt
AI prompt

Generate a Bash script for the task “For SSL Camera serving”. Parameterise the app name, camera name and certificate paths; update the RPi Cam config.php values, enable mod_ssl, link the certificates into /etc/ssl, and run apachectl configtest before reloading Apache. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Enable SSL on an Apache vhost

Adds the TLS directives to an Apache virtual host — SSLEngine on plus the certificate, key and chain-file paths — and reloads Apache.

Commands
Add these lines for ssl. Set VirtualHost port to match ../ports.conf port.
SSLEngine on
SSLCertificateFile /etc/ssl/certs/<APP>.com.crt
SSLCertificateKeyFile /etc/ssl/private/<APP>.com.key
SSLCertificateChainFile /etc/ssl/certs/gd_bundle-g2-g1.crt
AI prompt

Generate a Bash script for the task “Enable SSL on an Apache vhost”. Take the vhost file, the listen port and the cert/key/chain paths; insert the SSLEngine / SSLCertificate* lines, enable mod_ssl, and apachectl configtest &amp;&amp; apachectl graceful. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

LIRC - Linux Infrared Control

Installs LIRC and configures the infrared receive and transmit GPIO pins in /etc/modules and /boot/config.txt.

Commands
sudo apt install lirc  GPIOs:  In Pin:  17  Out pin:  18
Add to /etc/modules  lirc_dev
lirc_rpi gpio_in_pin=17 gpio_out_pin=18
Add to /boot/config.txt  dtoverlay=lirc-rpi,gpio_in_pin=17,gpio_out_pin=18
AI prompt

Generate a Bash script for the task “LIRC - Linux Infrared Control”. Parameterise the input and output GPIO pins; install lirc, add the dtoverlay line to /boot/config.txt if it is not already there (using gpio-ir/gpio-ir-tx on current kernels), and remind the user to reboot. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

irsend LIST "" ""

Sets up LIRC infrared send/receive on Raspberry Pi GPIO pins and sends remote key codes with irsend.

Commands
irsend SEND_ONCE JKT-86 KEY_POWER  Turn on/off a Changhong TV.
AI prompt

Generate a Bash script for the task “irsend LIST "" ""”. Take the in/out GPIO pins and a remote+key name; show the /etc/modules, /boot/config.txt overlay lines, and irsend SEND_ONCE <remote> <key>. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

BodyWave

Example crontab entries for routine maintenance — pruning old backups, NTP sync, updatedb, nightly backup and cleanup jobs.

Commands
sudo nano /etc/systemd/system/dbus-org.bluez.service  ExecStart=/usr/lib/bluetooth/bluetoothd --compat --noplugin=sap
sudo cp /opt/<APP>/gero/freer-logic/libbluetooth.so* /usr/lib/arm-linux-gnueabihf  Tray - Freer Logic  sudo scp pi@<PI_HOST>:/usr/lib/arm-linux-gnueabihf/libbluetooth.so* /usr/lib/arm-linux-gnueabihf
sudo mkdir /var/run/sdp
Edit /opt/<APP>/gero/start.sh and replace app.js with freer-logic-httpcomm.js and add gpio mode 1 out before running if pin 18. Must use wiring-pi numbers.
@reboot /opt/<APP>/gero/freer-logic/bw_bluetooth.sh  sudo crontab -e
AI prompt

Generate a crontab block for the task “BodyWave”. Produce a commented crontab block: field legend, then one line per job (backup prune, ntpdate, updatedb, backup script) with sane staggered times. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Pair Pi with the phone

Pairs the Raspberry Pi with a Bluetooth device from the command line and wires up the BlueZ service overrides needed for a serial/SPP link.

Commands
sudo bluetoothctl
scan on  Then look for the device and copy the address
pair ${address_you_found}
pairable yes
trust <BT_ADDR>
pair <BT_ADDR>  Say yes on your phone
AI prompt

Generate a Bash script for the task “Pair Pi with the phone”. Walk bluetoothctl (scan on, trust, pair) parameterised by the device MAC, and show the dbus-org.bluez.service ExecStart override for --compat. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Emissions Group support

Installs the Python 3 plotting, audio and numeric libraries the Emissions Group software needs.

Commands
sudo apt install python3-cairocffi
sudo apt install python3-matplotlib
sudo apt install python3-pyaudio
sudo pip3 install numpy
sudo pip3 install websocket
AI prompt

Generate a Bash script for the task “Emissions Group support”. Take the package list and package manager; run a single non-interactive install, then print the installed versions of the key tools. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Install MySQL Connector/Python

Installs MySQL Connector/Python 2.0.4 with pip3 from a direct download URL.

Commands
pip3 install http://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.zip
AI prompt

Generate a Bash script for the task “Install MySQL Connector/Python”. Install the MySQL connector with pip3 install mysql-connector-python from PyPI rather than a direct download URL, and print the installed version. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Raspberry Pi EG install support Python3 libs

Upgrades pip and installs the Python 3 audio, SciPy and Bluetooth packages for the EG software, then reboots.

Commands
sudo easy_install3 -U pip
sudo apt -y install python-pyaudio python3-pyaudio scipy bluez-tools blueman
sudo pip3 install matplotlib pydub wavio
reboot
AI prompt

Generate a Bash script for the task “Raspberry Pi EG install support Python3 libs”. Take the package list and package manager; run a single non-interactive install, then print the installed versions of the key tools. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Set the default USB Audio device

Forces a USB audio device to be card 0 on Raspberry Pi and works around PulseAudio/ALSA startup errors.

Commands
sudo nano /lib/modprobe.d/aliases.conf  #options snd-usb-audio index=-2  options snd- usb- audio index = -2 change to 0
options snd-usb-audio index=0
AI prompt

Generate a Bash script for the task “Set the default USB Audio device”. Show the /lib/modprobe.d/aliases.conf edit setting options snd-usb-audio index=0 plus the ALSA/PulseAudio packages to install, then a reboot. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Bigtime help getting past PulseAudio errors

Installs the PulseAudio volume control and ALSA tools used to troubleshoot PulseAudio errors, after editing alsa.conf.

Commands
sudo nano /usr/share/alsa/alsa.conf
sudo apt-get install pavucontrol
sudo apt-get install alsa-tools alsa-utils
sudo apt -y install linux-sound-base
AI prompt

Generate a Bash script for the task “Bigtime help getting past PulseAudio errors”. Install pavucontrol and the ALSA utilities, back up /usr/share/alsa/alsa.conf before any edit, and list the playback and capture devices with aplay -l and arecord -l so the right card can be chosen. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

didn't help

Installs Audacity, the ALSA development headers and PyAudio — an earlier attempt at the same audio problem that did not fix it.

Commands
sudo apt-get install audacity
sudo apt-get install libasound-dev
sudo pip3 install pyaudio
AI prompt

Generate a Bash script for the task “didn't help”. Take the package list and package manager; run a single non-interactive install, then print the installed versions of the key tools. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

OBD reset

Binds a paired Bluetooth OBD adapter to the serial device /dev/rfcomm0 with rfcomm bind.

Commands
rfcomm bind rfcomm0 <BT_ADDR>
AI prompt

Generate a Bash script for the task “OBD reset”. Parameterise the adapter’s Bluetooth address and channel; release any existing binding, bind it to /dev/rfcomm0 with rfcomm bind, and confirm the device node exists. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

Python3 PyQt5 install on Pi

Installs the OS packages and language libraries this component needs (apt/yum/brew plus pip/npm), on Raspberry Pi OS, CentOS or macOS.

Commands
sudo apt install python3-pyqt5
sudo apt-get install libgtk-3-dev
sudo apt-get install libegl1-mesa-dev
sudo apt install gir1.2-javascriptcoregtk-3.0
sudo apt-get install libgtk2.0-dev
AI prompt

Generate a Bash script for the task “Python3 PyQt5 install on Pi”. Take the package list and package manager; run a single non-interactive install, then print the installed versions of the key tools. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.

MySQL update

Creates a MySQL account for a given host pattern and grants it privileges (and shows how to drop it or reset its password).

Commands
create user 'root'@'%' identified by '<DB_PASSWORD>'; grant all on *.* to 'root'@'%' with grant option; flush privileges;
AI prompt

Generate the SQL statements for the task “MySQL update”. Take username, host pattern (e.g. %, 192.168.%, host.domain) and database scope; emit CREATE USER … IDENTIFIED BY, the matching GRANT, and FLUSH PRIVILEGES. Assume CentOS/RHEL or Raspberry Pi OS as appropriate, comment each step, and never hard-code a real credential — read secrets from the environment.