Merge branch 'master' into feature/dhcp-eth0

This commit is contained in:
Bill Zimmerman 2020-12-15 23:01:23 +01:00 committed by GitHub
commit f43083fec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 127 additions and 96 deletions

View File

@ -137,6 +137,8 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
$status->addMessage('Attempting to set channel outside of permitted range', 'danger');
$good_input = false;
}
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
// Check for Bridged AP mode checkbox
$bridgedEnable = 0;
if ($arrHostapdConf['BridgedEnable'] == 0) {

View File

@ -146,6 +146,14 @@ function getWifiInterface()
$iface = $_SESSION['ap_interface'] = isset($arrHostapdConf['WifiInterface']) ? $arrHostapdConf['WifiInterface'] : RASPI_WIFI_AP_INTERFACE;
// check for 2nd wifi interface -> wifi client on different interface
exec("iw dev | awk '$1==\"Interface\" && $2!=\"$iface\" {print $2}'",$iface2);
$_SESSION['wifi_client_interface'] = empty($iface2) ? $iface : trim($iface2[0]);
$client_iface = $_SESSION['wifi_client_interface'] = (empty($iface2) ? $iface : trim($iface2[0]));
// specifically for rpi0W in AP-STA mode, the above check ends up with the interfaces
// crossed over (wifi_client_interface vs 'ap_interface'), because the second interface (uap0) is
// created by raspap and used as the access point.
if ($client_iface == "uap0" && ($arrHostapdConf['WifiAPEnable'] ?? 0)){
$_SESSION['wifi_client_interface'] = $iface;
$_SESSION['ap_interface'] = $client_iface;
}
}

View File

