mirror of
				https://github.com/billz/raspap-webgui.git
				synced 2025-03-01 10:31:47 +00:00 
			
		
		
		
	Add bridged-routed toggle to webgui
This commit is contained in:
		@@ -33,6 +33,8 @@ function DisplayHostAPDConfig()
 | 
				
			|||||||
            $status->addMessage('Attempting to start hotspot', 'info');
 | 
					            $status->addMessage('Attempting to start hotspot', 'info');
 | 
				
			||||||
            if ($arrHostapdConf['WifiAPEnable'] == 1) {
 | 
					            if ($arrHostapdConf['WifiAPEnable'] == 1) {
 | 
				
			||||||
                exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 3', $return);
 | 
					                exec('sudo /etc/raspap/hostapd/servicestart.sh --interface uap0 --seconds 3', $return);
 | 
				
			||||||
 | 
					            } elseif ($arrHostapdConf['BridgedEnable'] == 1) {
 | 
				
			||||||
 | 
					                exec('sudo /etc/raspap/hostapd/servicestart.sh --interface br0 --seconds 3', $return);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                exec('sudo /etc/raspap/hostapd/servicestart.sh --seconds 3', $return);
 | 
					                exec('sudo /etc/raspap/hostapd/servicestart.sh --seconds 3', $return);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -120,6 +122,18 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Check for Bridged AP mode checkbox
 | 
				
			||||||
 | 
					    $bridgedEnable = 0;
 | 
				
			||||||
 | 
					    if ($arrHostapdConf['BridgedEnable'] == 0) {
 | 
				
			||||||
 | 
					        if (isset($_POST['bridgedEnable'])) {
 | 
				
			||||||
 | 
					            $bridgedEnable = 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        if (isset($_POST['bridgedEnable'])) {
 | 
				
			||||||
 | 
					            $bridgedEnable = 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Check for Logfile output checkbox
 | 
					    // Check for Logfile output checkbox
 | 
				
			||||||
    $logEnable = 0;
 | 
					    $logEnable = 0;
 | 
				
			||||||
    if ($arrHostapdConf['LogEnable'] == 0) {
 | 
					    if ($arrHostapdConf['LogEnable'] == 0) {
 | 
				
			||||||
@@ -140,6 +154,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
 | 
				
			|||||||
    $cfg = [];
 | 
					    $cfg = [];
 | 
				
			||||||
    $cfg['LogEnable'] = $logEnable;
 | 
					    $cfg['LogEnable'] = $logEnable;
 | 
				
			||||||
    $cfg['WifiAPEnable'] = $wifiAPEnable;
 | 
					    $cfg['WifiAPEnable'] = $wifiAPEnable;
 | 
				
			||||||
 | 
					    $cfg['BridgedEnable'] = $bridgedEnable;
 | 
				
			||||||
    $cfg['WifiManaged'] = RASPI_WIFI_CLIENT_INTERFACE;
 | 
					    $cfg['WifiManaged'] = RASPI_WIFI_CLIENT_INTERFACE;
 | 
				
			||||||
    write_php_ini($cfg, '/etc/raspap/hostapd.ini');
 | 
					    write_php_ini($cfg, '/etc/raspap/hostapd.ini');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -228,6 +243,9 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
 | 
				
			|||||||
            $config.= 'interface=uap0'.PHP_EOL;
 | 
					            $config.= 'interface=uap0'.PHP_EOL;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $config.= 'interface='.$_POST['interface'].PHP_EOL;
 | 
					            $config.= 'interface='.$_POST['interface'].PHP_EOL;
 | 
				
			||||||
 | 
					            if ($bridgedEnable == 1) {
 | 
				
			||||||
 | 
					                $config.= 'bridge=br0'.PHP_EOL;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        $config.= 'wpa='.$_POST['wpa'].PHP_EOL;
 | 
					        $config.= 'wpa='.$_POST['wpa'].PHP_EOL;
 | 
				
			||||||
        $config.= 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL;
 | 
					        $config.= 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL;
 | 
				
			||||||
@@ -288,7 +306,10 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
 | 
				
			|||||||
        $config[] = 'slaac private';
 | 
					        $config[] = 'slaac private';
 | 
				
			||||||
        $config[] = 'nohook lookup-hostname';
 | 
					        $config[] = 'nohook lookup-hostname';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($wifiAPEnable == 1) {
 | 
					        if ($bridgedEnable == 1) {
 | 
				
			||||||
 | 
					            $config[] = 'denyinterfaces eth0 wlan0';
 | 
				
			||||||
 | 
					            $config[] = 'interface br0';
 | 
				
			||||||
 | 
					        } elseif ($wifiAPEnable == 1) {
 | 
				
			||||||
            // Enable uap0 configuration in dhcpcd for Wifi client AP mode
 | 
					            // Enable uap0 configuration in dhcpcd for Wifi client AP mode
 | 
				
			||||||
            $intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/uap0.ini', false, INI_SCANNER_RAW);
 | 
					            $intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/uap0.ini', false, INI_SCANNER_RAW);
 | 
				
			||||||
            $ip_address = ($intConfig['ip_address'] == '') ? '192.168.50.1/24' : $intConfig['ip_address'];
 | 
					            $ip_address = ($intConfig['ip_address'] == '') ? '192.168.50.1/24' : $intConfig['ip_address'];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -177,7 +177,7 @@ function download_latest_files() {
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    install_log "Cloning latest files from github"
 | 
					    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"
 | 
					    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
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for file in /etc/systemd/network/raspap-*.net*; do
 | 
					    for file in /etc/systemd/network/raspap-*.net*; do
 | 
				
			||||||
        sudo cp "$file" "${raspap_dir}/backups/${file}.`date +%F-%R`"
 | 
					        if [-f "${file}" ]; then
 | 
				
			||||||
        sudo ln -sf "${raspap_dir}/backups/${file}.`date +%F-%R`" "${raspap_dir}/backups/${file}"
 | 
					            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
 | 
					    done
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 | 
				
			|||||||
NAME=raspap
 | 
					NAME=raspap
 | 
				
			||||||
DESC="Service control for RaspAP"
 | 
					DESC="Service control for RaspAP"
 | 
				
			||||||
CONFIGFILE="/etc/raspap/hostapd.ini"
 | 
					CONFIGFILE="/etc/raspap/hostapd.ini"
 | 
				
			||||||
 | 
					DAEMONPATH="/lib/systemd/system/raspap.service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
positional=()
 | 
					positional=()
 | 
				
			||||||
while [[ $# -gt 0 ]]
 | 
					while [[ $# -gt 0 ]]
 | 
				
			||||||
@@ -28,16 +29,40 @@ done
 | 
				
			|||||||
set -- "${positional[@]}"
 | 
					set -- "${positional[@]}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Stopping network services..."
 | 
					echo "Stopping network services..."
 | 
				
			||||||
 | 
					systemctl stop systemd-networkd
 | 
				
			||||||
systemctl stop hostapd.service
 | 
					systemctl stop hostapd.service
 | 
				
			||||||
systemctl stop dnsmasq.service
 | 
					systemctl stop dnsmasq.service
 | 
				
			||||||
systemctl stop dhcpcd.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
 | 
					if [ -r "$CONFIGFILE" ]; then
 | 
				
			||||||
    declare -A config
 | 
					    declare -A config
 | 
				
			||||||
    while IFS=" = " read -r key value; do
 | 
					    while IFS=" = " read -r key value; do
 | 
				
			||||||
        config["$key"]="$value"
 | 
					        config["$key"]="$value"
 | 
				
			||||||
    done < "$CONFIGFILE"
 | 
					    done < "$CONFIGFILE"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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 [ "${config[WifiAPEnable]}" = 1 ]; then
 | 
				
			||||||
            if [ "${interface}" = "uap0" ]; then
 | 
					            if [ "${interface}" = "uap0" ]; then
 | 
				
			||||||
                echo "Removing uap0 interface..."
 | 
					                echo "Removing uap0 interface..."
 | 
				
			||||||
@@ -49,6 +74,7 @@ if [ -r "$CONFIGFILE" ]; then
 | 
				
			|||||||
                ifconfig uap0 up
 | 
					                ifconfig uap0 up
 | 
				
			||||||
            fi
 | 
					            fi
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Start services, mitigating race conditions
 | 
					# Start services, mitigating race conditions
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -429,6 +429,9 @@ msgstr "Logfile output"
 | 
				
			|||||||
msgid "WiFi client AP mode"
 | 
					msgid "WiFi client AP mode"
 | 
				
			||||||
msgstr "WiFi client AP mode"
 | 
					msgstr "WiFi client AP mode"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msgid "Bridged AP mode"
 | 
				
			||||||
 | 
					msgstr "Bridged AP mode"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
msgid "Hide SSID in broadcast"
 | 
					msgid "Hide SSID in broadcast"
 | 
				
			||||||
msgstr "Hide SSID in broadcast"
 | 
					msgstr "Hide SSID in broadcast"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,6 +134,15 @@
 | 
				
			|||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					            <div class="row">
 | 
				
			||||||
 | 
					              <div class="col-md-6 mb-2">
 | 
				
			||||||
 | 
					                <div class="custom-control custom-switch">
 | 
				
			||||||
 | 
					                  <?php $checked = $arrHostapdConf['BridgedEnable'] == 1 ? 'checked="checked"' : '' ?>
 | 
				
			||||||
 | 
					                  <input class="custom-control-input" id="chxbridgedenable" name="bridgedEnable" type="checkbox" value="1" <?php echo $checked ?> />
 | 
				
			||||||
 | 
					                  <label class="custom-control-label" for="chxbridgedenable"><?php echo _("Bridged AP mode"); ?></label>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					              </div>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
            <div class="row">
 | 
					            <div class="row">
 | 
				
			||||||
              <div class="col-md-6 mb-2">
 | 
					              <div class="col-md-6 mb-2">
 | 
				
			||||||
                <div class="custom-control custom-switch">
 | 
					                <div class="custom-control custom-switch">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user