summaryrefslogtreecommitdiffstats
path: root/usr/lib/autowifi/lib/network
blob: a9e307394f12e90d36b69807dc04988bd4fac09b (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
#!/bin/sh

check_gateway(){
    ping -c 1 -w 5 $(ip route | awk '/default/{print $3}')
}
check_internet(){
    secret=$(curl http://krebsco.de/secret 2>/dev/null)
    if [ "$secret" == "1337" ]; then
        return 0
    else
        return 1
    fi
}

check_bandwidth(){
    echo $(curl http://www.microsoft.com/africa/4afrika/images/infographic.gif -w "%{speed_download}" -o /dev/null 2>/dev/null | sed 's/\..*//')
}

ip_start(){
    : ${interface?interface variable not set} ${1?please provide method to start ip}
    # usage: method [extra parms]
    case "$1" in
        dhcp)
            if exists dhcpcd; then 
                dhcpcd -x $interface
                dhcpcd -w -A $interface
            elif exists dhclient; then
                dhclient -x $interface
                dhclient $interface
            fi ;;
        *) echo "do not know ip starter $1";;
    esac
}