summaryrefslogtreecommitdiffstats
path: root/minikrebs/profiles/nfc-login/customfiles/usr/bin/login-manager
blob: f22a209e750f5cf53e47d8aaa3999ea1a3f387e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
#LOGIN_HOST=heidi.shack
#LOGIN_HOST=heidi:5000
LOGIN_HOST=10.42.10.38:5000
all_led(){
    for i in 3g wlan lan wps;do
        led $i $1
        
    done
}
led(){
    /usr/bin/mrled $1 $2
}

# fix for mr3020 weirdness
while sleep 1; do
    uid=$(nfc-list | grep UID | cut -d: -f 2 | sed 's/ //g')
    if ! [ x"$uid" = x ];then
        online=$(wget -O- http://$LOGIN_HOST/user/$uid/online 2>/dev/null)
        if [ x"$online" = "x" ];then
            led lan timer
        elif [ "$online" = "false" ];then
            action="login"
            led 3g timer
        else
            action="logout"
            led wlan timer
        fi
        wget -O- http://$LOGIN_HOST/user/$uid/$action &>/dev/null
        echo $uid $action
        sleep 5
        all_led none
    fi
done