You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
848 B
Bash

#!/bin/sh
[ "${ACTION}" = "released" ] || exit 0
. /lib/functions.sh
. /lib/functions/service.sh
logger -s -t "reset_button" "Reset button pressed, restoring from backup"
# specify the backup file
BACKUP_FILE="/etc/resetbutton.tar"
# check if backup file exists
if [ -f "$BACKUP_FILE" ]; then
logger -s -t "reset_button" "Backup file found, restoring..."
# stop all services before restoration
service_stop_all
# Extract the backup file
tar -xf $BACKUP_FILE -C /
# restart all services
service_start_all
logger -s -t "reset_button" "Restoration complete"
else
logger -s -t "reset_button" "No backup file found. Performing normal reset."
# Fallback to the default reset behavior if no backup is found
jffs2_mark_erase
fi
# sync to make sure all changes are written to disk
sync