| 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 | 5196264 | 2023-05-10 15:52:57 +0800 | [diff] [blame] | 10 | echo "port=0" > /run/wg870/dnsmasq.conf |
| 11 | echo "interface=ap0" >> /run/wg870/dnsmasq.conf |
| 12 | echo "listen-address=192.168.15.1" >> /run/wg870/dnsmasq.conf |
| you.chen | cd88268 | 2023-04-24 15:39:37 +0800 | [diff] [blame] | 13 | echo "bind-interfaces" >> /run/wg870/dnsmasq.conf |
| 14 | echo "localise-queries" >> /run/wg870/dnsmasq.conf |
| 15 | echo "dhcp-range=192.168.15.2,192.168.15.14,255.255.255.240,1h" >> /run/wg870/dnsmasq.conf |
| you.chen | 57eb584 | 2023-05-18 14:19:46 +0800 | [diff] [blame] | 16 | echo "dhcp-leasefile=/run/wg870/ap0.lease" >> /run/wg870/dnsmasq.conf |
| you.chen | 3c30900 | 2023-04-26 10:00:06 +0800 | [diff] [blame] | 17 | 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] | 18 | if [ $? != 0 ]; then |
| 19 | /usr/bin/dnsmasq -x /run/wg870/dnsmasq.pid -7 /run/wg870/dnsmasq.d --local-service -C /run/wg870/dnsmasq.conf -r /run/wg870 |
| 20 | fi |
| 21 | |
| 22 | elif [ "$1" == "stop" ]; then |
| you.chen | 3c30900 | 2023-04-26 10:00:06 +0800 | [diff] [blame] | 23 | 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] | 24 | ifconfig ap0 down |
| 25 | if [ $? != 0 ]; then |
| 26 | exit 1 |
| 27 | fi |
| 28 | else |
| 29 | exit 2 |
| 30 | fi |
| you.chen | 3c30900 | 2023-04-26 10:00:06 +0800 | [diff] [blame] | 31 | |
| 32 | exit 0 |