blob: 25dd64414841f2a726f8eddc806f4d884f0eff17 [file] [log] [blame]
you.chen8874cd62023-06-08 17:27:19 +08001#!/bin/sh
2
3if [ "$1" == "start" ]; then
4 ifconfig ap0 192.168.15.1 netmask 255.255.255.240
5
6 if [ $? != 0 ]; then
7 exit 1
8 fi
9 mkdir -p /run/wg870/dnsmasq.d
10 conf_file="/run/wg870/dnsmasq.conf"
11 echo "port=0" > $conf_file
12 echo "interface=ap0" >> $conf_file
13 echo "listen-address=192.168.15.1" >> $conf_file
14 echo "bind-interfaces" >> $conf_file
15 echo "localise-queries" >> $conf_file
16 echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h" >> $conf_file
17 echo "dhcp-option=3,192.168.15.1" >> $conf_file
18 echo "dhcp-option=6,192.168.15.1" >> $conf_file
19 echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h" >> $conf_file
20 echo "dhcp-leasefile=/run/wg870/ap0.lease" >> $conf_file
21 ps -eo "%p %a" | grep "/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid" | grep -v grep
22 if [ $? != 0 ]; then
23 /usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C $conf_file -r /run/wg870
24 fi
25
26elif [ "$1" == "stop" ]; then
27 ps -eo "%p %a" | grep "/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid" | grep -v grep | awk '{print "kill "$1}' | sh
28 ifconfig ap0 down
29 if [ $? != 0 ]; then
30 exit 1
31 fi
32else
33 exit 2
34fi
35
36exit 0