1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-27 10:09:28 +02:00

Default to interface value in /etc/raspap/hostapd.ini

This commit is contained in:
billz 2025-04-28 00:47:16 -07:00
parent 5d8b71b768
commit 0ad82da51c
2 changed files with 49 additions and 44 deletions

View File

@ -16,7 +16,7 @@ After=multi-user.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/bin/bash /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 3 ExecStart=/bin/bash /etc/raspap/hostapd/servicestart.sh --seconds 1
RemainAfterExit=no RemainAfterExit=no
[Install] [Install]

View File

@ -34,6 +34,20 @@ esac
done done
set -- "${positional[@]}" set -- "${positional[@]}"
# Load config file into associative array
declare -A config
if [ -r "$CONFIGFILE" ]; then
while IFS=" = " read -r key value; do
config["$key"]="$value"
done < "$CONFIGFILE"
fi
# Set interface from config if not set by parameter
if [ -z "$interface" ] && [ -n "${config[WifiInterface]}" ]; then
interface="${config[WifiInterface]}"
echo "Interface not provided. Using WifiInterface from config: $interface"
fi
echo "Stopping network services..." echo "Stopping network services..."
if [ $OPENVPNENABLED -eq 1 ]; then if [ $OPENVPNENABLED -eq 1 ]; then
systemctl stop openvpn-client@client systemctl stop openvpn-client@client
@ -49,58 +63,51 @@ if [ "${action}" = "stop" ]; then
exit 0 exit 0
fi fi
if [ -f "$DAEMONPATH" ] && [ ! -z "$interface" ]; then if [ -f "$DAEMONPATH" ] && [ -n "$interface" ]; then
echo "Changing RaspAP Daemon --interface to $interface" echo "Changing RaspAP Daemon --interface to $interface"
sed -i "s/\(--interface \)[[:alnum:]]*/\1$interface/" "$DAEMONPATH" sed -i "s/\(--interface \)[[:alnum:]]*/\1$interface/" "$DAEMONPATH"
fi fi
if [ -r "$CONFIGFILE" ]; then if [ "${config[BridgedEnable]}" = 1 ]; then
declare -A config if [ "${interface}" = "br0" ]; then
while IFS=" = " read -r key value; do echo "Stopping systemd-networkd"
config["$key"]="$value" systemctl stop systemd-networkd
done < "$CONFIGFILE"
if [ "${config[BridgedEnable]}" = 1 ]; then echo "Restarting eth0 interface..."
if [ "${interface}" = "br0" ]; then ip link set down eth0
echo "Stopping systemd-networkd" ip link set up eth0
systemctl stop systemd-networkd
echo "Restarting eth0 interface..." echo "Removing uap0 interface..."
ip link set down eth0 iw dev uap0 del
ip link set up eth0
echo "Removing uap0 interface..." echo "Enabling systemd-networkd"
iw dev uap0 del systemctl start systemd-networkd
systemctl enable systemd-networkd
fi
else
echo "Disabling systemd-networkd"
systemctl disable systemd-networkd
echo "Enabling systemd-networkd" ip link ls up | grep -q 'br0' &> /dev/null
systemctl start systemd-networkd if [ $? == 0 ]; then
systemctl enable systemd-networkd echo "Removing br0 interface..."
fi ip link set down br0
else ip link del dev br0
echo "Disabling systemd-networkd" fi
systemctl disable systemd-networkd
ip link ls up | grep -q 'br0' &> /dev/null if [ "${config[WifiAPEnable]}" = 1 ]; then
if [ $? == 0 ]; then if [ "${interface}" = "uap0" ]; then
echo "Removing br0 interface..."
ip link set down br0
ip link del dev br0
fi
if [ "${config[WifiAPEnable]}" = 1 ]; then ip link ls up | grep -q 'uap0' &> /dev/null
if [ "${interface}" = "uap0" ]; then if [ $? == 0 ]; then
echo "Removing uap0 interface..."
ip link ls up | grep -q 'uap0' &> /dev/null iw dev uap0 del
if [ $? == 0 ]; then
echo "Removing uap0 interface..."
iw dev uap0 del
fi
echo "Adding uap0 interface to ${config[WifiManaged]}"
iw dev ${config[WifiManaged]} interface add uap0 type __ap
# Bring up uap0 interface
ifconfig uap0 up
fi fi
echo "Adding uap0 interface to ${config[WifiManaged]}"
iw dev ${config[WifiManaged]} interface add uap0 type __ap
# Bring up uap0 interface
ifconfig uap0 up
fi fi
fi fi
fi fi
@ -122,8 +129,6 @@ if [ $OPENVPNENABLED -eq 1 ]; then
systemctl start openvpn-client@client systemctl start openvpn-client@client
fi fi
# @mp035 found that the wifi client interface would stop every 8 seconds
# for about 16 seconds. Reassociating seems to solve this
if [ "${config[WifiAPEnable]}" = 1 ]; then if [ "${config[WifiAPEnable]}" = 1 ]; then
echo "Reassociating wifi client interface..." echo "Reassociating wifi client interface..."
sleep "${seconds}" sleep "${seconds}"