forked from openwrt/openwrt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
. /lib/functions.sh | ||
|
||
reset_sdcard() { #Not sure what really do. Check | ||
logger Resetting the SD card reader | ||
echo "0" > /sys/class/gpio/gpio18/value | ||
echo "1" > /sys/class/gpio/gpio18/value | ||
} | ||
|
||
|
||
|
||
board=$(board_name) | ||
|
||
case "$board" in | ||
zsun,sdreader) | ||
reset_sdcard | ||
;; | ||
esac |
23 changes: 23 additions & 0 deletions
23
target/linux/ath79/base-files/lib/preinit/50_failsafe_wipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
|
||
erase_all() { | ||
echo "Doing a factory reset." | ||
mount_root | ||
firstboot -y | ||
sleep 10 | ||
reboot -f | ||
} | ||
|
||
failsafe_wipe() { | ||
. /lib/functions.sh | ||
|
||
board=$(board_name) | ||
|
||
case "$board" in | ||
zsun,sdreader) | ||
erase_all | ||
;; | ||
esac | ||
} | ||
|
||
boot_hook_add failsafe failsafe_wipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/sh | ||
# Some devices can be only accesed by wifi (zsun for example). To avoid enable wifi automatically, we will do it based on a file presence inside external device | ||
|
||
|
||
enable_all_wifi_ifaces() { | ||
for entry in $(uci show wireless | grep -E '@wifi-iface\[\d+\]\.device'); do # list all wifi devices | ||
dev=$(echo $entry| sed -nre 's/.*\[(\d+)\].*/\1/p'); #get the asociated number | ||
uci set wireless.@wifi-iface[$dev].disabled='0' | ||
done | ||
|
||
uci commit wireless | ||
wifi | ||
} | ||
|
||
generic_wifi_on() { | ||
|
||
mount_tmp=$(mktemp -d) | ||
|
||
for partition in $(cat /proc/partitions | grep -v block | awk '{print $4}' | grep '\d'); do | ||
#No beauty way to determine fs type. Let's try and see what will happen | ||
mount /dev/$partition $mount_tmp | ||
if [ $? -eq 0 ]; then | ||
#mounted! | ||
if [ -f $mount_tmp/openwrt_wireless ]; then | ||
#File available. Let's turn on the wifi | ||
|
||
enable_all_wifi_ifaces | ||
|
||
rm $mount_tmp/openwrt_wireless | ||
fi | ||
umount /dev/$partition | ||
fi | ||
done | ||
|
||
rmdir $mount_tmp | ||
|
||
} | ||
|
||
enable_wifi() { | ||
. /lib/functions.sh | ||
|
||
board=$(board_name) | ||
|
||
case "$board" in | ||
zsun,sdreader) | ||
generic_wifi_on | ||
;; | ||
esac | ||
} | ||
|
||
boot_hook_add preinit_mount_root enable_wifi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters