-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinternet-hg680p.sh
57 lines (49 loc) · 914 Bytes
/
internet-hg680p.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Internet Indicator for HG680P Wrapper
# by Lutfa Ilham
# v1.0
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
SERVICE_NAME="Internet Indicator"
function loop() {
while true; do
hg680p.sh -lan warn
if curl -X "HEAD" --connect-timeout 3 -so /dev/null "http://bing.com"; then
hg680p.sh -lan on
else
hg680p.sh -lan off
fi
sleep 1
done
}
function start() {
echo -e "Starting ${SERVICE_NAME} service ..."
screen -AmdS internet-indicator "${0}" -l
}
function stop() {
echo -e "Stopping ${SERVICE_NAME} service ..."
kill $(screen -list | grep internet-indicator | awk -F '[.]' {'print $1'})
}
function usage() {
cat <<EOF
Usage:
-r Run ${SERVICE_NAME} service
-s Stop ${SERVICE_NAME} service
EOF
}
case "${1}" in
-l)
loop
;;
-r)
start
;;
-s)
stop
;;
*)
usage
;;
esac