Add Reset Key button

Source: Internet
Author: User
Tags reset sleep
foundUci-defaults looks like you can inject the settings file
#!/bin/sh
uci-q Show system. @restorefactory [0] | | {
	UCI Add system restorefactory
	UCI set System. @restorefactory [0].button=reset
	UCI set system.@ restorefactory[0].action=pressed
	UCI set System. @restorefactory [0].timeout=5
	UCI commit
}
Mori Bright number Modify mirrorhttps://code.google.com/p/openwrt-restorefactory-slboat/ Modify increased LED display, 10 seconds default timeoutPress the reset button to start 2.5 seconds at a time, if held for 10 seconds, then start flashing quickly, the representative has begun to reset when the time of the cancellation, the LED recovery light default timeout changed to 10 seconds, 5 seconds may be prone to false trigger Source Code
#!/bin/sh   # Let ' s Loag the LED.
/etc/diag.sh get_status_led   # for failsafe mode,it cant read everything button= "reset" action= "pressed" timeout=10   System_config () {config_get button "$" button "reset" Config_get action "$" action "pressed" Config_get Timeo UT "$" timeout "Ten"}   config_load system Config_foreach system_config restorefactory   ["$BUTTON" = "$button "] && {[-f/tmp/run/restore_now.pid] && logger-p user.info-t" restorefactory "" Restore to factory a Re start working now! "&& exit 1   # If we cancal One,then let the ' led just normal on [-f/tmp/run/restor EFACTORY.PID] && Read PID </tmp/run/restorefactory.pid && kill $PID && RM/TMP/RUN/RESTOREFAC Tory.pid && logger-p user.info-t "restorefactory" "Restore to Factory defaults aborted" && set_state Don e && [-f/tmp/.failsafe] && set_state failsafe   ["$ACTION" = "$action"] &AMP;&Amp  {  If ["$timeout"-GT 0] then # make the LED slow, so we know now is doing restore Status_led_set_timer   # Make sure we can use the folder/tmp/run,mostly just is not easy with it in Failsafemode mkdir-p/tmp/ run/  # Wait the time and let led flash like failsafe sleep "$timeout" && status_led_set_timer 80 200 && rm/tmp/run/restorefactory.pid && echo work >/tmp/run/restore_now.pid && firstboot && Amp Set_state done && sleep 2 && reboot-f &   Echo $! >/tmp/run/restorefactory.pid   logger-p user.info-t "restorefactory" "Restoring to factory defaults in $time Out seconds "elif [" $timeout "-eq 0] then # make the LED Feelsafe set_state failsafe   Firstboot &amp ;& reboot & Else logger-p user.info-t "restorefactory" "Invalid timeout value ($timeout)" fi}}
failsafe Hook Patch addedInject an open hotplug file to name it: 50_hotplug_for_failsafe.sh
#!/bin/sh
# This was Strart hotplud for failsafe
# The MoD was by Slboat
start_hotplug2 () {
        killall-q HOTPLUG2
        [-x/sbin/hotplug2] &&/sbin/hotplug2--override--persistent \
                        --set-rules-file/etc/ hotplug2.rules \
                        --set-coldplug-cmd/sbin/udevtrigger \
                        --max-children 1 >/dev/null 2>&1 &
	echo-e "\ slboat:the hotplug2 for the reset button has start!"
	echo "IF you like,you can push reset button + than second for Firstboot"
  }
Boot_hook_add FAI Lsafe START_HOTPLUG2
Its effect looks like this. Source Appreciation/etc/hotplug.d/button/50-restorefactory
#!/bin/sh   #像是初始化设置 System_config () {# bind button, reset button config_get "" button "reset" # only trigger Config_get AC when pressed down tion "$" action "pressed" # Default timeout 5 seconds config_get Timeout "$" timeout "5"}   # Load the settings from the system and look through the UCI config_load SYS TEM # Zujou system settings for each restorefactory Config_foreach system_config restorefactory   # If the trigger button matches ["$BUTTON" = "$button"] &A mp;& {# If there is a process, read the process ID, kill the process, delete the process ID file, log the event [-f/tmp/run/restorefactory.pid] && read PID </tmp/ Run/restorefactory.pid && kill $PID && rm/tmp/run/restorefactory.pid && logger-p user.info-t "R Estorefactory "" Restore to Factory defaults aborted "# has a specified trigger event, which is the press of the reset button, release will trigger the above thing [" $ACTION "=" $action "] && {  If [" $timeout "-GT 0] then # Wait a few seconds, then perform a reset restart, if the middle is pressed again will terminate the operation, here the last & is the background running the thing Sleep" $t Imeout "&& firstboot && Reboot & # Interesting is the following will be executed directly, and will not wait for the above # to write the current process ID into a file echo $!
		>/tmp/run/restorefactory.pid	Logger-p user.info-t "Restorefactory" "Restoring to factory defaults in $timeout seconds" elif ["$timeout"-eq 0] # If the timeout setting is 0, then the direct restart then Firstboot && reboot & Else # timeout is invalid logger-p user.info-t "Restorefac Tory "" Invalid timeout value ($timeout) "fi}}
found in

Compile OpenWrt firmware/compile embedded Luci package include file

root@openwrt:/# opkg Files Restorefactory package
restorefactory (1-6) was installed on root and have the following file S:
/etc/uci-defaults/50-restorefactory
/etc/hotplug.d/button/50-restorefactory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.