Add bridged-routed toggle to webgui

This commit is contained in:
Taikuh
2020-03-10 16:42:08 +08:00
parent 8bda81adcb
commit 8823c0602e
5 changed files with 75 additions and 13 deletions

View File

@@ -177,7 +177,7 @@ function download_latest_files() {
fi
install_log "Cloning latest files from github"
git clone --single-branch $branch --depth 1 $git_source_url /tmp/raspap-webgui || install_error "Unable to download files from github"
git clone --branch $branch --depth 1 $git_source_url /tmp/raspap-webgui || install_error "Unable to download files from github"
sudo mv /tmp/raspap-webgui $webroot_dir || install_error "Unable to move raspap-webgui to web root"
}
@@ -220,8 +220,11 @@ function check_for_old_configs() {
fi
for file in /etc/systemd/network/raspap-*.net*; do
sudo cp "$file" "${raspap_dir}/backups/${file}.`date +%F-%R`"
sudo ln -sf "${raspap_dir}/backups/${file}.`date +%F-%R`" "${raspap_dir}/backups/${file}"
if [-f "${file}" ]; then
filename = $(basename $file)
sudo cp "$file" "${raspap_dir}/backups/${filename}.`date +%F-%R`"
sudo ln -sf "${raspap_dir}/backups/${filename}.`date +%F-%R`" "${raspap_dir}/backups/${filename}"
fi
done
}

View File

@@ -6,6 +6,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=raspap
DESC="Service control for RaspAP"
CONFIGFILE="/etc/raspap/hostapd.ini"
DAEMONPATH="/lib/systemd/system/raspap.service"
positional=()
while [[ $# -gt 0 ]]
@@ -28,25 +29,50 @@ done
set -- "${positional[@]}"
echo "Stopping network services..."
systemctl stop systemd-networkd
systemctl stop hostapd.service
systemctl stop dnsmasq.service
systemctl stop dhcpcd.service
if [ -f "$DAEMONPATH" ]; then
echo "Changing RaspAP Daemon --interface to $interface"
sed -i "s/\(--interface \)[[:alnum:]]*/\1$interface/" "$DAEMONPATH"
fi
if [ -r "$CONFIGFILE" ]; then
declare -A config
while IFS=" = " read -r key value; do
config["$key"]="$value"
done < "$CONFIGFILE"
if [ "${config[WifiAPEnable]}" = 1 ]; then
if [ "${interface}" = "uap0" ]; then
echo "Removing uap0 interface..."
iw dev uap0 del
echo "Adding uap0 interface to ${config[WifiManaged]}"
iw dev ${config[WifiManaged]} interface add uap0 type __ap
# Bring up uap0 interface
ifconfig uap0 up
if [ "${config[BridgedEnable]}" = 1 ]; then
if [ "${interface}" = "br0" ]; then
echo "Restarting eth0 interface..."
ip link set down eth0
ip link set up eth0
echo "Enabling systemd-networkd"
systemctl start systemd-networkd
systemctl enable systemd-networkd
fi
else
echo "Disabling systemd-networkd"
systemctl disable systemd-networkd
echo "Removing br0 interface..."
ip link set down br0
ip link del dev br0
if [ "${config[WifiAPEnable]}" = 1 ]; then
if [ "${interface}" = "uap0" ]; then
echo "Removing uap0 interface..."
iw dev uap0 del
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