-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathS45dnsmasq
executable file
·64 lines (46 loc) · 1.27 KB
/
S45dnsmasq
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
#!/bin/bash
SYS_CONF="/etc/dnsmasq.conf"
BOOT_CONF="/boot/dnsmasq.conf"
USER_CONF="/data/etc/dnsmasq.conf"
CP_CONF="/etc/captive-portal.conf"
LOG="/var/log/dnsmasq.log"
PROG="/usr/sbin/dnsmasq"
test -x ${PROG} || exit 0
test -n "${OS_VERSION}" || source /etc/init.d/base
CONF=$(select_conf ${SYS_CONF} ${BOOT_CONF} ${USER_CONF})
test -s "${CONF}" || exit 0
source ${CP_CONF}
function start() {
msg_begin "Starting dnsmasq"
run_conf=/var/run/dnsmasq.conf
# Replace placeholders
eval "echo \"$(cat ${CONF})\"" > ${run_conf}
ip=$(cat ${run_conf} | grep range | cut -d '=' -f 2 | cut -d '.' -f 1,2,3).1
iface=$(cat ${run_conf} | grep interface | cut -d '=' -f 2)
if [[ "${CAPTIVE_PORTAL_ENABLED}" == true ]]; then
echo "address=/#/${ip}" >> ${run_conf}
fi
ifconfig ${iface} ${ip}
${PROG} -C ${run_conf} --log-facility=${LOG}
test $? == 0 && msg_done || msg_fail
}
function stop() {
msg_begin "Stopping dnsmasq"
killall -q $(basename ${PROG})
test $? == 0 && msg_done || msg_fail
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac