blob: 25dd64414841f2a726f8eddc806f4d884f0eff17 [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
you.chend9948952023-05-19 11:05:24 +080010 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
you.chencd882682023-04-24 15:39:37 +080022 if [ $? != 0 ]; then
you.chend9948952023-05-19 11:05:24 +080023 /usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C $conf_file -r /run/wg870
you.chencd882682023-04-24 15:39:37 +080024 fi
25
26elif [ "$1" == "stop" ]; then
you.chen3c309002023-04-26 10:00:06 +080027 ps -eo "%p %a" | grep "/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid" | grep -v grep | awk '{print "kill "$1}' | sh
you.chencd882682023-04-24 15:39:37 +080028 ifconfig ap0 down
29 if [ $? != 0 ]; then
30 exit 1
31 fi
32else
33 exit 2
34fi
you.chen3c309002023-04-26 10:00:06 +080035
36exit 0