you.chen | cd88268 | 2023-04-24 15:39:37 +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 |
you.chen | d994895 | 2023-05-19 11:05:24 +0800 | [diff] [blame] | 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 |
qs.xiong | e9aa495 | 2023-07-05 20:51:38 +0800 | [diff] [blame] | 16 | echo "no-ping" >> $conf_file |
| 17 | echo "dhcp-authoritative" >> $conf_file |
you.chen | d994895 | 2023-05-19 11:05:24 +0800 | [diff] [blame] | 18 | 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 |
lh | 499dada | 2023-10-25 06:30:48 -0700 | [diff] [blame] | 20 | echo "dhcp-option=6,192.168.15.1,114.114.114.114" >> $conf_file |
you.chen | d994895 | 2023-05-19 11:05:24 +0800 | [diff] [blame] | 21 | 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.chen | cd88268 | 2023-04-24 15:39:37 +0800 | [diff] [blame] | 24 | if [ $? != 0 ]; then |
lh | 499dada | 2023-10-25 06:30:48 -0700 | [diff] [blame] | 25 | /usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C $conf_file -r /run/wg870 --dhcp-broadcast |
you.chen | cd88268 | 2023-04-24 15:39:37 +0800 | [diff] [blame] | 26 | fi |
| 27 | |
| 28 | elif [ "$1" == "stop" ]; then |
you.chen | 3c30900 | 2023-04-26 10:00:06 +0800 | [diff] [blame] | 29 | ps -eo "%p %a" | grep "/usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid" | grep -v grep | awk '{print "kill "$1}' | sh |
you.chen | cd88268 | 2023-04-24 15:39:37 +0800 | [diff] [blame] | 30 | ifconfig ap0 down |
| 31 | if [ $? != 0 ]; then |
| 32 | exit 1 |
| 33 | fi |
| 34 | else |
| 35 | exit 2 |
| 36 | fi |
you.chen | 3c30900 | 2023-04-26 10:00:06 +0800 | [diff] [blame] | 37 | |
| 38 | exit 0 |