From f3d5699e15ea811b2e0568183b7b3d9ec4db7252 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Sun, 4 Jan 2026 15:45:31 -0500 Subject: [PATCH] Add config file support and help to RPi scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add stegasoo.conf.example with all configurable options - setup.sh: Add -h/--help, load config from /etc and ~/.config - setup.sh: Support STEGASOO_BRANCH for non-main branches - sanitize-for-image.sh: Add -h/--help with usage examples Config files are loaded in order: 1. /etc/stegasoo.conf (system-wide) 2. ~/.config/stegasoo/stegasoo.conf (per-user) 3. Environment variables (highest priority) 馃 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- rpi/sanitize-for-image.sh | 26 +++++++++++++++++ rpi/setup.sh | 60 ++++++++++++++++++++++++++++++++++----- rpi/stegasoo.conf.example | 30 ++++++++++++++++++++ 3 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 rpi/stegasoo.conf.example diff --git a/rpi/sanitize-for-image.sh b/rpi/sanitize-for-image.sh index 628984b..58481cb 100755 --- a/rpi/sanitize-for-image.sh +++ b/rpi/sanitize-for-image.sh @@ -29,10 +29,36 @@ GRAY='\033[0;90m' BOLD='\033[1m' NC='\033[0m' +# Show help +show_help() { + echo "Stegasoo Sanitize Script - Prepare Pi for SD Card Imaging" + echo "" + echo "Usage: sudo $0 [options]" + echo "" + echo "Options:" + echo " -h, --help Show this help message" + echo " -s, --soft Soft reset (keeps WiFi for testing)" + echo " -r, --reboot Auto-reboot/shutdown when done" + echo "" + echo "Examples:" + echo " sudo $0 # Full sanitize, prompts for shutdown" + echo " sudo $0 --soft # Keep WiFi, reset everything else" + echo " sudo $0 --soft --reboot # Soft reset, auto-reboot" + echo " sudo $0 --reboot # Full sanitize, auto-shutdown" + echo "" + echo "Config override:" + echo " Set STEGASOO_DIR to specify a custom install location:" + echo " export STEGASOO_DIR=\"/home/pi/stegasoo\"" + echo " sudo -E $0" + echo "" + exit 0 +} + SOFT_RESET=false AUTO_REBOOT=false for arg in "$@"; do case $arg in + -h|--help) show_help ;; --soft|-s) SOFT_RESET=true ;; --reboot|-r) AUTO_REBOOT=true ;; esac diff --git a/rpi/setup.sh b/rpi/setup.sh index 8ccf08b..d915435 100755 --- a/rpi/setup.sh +++ b/rpi/setup.sh @@ -29,12 +29,56 @@ GRAY='\033[0;90m' BOLD='\033[1m' NC='\033[0m' # No Color -# Configuration -INSTALL_DIR="/opt/stegasoo" -PYTHON_VERSION="3.12" -STEGASOO_REPO="https://github.com/adlee-was-taken/stegasoo.git" +# Show help +show_help() { + echo "Stegasoo Raspberry Pi Setup Script" + echo "" + echo "Usage: $0 [options]" + echo "" + echo "Options:" + echo " -h, --help Show this help message" + echo "" + echo "Configuration:" + echo " Config files are loaded in order (later overrides earlier):" + echo " 1. /etc/stegasoo.conf" + echo " 2. ~/.config/stegasoo/stegasoo.conf" + echo " 3. Environment variables" + echo "" + echo " Available variables:" + echo " INSTALL_DIR Install location (default: /opt/stegasoo)" + echo " PYTHON_VERSION Python version (default: 3.12)" + echo " STEGASOO_REPO Git repo URL" + echo " STEGASOO_BRANCH Git branch (default: main)" + echo "" + echo " Example:" + echo " export INSTALL_DIR=\"/home/pi/stegasoo\"" + echo " ./setup.sh" + echo "" + exit 0 +} + +# Parse args +for arg in "$@"; do + case $arg in + -h|--help) show_help ;; + esac +done + +# Default configuration +INSTALL_DIR="${INSTALL_DIR:-/opt/stegasoo}" +PYTHON_VERSION="${PYTHON_VERSION:-3.12}" +STEGASOO_REPO="${STEGASOO_REPO:-https://github.com/adlee-was-taken/stegasoo.git}" +STEGASOO_BRANCH="${STEGASOO_BRANCH:-main}" JPEGIO_REPO="https://github.com/dwgoon/jpegio.git" +# Load config files (system, then user - user overrides system) +for config_file in "/etc/stegasoo.conf" "$HOME/.config/stegasoo/stegasoo.conf"; do + if [ -f "$config_file" ]; then + # shellcheck source=/dev/null + source "$config_file" + fi +done + clear echo "" echo -e "${GRAY} . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 . 路 .${NC}" @@ -183,12 +227,14 @@ rm -rf "$JPEGIO_DIR" echo -e "${GREEN}[5/7]${NC} Installing Stegasoo..." # Clone Stegasoo -if [ -d "$INSTALL_DIR" ]; then +if [ -d "$INSTALL_DIR/.git" ]; then echo "Stegasoo directory exists, updating..." cd "$INSTALL_DIR" - git pull + git fetch origin + git checkout "$STEGASOO_BRANCH" + git pull origin "$STEGASOO_BRANCH" else - git clone "$STEGASOO_REPO" "$INSTALL_DIR" + git clone -b "$STEGASOO_BRANCH" "$STEGASOO_REPO" "$INSTALL_DIR" cd "$INSTALL_DIR" fi diff --git a/rpi/stegasoo.conf.example b/rpi/stegasoo.conf.example new file mode 100644 index 0000000..f7d0402 --- /dev/null +++ b/rpi/stegasoo.conf.example @@ -0,0 +1,30 @@ +# Stegasoo Raspberry Pi Configuration +# Copy this file to /etc/stegasoo.conf or ~/.config/stegasoo/stegasoo.conf +# +# You can also override these by exporting environment variables: +# export STEGASOO_INSTALL_DIR="/custom/path" +# ./setup.sh + +# Installation directory (default: /opt/stegasoo) +#INSTALL_DIR="/opt/stegasoo" + +# Python version to install via pyenv (default: 3.12) +#PYTHON_VERSION="3.12" + +# Git repository URL +#STEGASOO_REPO="https://github.com/adlee-was-taken/stegasoo.git" + +# Git branch to checkout (default: main) +#STEGASOO_BRANCH="main" + +# Web UI port (default: 5000) +#STEGASOO_PORT="5000" + +# Enable HTTPS (default: false, configured via wizard) +#STEGASOO_HTTPS_ENABLED="false" + +# Enable authentication (default: true) +#STEGASOO_AUTH_ENABLED="true" + +# Channel key for private channels (default: none) +#STEGASOO_CHANNEL_KEY=""