Skip to content

Commit

Permalink
Modify reset button behavior
Browse files Browse the repository at this point in the history
The default OpenWRT behavior for a long press of the reset button over 5 secs is to completely erase the changed files overlay on the squashfs filesystem.  This commit replaces that to only delete the rita dashboard password and to remove only the wifi config from the overlay directory.  It does not do anything regarding the SSH password.

This reset button change is optional and controlled by the ansible var
reset_button_alt. This is only enabled by default for hawk managed
images.
  • Loading branch information
thosmos authored and jkilpatr committed Oct 17, 2024
1 parent 02edb84 commit 26a3465
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions profiles/management/hawk-managed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ exit_wifi_ssid_five_ghz: AltheaExit-5
wifi_disabled: 0
wifi_key: ChangeMe
copy_images: true
# enables alterante reset button behavior, specifically instead of
# resetting the device by deleting all overlay data it will reset the wifi config
# and rita dashboard password, allowing access to the device without erasing it's data
reset_button_alt: true

password_auth: "no"

Expand Down
6 changes: 6 additions & 0 deletions roles/build-config/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,9 @@ free_tier_throughput: 1000
max_fee: 20000000
full_nodes: ["https://dai.althea.net:443"]
system_chain: "Xdai"

# enables alterante reset button behavior
# False: Default behavior, all overlay data is reset and the device is wiped
# True: Instead of resetting the device by deleting all overlay data it will reset the wifi config
# and rita dashboard password, allowing access to the device without erasing it's data
reset_button_alt: false
12 changes: 12 additions & 0 deletions roles/build-config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
mode: 0600
when: insert_keys

- name: Create Button configuration folder
file:
path: "{{source_dir}}/files/etc/rc.button/"
state: directory
when: reset_button_alt

- name: Template reset button configuration
template:
src: "rc.button.j2"
dest: "{{source_dir}}/files/etc/rc.button/reset"
when: reset_button_alt

- name: Create the UCI config folder
file:
path: "{{source_dir}}/files/etc/config/"
Expand Down
30 changes: 30 additions & 0 deletions roles/build-config/templates/rc.button.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

. /lib/functions.sh

OVERLAY="$( grep ' /overlay ' /proc/mounts )"

case "$ACTION" in
timeout)
. /etc/diag.sh
set_state failsafe
;;
released)
if [ "$SEEN" -lt 1 ]
then
echo "REBOOT" > /dev/console
sync
reboot
elif [ "$SEEN" -ge 5 -a -n "$OVERLAY" ]
then
echo "ROUTER RESET" > /dev/console
rm /overlay/upper/etc/config/wireless
/etc/init.d/rita stop
sed -i 's/rita_dashboard_password.*//g' /etc/rita.toml
sync
reboot
fi
;;
esac

return 0

0 comments on commit 26a3465

Please sign in to comment.