-
Notifications
You must be signed in to change notification settings - Fork 4
/
init
executable file
·92 lines (79 loc) · 1.72 KB
/
init
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh
#set -x
config="/system/conf/dnsmasq.conf";
curdir=$(cd $(dirname $0) && pwd)
hdnsconf="conf-dir=$curdir/conf";
usage() {
echo "ERROR: action missing"
echo "syntax: $0 <start|stop|restart|status|config|install|uninstall>"
echo "example: $0 start"
}
delConfDir() {
/system/sbin/writesys.sh
local hdnsdir=`echo "$curdir/conf" | sed -e 's:/:\\\\/:g'`
/bin/sed -ie "/conf-dir=$hdnsdir/d" $config 1>/dev/null 2>&1
/system/sbin/writesys.sh close
}
addConfDir() {
/system/sbin/writesys.sh
local hdnsdir=`echo "$curdir/conf" | sed -e 's:/:\\\\/:g'`
/bin/sed -ie "/conf-dir=$hdnsdir/d" $config 1>/dev/null 2>&1
echo $hdnsconf >> $config
/system/sbin/writesys.sh close
}
dnsStop() {
pid=`/bin/ps|grep dnsmasq|grep -v grep|awk '{print $1}'`
if [ "$pid" != "" ]; then
/bin/kill $pid
else
/usr/bin/killall dnsmasq
fi
}
dnsStart() {
dnsStop
/bin/dnsmasq -C "$config" &
}
hdnsEnable() {
addConfDir
dnsStart
}
hdnsDisable() {
delConfDir
dnsStart
}
hdnsStatus() {
conf=`/bin/grep "conf-dir" $config`
echo $conf
}
hdnsConfig() {
## TBD, need to handle the re-config data from plugin internal logic.
## for hdns, need to move the conf file into ./conf folder, and maybe want
## to restart DNS service
dnsStart
}
install(){
## init tp_apps.conf dir
echo "installed"
}
# main
if [ $# -lt 1 ]; then
usage
exit 1
fi
case "$1" in
"start" | "restart" )
hdnsEnable ;;
"stop" )
hdnsDisable ;;
"status" )
hdnsStatus ;;
"config" )
hdnsConfig ;;
"install" )
install ;;
"uninstall" )
hdnsDisable
echo "uninstall" ;;
* )
usage ;;
esac