blob: 8fe91f70f4b7edfad309b7dfe494183fb3542391 [file] [log] [blame]
you.chencd882682023-04-24 15:39:37 +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 echo "interface=ap0" > /run/wg870/dnsmasq.conf
11 echo "listen-address=127.0.0.1,192.168.15.1" >> /run/wg870/dnsmasq.conf
12 echo "bind-interfaces" >> /run/wg870/dnsmasq.conf
13 echo "localise-queries" >> /run/wg870/dnsmasq.conf
14 echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h" >> /run/wg870/dnsmasq.conf
15 ps -ef | grep "/usr/bin/dnsmasq" | grep "/run/wg870/dnsmasq.conf"
16 if [ $? != 0 ]; then
17 /usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C /run/wg870/dnsmasq.conf -r /run/wg870
18 fi
19
20elif [ "$1" == "stop" ]; then
21 ps -ef | grep "/usr/bin/dnsmasq" | grep "/run/wg870/dnsmasq.conf" | awk '{print $2}' | xargs kill
22 ifconfig ap0 down
23 if [ $? != 0 ]; then
24 exit 1
25 fi
26else
27 exit 2
28fi