blob: 441a0ee70fc4bd275c3a4e561c556e8183b36383 [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
qs.xionge9aa4952023-07-05 20:51:38 +080016 echo "no-ping" >> $conf_file
17 echo "dhcp-authoritative" >> $conf_file
you.chend9948952023-05-19 11:05:24 +080018 echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h" >> $conf_file
19 echo "dhcp-option=3,192.168.15.1" >> $conf_file
lh499dada2023-10-25 06:30:48 -070020 echo "dhcp-option=6,192.168.15.1,114.114.114.114" >> $conf_file
you.chend9948952023-05-19 11:05:24 +080021 echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h" >> $conf_file
22 echo "dhcp-leasefile=/run/wg870/ap0.lease" >> $conf_file
23 ps -eo "%p %a" | grep "/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid" | grep -v grep
you.chencd882682023-04-24 15:39:37 +080024 if [ $? != 0 ]; then
lh499dada2023-10-25 06:30:48 -070025 /usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C $conf_file -r /run/wg870 --dhcp-broadcast
you.chencd882682023-04-24 15:39:37 +080026 fi
27
28elif [ "$1" == "stop" ]; then
you.chen3c309002023-04-26 10:00:06 +080029 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 +080030 ifconfig ap0 down
31 if [ $? != 0 ]; then
32 exit 1
33 fi
34else
35 exit 2
36fi
you.chen3c309002023-04-26 10:00:06 +080037
38exit 0