diff --git a/README.md b/README.md index df6e45d9..c3c8f47e 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ We hope you enjoy using RaspAP as much as we do creating it. Tell us how you use - [Prerequisites](#prerequisites) - [Quick installer](#quick-installer) + - [Bridged AP](#bridged-ap) - [Simultaneous AP and Wifi client](#simultaneous-ap-and-wifi-client) - [Support us](#support-us) - [Manual installation](#manual-installation) @@ -60,6 +61,11 @@ configured as an access point as follows: **Note:** As the name suggests, the Quick Installer is a great way to quickly setup a new AP. However, it does not automagically detect the unique configuration of your RPi. Best results are obtained by connecting an RPi to ethernet (`eth0`) or as a WiFi client, also known as managed mode, with `wlan0`. For the latter, refer to [this FAQ](https://github.com/billz/raspap-webgui/wiki/FAQs#how-do-i-prepare-the-sd-card-to-connect-to-wifi-in-headless-mode). Please [read this](https://github.com/billz/raspap-webgui/wiki/Reporting-issues) before reporting an issue. +## Bridged AP +By default RaspAP configures a routed AP for your clients to connect to. A bridged AP configuration is also possible. Slide the **Bridged AP mode** toggle under the **Advanced** tab of **Configure hotspot**, then save and restart the hotspot. + +**Note:** In bridged mode, all routing capabilities are handled by your upstream router. Because your router assigns IP addresses to your RPi's hotspot and its clients, you might not be able to reach the RaspAP web interface from the default `10.3.141.1` address. Instead use your RPi's hostname followed by `.local` to access the RaspAP web interface. With Raspbian default settings, this should look like `raspberrypi.local`. + ## Simultaneous AP and Wifi client RaspAP lets you easily create an AP with a Wifi client configuration. With your RPi configured in managed mode, enable the AP from the **Advanced** tab of **Configure hotspot** by sliding the **Wifi client AP mode** toggle. Save settings and start the hotspot. The managed mode AP is functional without restart. diff --git a/includes/hostapd.php b/includes/hostapd.php index 41d7afcf..8a351fba 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -246,11 +246,11 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) } if ($wifiAPEnable == 1) { $config.= 'interface=uap0'.PHP_EOL; + } elseif ($bridgedEnable == 1) { + $config.='interface='.RASPI_WIFI_CLIENT_INTERFACE.PHP_EOL; + $config.= 'bridge=br0'.PHP_EOL; } else { $config.= 'interface='.$_POST['interface'].PHP_EOL; - if ($bridgedEnable == 1) { - $config.= 'bridge=br0'.PHP_EOL; - } } $config.= 'wpa='.$_POST['wpa'].PHP_EOL; $config.= 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL; diff --git a/includes/openvpn.php b/includes/openvpn.php index 5f6c2827..5fc11e63 100755 --- a/includes/openvpn.php +++ b/includes/openvpn.php @@ -21,12 +21,14 @@ function DisplayOpenVPNConfig() } elseif (isset($_POST['StartOpenVPN'])) { $status->addMessage('Attempting to start OpenVPN', 'info'); exec('sudo /bin/systemctl start openvpn-client@client', $return); + exec('sudo /bin/systemctl enable openvpn-client@client', $return); foreach ($return as $line) { $status->addMessage($line, 'info'); } } elseif (isset($_POST['StopOpenVPN'])) { $status->addMessage('Attempting to stop OpenVPN', 'info'); exec('sudo /bin/systemctl stop openvpn-client@client', $return); + exec('sudo /bin/systemctl disable openvpn-client@client', $return); foreach ($return as $line) { $status->addMessage($line, 'info'); } diff --git a/installers/common.sh b/installers/common.sh index d8ac9327..e73add3e 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -325,7 +325,9 @@ function patch_system_files() { "/bin/systemctl start dnsmasq.service" "/bin/systemctl stop dnsmasq.service" "/bin/systemctl start openvpn-client@client" + "/bin/systemctl enable openvpn-client@client" "/bin/systemctl stop openvpn-client@client" + "/bin/systemctl disable openvpn-client@client" "/bin/cp /tmp/ovpnclient.ovpn /etc/openvpn/client/client.conf" "/bin/cp /tmp/authdata /etc/openvpn/client/login.conf" "/bin/cp /tmp/dnsmasqdata /etc/dnsmasq.conf" diff --git a/installers/configauth.sh b/installers/configauth.sh index 5fc6965a..1300f8c3 100755 --- a/installers/configauth.sh +++ b/installers/configauth.sh @@ -34,7 +34,8 @@ lines=( for line in "${lines[@]}"; do if grep "$line" /etc/rc.local > /dev/null; then - else + echo "$line: Line already added" + else sudo sed -i "s/^exit 0$/$line\nexit 0/" /etc/rc.local echo "Adding rule: $line" fi diff --git a/installers/servicestart.sh b/installers/servicestart.sh index 76e7e2ea..710d2b4b 100755 --- a/installers/servicestart.sh +++ b/installers/servicestart.sh @@ -7,6 +7,7 @@ NAME=raspap DESC="Service control for RaspAP" CONFIGFILE="/etc/raspap/hostapd.ini" DAEMONPATH="/lib/systemd/system/raspap.service" +OPENVPNENABLED=$(pidof openvpn | wc -l) positional=() while [[ $# -gt 0 ]] @@ -29,6 +30,7 @@ done set -- "${positional[@]}" echo "Stopping network services..." +systemctl stop openvpn-client@client systemctl stop systemd-networkd systemctl stop hostapd.service systemctl stop dnsmasq.service @@ -51,6 +53,9 @@ if [ -r "$CONFIGFILE" ]; then ip link set down eth0 ip link set up eth0 + echo "Removing uap0 interface..." + iw dev uap0 del + echo "Enabling systemd-networkd" systemctl start systemd-networkd systemctl enable systemd-networkd @@ -87,5 +92,9 @@ sleep "${seconds}" systemctl start dnsmasq.service +if [ $OPENVPNENABLED -eq 1 ]; then + systemctl start openvpn-client@client +fi + echo "RaspAP service start DONE"