@ -4,11 +4,12 @@
# Author: @billz <billzimmerman@gmail.com>
# License: GNU General Public License v3.0
#
# Usage:
# Installs an instance of RaspAP.
#
# Available options:
# -y, --yes, --assume-yes
# Assume "yes" as answer to all prompts and run non-interactively
# c, --cert, --certficate
# -c, --cert, --certficate
# Installs mkcert and generates an SSL certificate for lighttpd
# -o, --openvpn <flag>
# Used with -y, --yes, sets OpenVPN install option (0=no install)
@ -35,93 +36,118 @@
# You are not obligated to bundle the LICENSE file with your RaspAP projects as long
# as you leave these references intact in the header comments of your source files.
# Set defaults
repo="billz/raspap-webgui"
assume_yes=0
upgrade=0
ovpn_option=1
adblock_option=1
# Define colors
readonly ANSI_RED="\033[0;31m"
readonly ANSI_GREEN="\033[0;32m"
readonly ANSI_YELLOW="\033[0;33m"
readonly ANSI_RASPBERRY="\033[0;35m"
readonly ANSI_ERROR="\033[1;37;41m"
readonly ANSI_RESET="\033[m"
# Log output
readonly LOGFILE_PATH="/tmp"
exec > >(tee -i $LOGFILE_PATH/raspap_install.log)
exec 2>&1
# Fetch latest release from GitHub API
repo="billz/raspap-webgui" #override with -r, --repo option
readonly RASPAP_LATEST=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' )
branch="$RASPAP_LATEST" #override with the -b, --branch option
branch="$RASPAP_LATEST" #override with -b, --branch option
function _setup_colors() {
ANSI_RED="\033[0;31m"
ANSI_GREEN="\033[0;32m"
ANSI_YELLOW="\033[0;33m"
ANSI_RASPBERRY="\033[0;35m"
ANSI_ERROR="\033[1;37;41m"
ANSI_RESET="\033[m"
}
function _log_output() {
readonly LOGFILE_PATH="/tmp"
exec > >(tee -i $LOGFILE_PATH/raspap_install.log)
exec 2>&1
}
function _usage() {
cat << EOF
Usage: $(basename "$0") [OPTION]
Installs an instance of RaspAP.
Available options:
-y, --yes, --assume-yes
Assumes "yes" as an answer to all prompts
-c, --cert, --certificate
Installs an SSL certificate for lighttpd
-o, --openvpn <flag>
Used with -y, --yes, sets OpenVPN install option (0=no install)
-a, --adblock <flag>
Used with -y, --yes, sets Adblock install option (0=no install)
-r, --repo, --repository <name>
Overrides the default GitHub repo (billz/raspap-webgui)
-b, --branch <name>
Overrides the default git branch (latest release)
-h, --help
Outputs usage notes and exits
-u, --upgrade
Upgrades an existing installation to the latest release version
-v, --version
Outputs release info and exits
# Define usage notes
usage=$(cat << EOF
Usage: raspbian.sh [OPTION]\n
-y, --yes, --assume-yes\n\tAssumes "yes" as an answer to all prompts
-c, --cert, --certificate\n\tInstalls an SSL certificate for lighttpd
-o, --openvpn <flag>\n\tUsed with -y, --yes, sets OpenVPN install option (0=no install)
-a, --adblock <flag>\n\tUsed with -y, --yes, sets Adblock install option (0=no install)
-r, --repo, --repository <name>\n\tOverrides the default GitHub repo (billz/raspap-webgui)
-b, --branch <name>\n\tOverrides the default git branch (latest release)
-h, --help\n\tOutputs usage notes and exits
-u, --upgrade\n\tUpgrades an existing installation to the latest release version
-v, --version\n\tOutputs release info and exits\n
EOF
)
exit
}
# Parse command-line options
while :; do
case $1 in
-y|--yes|--assume-yes)
assume_yes=1
apt_option="-y"
;;
-o|--openvpn)
ovpn_option="$2"
function _parse_params() {
# default flag values
assume_yes=0
upgrade=0
ovpn_option=1
adblock_option=1
while :; do
case ${1} in
-y|--yes|--assume-yes)
assume_yes=1
apt_option="-y"
;;
-o|--openvpn)
ovpn_option="$2"
shift
;;
-a|--adblock)
adblock_option="$2"
shift
;;
-c|--cert|--certificate)
install_cert=1
;;
-r|--repo|--repository)
repo="$2"
shift
;;
-b|--branch)
branch="$2"
shift
;;
-h|--help)
_usage
;;
-u|--upgrade)
upgrade=1
;;
-v|--version)
_version
;;
-*|--*)
echo "Unknown option: $1"
_usage
exit 1
;;
*)
break
;;
esac
shift
;;
-a|--adblock)
adblock_option="$2"
shift
;;
-c|--cert|--certificate)
install_cert=1
;;
-r|--repo|--repository)
repo="$2"
shift
;;
-b|--branch)
branch="$2"
shift
;;
-h|--help)
printf "$usage"
exit 1
;;
-u|--upgrade)
upgrade=1
;;
-v|--version)
printf "RaspAP v${RASPAP_LATEST} - Simple AP setup & WiFi management for Debian-based devices\n"
exit 1
;;
-*|--*)
echo "Unknown option: $1"
printf "$usage"
exit 1
;;
*)
break
;;
esac
shift
done
done
}
function _version() {
echo -e "RaspAP v${RASPAP_LATEST} - Simple AP setup & WiFi management for Debian-based devices"
exit
}
_parse_params "$@"
_setup_colors
_log_output
UPDATE_URL="https://raw.githubusercontent.com/$repo/$branch/"
@ -167,7 +193,7 @@ function _install_status() {
function _update_system_packages() {
_install_log "Updating sources"
sudo apt-get update || _install_error "Unable to update package list"
sudo apt-get update || _install_status 1 "Unable to update package list"
}
# Fetch required installer functions

View File

@ -1,10 +1,7 @@
<?php
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
if ($arrHostapdConf['WifiAPEnable'] == 1) {
$client_interface = 'uap0';
} else {
$client_interface = $_SESSION['wifi_client_interface'];
}
$client_interface = $_SESSION['wifi_client_interface'];
exec('ip a show '.$client_interface, $stdoutIp);
$stdoutIpAllLinesGlued = implode(" ", $stdoutIp);
$stdoutIpWRepeatedSpaces = preg_replace('/\s\s+/', ' ', $stdoutIpAllLinesGlued);

View File

@ -1,10 +1,8 @@
<?php
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
if ($arrHostapdConf['WifiAPEnable'] == 1) {
$client_interface = 'uap0';
} else {
$client_interface = $_SESSION['wifi_client_interface'];
}
$client_interface = $_SESSION['wifi_client_interface'];
$ap_iface = $_SESSION['ap_interface'];
$MACPattern = '"([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}"';
if ($arrHostapdConf['BridgedEnable'] == 1) {