diff --git a/config/dhcpcd.conf b/config/dhcpcd.conf index 5804655b..22a4ae18 100644 --- a/config/dhcpcd.conf +++ b/config/dhcpcd.conf @@ -10,6 +10,11 @@ require dhcp_server_identifier slaac private nohook lookup-hostname +#denyinterfaces eth0 wlan0 #BRIDGED + +# RaspAP br0 configuration +interface br0 + # RaspAP wlan0 configuration interface wlan0 static ip_address=10.3.141.1/24 diff --git a/config/hostapd.conf b/config/hostapd.conf index be164e30..856e4a1b 100644 --- a/config/hostapd.conf +++ b/config/hostapd.conf @@ -20,3 +20,5 @@ country_code= ## RaspAP wireless client AP mode #interface=uap0 +## RaspAP bridge AP mode (disabled by default) +#bridge=br0 diff --git a/config/raspap-br0-member-eth0.network b/config/raspap-br0-member-eth0.network new file mode 100644 index 00000000..1eddb017 --- /dev/null +++ b/config/raspap-br0-member-eth0.network @@ -0,0 +1,5 @@ +[Match] +Name=eth0 + +[Network] +Bridge=br0 diff --git a/config/raspap-bridge-br0.netdev b/config/raspap-bridge-br0.netdev new file mode 100644 index 00000000..6ec2b6dc --- /dev/null +++ b/config/raspap-bridge-br0.netdev @@ -0,0 +1,3 @@ +[NetDev] +Name=br0 +Kind=bridge diff --git a/installers/common.sh b/installers/common.sh index f0817664..43fe9d0e 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -169,7 +169,8 @@ function download_latest_files() { fi install_log "Cloning latest files from github" - git clone --depth 1 https://github.com/billz/raspap-webgui /tmp/raspap-webgui || install_error "Unable to download files from github" + # git clone --depth 1 https://github.com/billz/raspap-webgui /tmp/raspap-webgui || install_error "Unable to download files from github" + git clone --single-branch --branch bridge-mode --depth 1 https://github.com/Taikuh/raspap-webgui /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" } @@ -209,6 +210,11 @@ function check_for_old_configs() { sudo cp /etc/rc.local "$raspap_dir/backups/rc.local.`date +%F-%R`" sudo ln -sf "$raspap_dir/backups/rc.local.`date +%F-%R`" "$raspap_dir/backups/rc.local" 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}" + done } # Move configuration file to the correct location @@ -235,6 +241,11 @@ function default_configuration() { [ -d /etc/dnsmasq.d ] || sudo mkdir /etc/dnsmasq.d + sudo systemctl stop systemd-networkd + sudo systemctl disable systemd-networkd + sudo cp $webroot_dir/config/raspap-bridge-br0.netdev /etc/systemd/network/raspap-bridge-br0.netdev || install_error "Unable to move br0 netdev file" + sudo cp $webroot_dir/config/raspap-br0-member-eth0.network /etc/systemd/network/raspap-br0-member-eth0.network || install_error "Unable to move br0 member file" + if [ ! -f "$webroot_dir/includes/config.php" ]; then sudo cp "$webroot_dir/config/config.php" "$webroot_dir/includes/config.php" fi diff --git a/installers/toggle-bridged-routed.sh b/installers/toggle-bridged-routed.sh new file mode 100755 index 00000000..5020bcfb --- /dev/null +++ b/installers/toggle-bridged-routed.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +function do_routed_mode() { + sudo systemctl disable systemd-networkd + + sudo sed -i "s/^.*#BRIDGED$/#&/" /etc/dhcpcd.conf + sudo sed -i "s/^bridge/#&/" /etc/hostapd/hostapd.conf + + sudo ip link set down br0 + sudo ip link del dev br0 +} + +function do_bridged_mode() { + sudo sed -i "s/^#\(.*#BRIDGED\)$/\1/" /etc/dhcpcd.conf + sudo sed -i "s/^#\(bridge\)/\1/" /etc/hostapd/hostapd.conf + + sudo ip link set down eth0 + sudo ip link set up eth0 + + sudo systemctl start systemd-networkd + sudo systemctl enable systemd-networkd +} + +sudo systemctl stop systemd-networkd +sudo systemctl stop hostapd +sudo systemctl stop dhcpcd +sudo systemctl stop dnsmasq + +if [ "$1" = "force-routed" ] +then do_routed_mode +elif [ "$1" = "force-bridged" ] +then do_bridged_mode +elif ip addr show br0 | grep 'inet ' > /dev/null +then do_routed_mode +elif ! ip addr show br0 | grep 'inet ' > /dev/null +then do_bridged_mode +fi + +sudo systemctl start hostapd +sudo systemctl start dhcpcd +sudo systemctl start dnsmasq