This commit is contained in:
garywill 2020-12-24 20:36:09 +08:00 committed by garywill
parent 509eedf10f
commit a67c19d8f5
2 changed files with 20 additions and 13 deletions

View File

@ -312,7 +312,7 @@ Wifi hotspot:
## Donate ## Donate
[Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md) [Buy me a coffee](https://github.com/garywill/receiving/blob/master/receiving_methods.md), or just give a star!
## Thanks ## Thanks

31
lnxrouter Normal file → Executable file
View File

@ -1453,9 +1453,14 @@ if [[ $NM_RUNNING -eq 1 ]] && nm_knows $TARGET_IFACE ; then
fi fi
if [[ $NO_DNSMASQ -eq 0 ]]; then if [[ $NO_DNSMASQ -eq 0 ]]; then
if grep "^nobody:" /etc/group >/dev/null 2>&1 ; then
NOBODY_GROUP="nobody"
else
NOBODY_GROUP="nogroup"
fi
cat <<- EOF > $CONFDIR/dnsmasq.conf cat <<- EOF > $CONFDIR/dnsmasq.conf
user=nobody user=nobody
group=nobody group=$NOBODY_GROUP
bind-dynamic bind-dynamic
listen-address=${GATEWAY} listen-address=${GATEWAY}
interface=$SUBNET_IFACE interface=$SUBNET_IFACE
@ -1464,11 +1469,11 @@ if [[ $NO_DNSMASQ -eq 0 ]]; then
dhcp-range=${GATEWAY%.*}.10,${GATEWAY%.*}.250,255.255.255.0 dhcp-range=${GATEWAY%.*}.10,${GATEWAY%.*}.250,255.255.255.0
dhcp-option-force=option:router,${GATEWAY} dhcp-option-force=option:router,${GATEWAY}
#log-dhcp #log-dhcp
log-facility=/dev/null log-facility=/dev/stdout
bogus-priv bogus-priv
domain-needed domain-needed
EOF EOF
# 'log-dhcp' show too much logs. Using '-d' in dnsmasq command shows a proper dhcp log # 'log-dhcp'(Extra logging for DHCP) shows too much logs.
# if use '-d', 'log-facility' should = /dev/null # if use '-d', 'log-facility' should = /dev/null
if [[ $SHARE_METHOD == "none" ]]; then if [[ $SHARE_METHOD == "none" ]]; then
echo "no-resolv" >> $CONFDIR/dnsmasq.conf echo "no-resolv" >> $CONFDIR/dnsmasq.conf
@ -1635,16 +1640,18 @@ if [[ $NO_DNSMASQ -eq 0 ]]; then
echo echo
echo "Starting dnsmasq" echo "Starting dnsmasq"
# dnsmasq '-x' works only when no '-d' (run in foreground) # Using '-d'(no daemon) dnsmasq will not turn into 'nobody'
# Using '-d' dnsmasq will not turn into 'nobody' # '-x' works only when no '-d'
dnsmasq -d -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid -l $CONFDIR/dnsmasq.leases & dnsmasq -k -C $CONFDIR/dnsmasq.conf -x $CONFDIR/dnsmasq.pid -l $CONFDIR/dnsmasq.leases &
DNSMASQ_PID=$! #####DNSMASQ_PID=$! # only when with '-d'
echo "dnsmasq PID: $DNSMASQ_PID" ######echo "dnsmasq PID: $DNSMASQ_PID" # only when with '-d'
#while [[ ! -f $CONFDIR/dnsmasq.pid ]]; do i=0; while [[ ! -f $CONFDIR/dnsmasq.pid ]]; do
# sleep 1 sleep 1
#done i=$((i + 1))
if [[ $i -gt 10 ]]; then die "Couldn't get dnsmasq PID" ; fi
done
echo -n "dnsmasq PID: " ; cat $CONFDIR/dnsmasq.pid echo -n "dnsmasq PID: " ; cat $CONFDIR/dnsmasq.pid
#(wait $DNSMASQ_PID ; die "dnsmasq failed") & ######(wait $DNSMASQ_PID ; die "dnsmasq failed") & # wait can't deal with non-child
( while [ -e /proc/$DNSMASQ_PID ]; do sleep 10; done ; die "dnsmasq exited" ) & ( while [ -e /proc/$DNSMASQ_PID ]; do sleep 10; done ; die "dnsmasq exited" ) &
sleep 2 sleep 2