USBRecovery is a Raspberry Pi USB-triggered recovery runner.
When a USB partition is inserted, udev triggers a systemd oneshot unit that runs /usr/local/sbin/usb-recovery.sh. The handler verifies a signed checksum manifest, then runs scripts/RECOVERY.sh via /bin/bash and mirrors output to Pi and USB logs.
The handler executes recovery only if all gates pass:
- USB label matches
RECOVERYKEY scripts/manifest.sha256signature verifies with/etc/usb-recovery/cobod_recovery.pub- Manifest lines are valid and only allowed paths are present (
scripts/RECOVERY.sh,scripts/modules/*.sh) scripts/RECOVERY.shhash matches manifest- Every
scripts/modules/*.shfile hash matches manifest - Coverage is strict: no extra modules on USB and no stale module entries in manifest
scripts/
RECOVERY.sh
manifest.sha256
manifest.sha256.minisig
modules/
output/
- Syslog/journal via
logger -t usb-recovery - Pi log:
/var/log/usb-recovery.log - USB mirror log:
scripts/output/pi-recovery.log - Recovery wrapper log (from USB script):
scripts/output/recovery_wrapper.log
Installer: installation script/install_usb_recovery.sh
Before running installer:
- Place
cobod_recovery.pubnext to installer (unless already at/etc/usb-recovery/cobod_recovery.pub) - Ensure
minisignis installed, or place one or moreminisign_*.debfiles in the installer directory - Ensure
sha256sumis available on Pi (typically fromcoreutils)
Run:
sudo bash "installation script/install_usb_recovery.sh"Minisign install behavior:
- If minisign exists: continue
- If missing and one
minisign_*.debexists: install viadpkg -i - If missing and multiple packages exist: prompt for selection
- If missing and no local package exists: abort before making changes
Use helper script (interactive + CI):
bash "installation script/generate_manifest_and_sign.sh"Interactive quick guide:
- Run the command above
- For
Package root directory, enter directory that containsscripts/(usuallyUSB drive structure) - Provide secret key path (for example
./cobod_recovery.key) - Optionally provide pubkey path for immediate verification
- Confirm overwrite if prompted
Generated files:
scripts/manifest.sha256scripts/manifest.sha256.minisig
CI example:
bash "installation script/generate_manifest_and_sign.sh" \
--ci --force \
--root "USB drive structure" \
--key ./cobod_recovery.key \
--pubkey ./cobod_recovery.pub \
--verifyDetailed script guide:
installation script/generate_manifest_and_sign.md
Generate keypair once (keep private key offline):
minisign -G -p cobod_recovery.pub -s cobod_recovery.keyBuild manifest:
shopt -s nullglob
MODULE_FILES=(scripts/modules/*.sh)
shopt -u nullglob
{
echo "# USBRECOVERY-MANIFEST-V1"
sha256sum scripts/RECOVERY.sh "${MODULE_FILES[@]}"
} > scripts/manifest.sha256Sign manifest:
minisign -S -s cobod_recovery.key -m scripts/manifest.sha256 -x scripts/manifest.sha256.minisigCopy to USB:
scripts/RECOVERY.shscripts/modules/*.shscripts/manifest.sha256scripts/manifest.sha256.minisig