mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Paramaterized service start, handles both uap0 and default
This commit is contained in:
parent
a2829dcf78
commit
47a2b7c346
56
installers/servicestart.sh
Normal file → Executable file
56
installers/servicestart.sh
Normal file → Executable file
@ -1,39 +1,61 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# When wireless client AP mode is enabled, this script handles starting
|
||||||
|
# up network services in a specific order and timing to avoid race conditions.
|
||||||
|
|
||||||
# When wireless client AP mode is enabled, this script handles starting up network services in a specific order and timing to avoid race conditions.
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
# Todo: update /etc/rc.local script with /bin/bash /etc/raspap/hostapd/servicestart.sh to enable at system startup
|
NAME=raspap
|
||||||
|
DESC="Service control for RaspAP"
|
||||||
|
|
||||||
|
positional=()
|
||||||
|
while [[ $# -gt 0 ]]
|
||||||
|
do
|
||||||
|
key="$1"
|
||||||
|
|
||||||
|
case $key in
|
||||||
|
-i|--interface)
|
||||||
|
interface="$2"
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
|
-s|--seconds)
|
||||||
|
seconds="$2"
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
set -- "${positional[@]}"
|
||||||
|
|
||||||
echo "Stopping network services..."
|
echo "Stopping network services..."
|
||||||
systemctl stop hostapd.service
|
systemctl stop hostapd.service
|
||||||
systemctl stop dnsmasq.service
|
systemctl stop dnsmasq.service
|
||||||
systemctl stop dhcpcd.service
|
systemctl stop dhcpcd.service
|
||||||
|
|
||||||
echo "Removing uap0 interface..."
|
if [ "${interface}" = "uap0" ]; then
|
||||||
iw dev uap0 del
|
echo "Removing uap0 interface..."
|
||||||
|
iw dev uap0 del
|
||||||
|
|
||||||
echo "Adding uap0 interface..."
|
echo "Adding uap0 interface..."
|
||||||
iw dev wlan0 interface add uap0 type __ap
|
iw dev wlan0 interface add uap0 type __ap
|
||||||
|
|
||||||
# Add iptables rules (todo: persist to /etc/rc.local as with default rules)
|
# Bring up uap0 interface
|
||||||
echo "IPV4 forwarding: setting..."
|
ifconfig uap0 up
|
||||||
sysctl net.ipv4.ip_forward=1
|
else
|
||||||
echo "Editing IP tables..."
|
echo "Removing uap0 interface..."
|
||||||
iptables -t nat -A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.50.0/24 -j MASQUERADE
|
iw dev uap0 del
|
||||||
|
fi
|
||||||
# Bring up uap0 interface
|
|
||||||
ifconfig uap0 up
|
|
||||||
|
|
||||||
# Start services, mitigating race conditions
|
# Start services, mitigating race conditions
|
||||||
echo "Starting hostapd service..."
|
echo "Starting hostapd service..."
|
||||||
systemctl start hostapd.service
|
systemctl start hostapd.service
|
||||||
sleep 5
|
sleep "${seconds}"
|
||||||
|
|
||||||
echo "Starting dhcpcd service..."
|
echo "Starting dhcpcd service..."
|
||||||
systemctl start dhcpcd.service
|
systemctl start dhcpcd.service
|
||||||
sleep 5
|
sleep "${seconds}"
|
||||||
|
|
||||||
echo "Starting dnsmasq service..."
|
echo "Starting dnsmasq service..."
|
||||||
systemctl start dnsmasq.service
|
systemctl start dnsmasq.service
|
||||||
|
|
||||||
echo "servicestart DONE"
|
echo "RaspAP servicestart DONE"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user