Files
ubuntu-based-kiosk/menus/advanced_factory_reset.sh
Claude a3313aa9b8 Migrate 4 more Advanced items (Electron, Factory Reset, Virtual Consoles, Emergency Hotspot); bump to v2.11.0
New in install.sh's Advanced menu, alongside Diagnostics:
- menus/advanced_electron.sh: "Electron Maintenance" - the legacy
  "Manual Electron Update" and "Fix Blank Screen" combined into one
  submenu, sharing the binary-repair logic (electron_install_binary).
- menus/advanced_factory_reset.sh: "Factory Reset" - wipes config.json
  back to defaults only; addons are untouched.
- menus/advanced_virtual_consoles.sh: "Virtual Consoles" - toggles
  Ctrl+Alt+F1-F8 terminal login access.
- menus/advanced_emergency_hotspot.sh: "Emergency Hotspot" - auto-starts
  a WiFi hotspot if no internet is detected 60 seconds after boot. Its
  own runtime script and systemd unit now go through $BIN_DIR/
  $SYSTEMD_DIR like every other addon's own files, instead of the
  legacy's hardcoded /usr/local/bin and /etc/systemd/system.

That covers 8 of the legacy Advanced menu's 12 entries. Not migrated
this round: Export/Import Settings (pending a decision on rebuilding it
around actual paths vs. a hardcoded step list, or whether the future
web UI replaces the need for it) and Fix Squeezelite Audio (small
enough it may fold into the LMS addon instead of staying standalone).

Full command-level stubbed test suite per file, including set -e safety
checks (declined/failed paths never crash the session) and content
verification for every written file. Full 18-suite regression + real
end-to-end menu navigation via install.sh all pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VfsFSoRqfbRG7XAg5RoE7e
2026-08-19 02:52:43 +00:00

47 lines
1.7 KiB
Bash

#!/bin/bash
################################################################################
# menus/advanced_factory_reset.sh - "Factory Reset" (Advanced): wipe
# config.json back to script defaults without touching anything else.
#
# Deliberately narrow - this only removes $CONFIG_PATH. Installed addons
# (CUPS, LMS, VPNs, etc.), the kiosk user, and the system itself are left
# alone; that's what Complete Uninstall is for.
#
# Depends on: lib/menu.sh, lib/config.sh being sourced first.
################################################################################
advanced_factory_reset_status() {
if sudo -u "$KIOSK_USER" test -f "$CONFIG_PATH" 2>/dev/null; then
echo "Config: $CONFIG_PATH exists"
else
echo "Config: not found (already at defaults)"
fi
}
advanced_factory_reset_menu_builder() {
MENU_LABELS=("Reset configuration to defaults")
MENU_HANDLERS=(action_factory_reset)
}
advanced_factory_reset_menu() {
run_menu "FACTORY RESET" advanced_factory_reset_menu_builder advanced_factory_reset_status
}
################################################################################
# Actions
################################################################################
action_factory_reset() {
echo
echo "This resets $CONFIG_PATH to defaults - sites, schedules,"
echo "password protection, and every other setting stored there are"
echo "cleared. Installed addons (CUPS, LMS, VPNs, etc.) are not touched."
echo
ask_yes_no "Continue?" "n" || { echo "Cancelled"; pause; return; }
sudo -u "$KIOSK_USER" rm -f "$CONFIG_PATH"
log_success "Configuration reset - reconfigure via Core Settings"
pause
}