Root/target/linux/lantiq/base-files/etc/hotplug.d/button/10-generic.sh

1#!/bin/sh
2
3[ "${ACTION}" = "released" ] || exit 0
4
5. /lib/functions.sh
6
7logger "$BUTTON pressed for $SEEN seconds"
8
9local rfkill_state=0
10
11wifi_rfkill_set() {
12    uci set wireless.$1.disabled=$rfkill_state
13}
14
15wifi_rfkill_check() {
16    local disabled
17    config_get disabled $1 disabled
18    [ "$disabled" = "1" ] || rfkill_state=1
19}
20
21case "${BUTTON}" in
22    reset)
23        if [ "$SEEN" -lt 1 ]
24        then
25            echo "REBOOT" > /dev/console
26            sync
27            reboot
28        elif [ "$SEEN" -gt 5 ]
29        then
30            echo "FACTORY RESET" > /dev/console
31            firstboot && reboot &
32        fi
33        ;;
34
35    wps)
36        for dir in /var/run/hostapd-*; do
37            [ -d "$dir" ] || continue
38            hostapd_cli -p "$dir" wps_pbc
39        done
40        ;;
41
42    rfkill)
43        config_load wireless
44        config_foreach wifi_rfkill_check wifi-device
45        config_foreach wifi_rfkill_set wifi-device
46        uci commit wireless
47        wifi up
48        ;;
49
50    *)
51        logger "unknown button ${BUTTON}"
52        ;;
53esac
54

Archive Download this file



interactive