| you.chen | 8874cd6 | 2023-06-08 17:27:19 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | if [ "$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 | |
| 26 | elif [ "$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 |
| 32 | else |
| 33 | exit 2 |
| 34 | fi |
| 35 | |
| 36 | exit 0 |