Add --reboot flag to sanitize script for full automation
Skips all prompts when passed, auto-reboots (soft reset) or auto-shutdowns (full sanitize) when complete. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
# Usage:
|
# Usage:
|
||||||
# sudo ./sanitize-for-image.sh # Full sanitize for image distribution
|
# sudo ./sanitize-for-image.sh # Full sanitize for image distribution
|
||||||
# sudo ./sanitize-for-image.sh --soft # Soft reset (keeps WiFi for testing)
|
# sudo ./sanitize-for-image.sh --soft # Soft reset (keeps WiFi for testing)
|
||||||
|
# sudo ./sanitize-for-image.sh --soft --reboot # Soft reset and auto-reboot
|
||||||
|
# sudo ./sanitize-for-image.sh --reboot # Full sanitize and auto-shutdown
|
||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
@@ -28,9 +30,13 @@ BOLD='\033[1m'
|
|||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
SOFT_RESET=false
|
SOFT_RESET=false
|
||||||
if [ "$1" = "--soft" ] || [ "$1" = "-s" ]; then
|
AUTO_REBOOT=false
|
||||||
SOFT_RESET=true
|
for arg in "$@"; do
|
||||||
fi
|
case $arg in
|
||||||
|
--soft|-s) SOFT_RESET=true ;;
|
||||||
|
--reboot|-r) AUTO_REBOOT=true ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ "$EUID" -ne 0 ]; then
|
if [ "$EUID" -ne 0 ]; then
|
||||||
echo -e "${RED}Error: Must run as root (sudo)${NC}"
|
echo -e "${RED}Error: Must run as root (sudo)${NC}"
|
||||||
@@ -71,12 +77,14 @@ else
|
|||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
if [ "$AUTO_REBOOT" = false ]; then
|
||||||
read -p "Continue? This cannot be undone! [y/N] " -n 1 -r </dev/tty
|
read -p "Continue? This cannot be undone! [y/N] " -n 1 -r </dev/tty
|
||||||
echo
|
echo
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||||
echo "Aborted."
|
echo "Aborted."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Track validation results
|
# Track validation results
|
||||||
VALIDATION_ERRORS=0
|
VALIDATION_ERRORS=0
|
||||||
@@ -356,6 +364,10 @@ if [ "$SOFT_RESET" = true ]; then
|
|||||||
echo -e "${CYAN}Soft reset complete.${NC}"
|
echo -e "${CYAN}Soft reset complete.${NC}"
|
||||||
echo "You can now reboot to test the first-boot wizard."
|
echo "You can now reboot to test the first-boot wizard."
|
||||||
echo ""
|
echo ""
|
||||||
|
if [ "$AUTO_REBOOT" = true ]; then
|
||||||
|
echo "Rebooting..."
|
||||||
|
exec reboot
|
||||||
|
fi
|
||||||
read -p "Reboot now? [y/N] " -n 1 -r </dev/tty
|
read -p "Reboot now? [y/N] " -n 1 -r </dev/tty
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
@@ -371,6 +383,10 @@ else
|
|||||||
echo " sudo dd if=/dev/sdX of=stegasoo-rpi.img bs=4M status=progress"
|
echo " sudo dd if=/dev/sdX of=stegasoo-rpi.img bs=4M status=progress"
|
||||||
echo " 4. Compress: zstd -19 stegasoo-rpi.img"
|
echo " 4. Compress: zstd -19 stegasoo-rpi.img"
|
||||||
echo ""
|
echo ""
|
||||||
|
if [ "$AUTO_REBOOT" = true ]; then
|
||||||
|
echo "Shutting down..."
|
||||||
|
exec shutdown -h now
|
||||||
|
fi
|
||||||
read -p "Shut down now? [y/N] " -n 1 -r </dev/tty
|
read -p "Shut down now? [y/N] " -n 1 -r </dev/tty
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user