Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions config/hostapd-mt7921u-ax.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# RaspAP hostapd configuration for Mediatek MT7921 802.11ax / Wi-Fi 6
# Optimized for mt7921u driver
# This configuration is automatically applied when mt7921u adapter is detected

# Driver and control interface
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0

# Network interface
interface=wlan1

# SSID and authentication
ssid=RaspAP
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_passphrase=ChangeMe

# Country and regulatory
country_code=US
ieee80211d=1
ieee80211h=0

# Channel configuration
hw_mode=a
channel=36

# 802.11n HT support
ieee80211n=1
require_ht=1
ht_capab=[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][MAX-AMSDU-7935]

# 802.11ac VHT support
ieee80211ac=1
require_vht=1
vht_capab=[RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-MPDU-11454][MAX-A-MPDU-LEN-EXP7]
vht_oper_chwidth=1
vht_oper_centr_freq_seg0_idx=42

# 802.11ax HE Wi-Fi 6 support
ieee80211ax=1
he_su_beamformer=1
he_su_beamformee=1
he_mu_beamformer=1
he_bss_color=1
he_oper_chwidth=1
he_oper_centr_freq_seg0_idx=42

# QoS and WMM
wmm_enabled=1

# Beacon and timing
beacon_int=100

65 changes: 65 additions & 0 deletions installers/apply_profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
#
# Author: @billz <billzimmerman@gmail.com>
# Author URI: https://github.com/billz
# Project URI: https://github.com/RaspAP/
# License: GNU General Public License v3.0
# License URI: https://github.com/RaspAP/raspap-webgui/blob/master/LICENSE
#
# Applies adapter-specific hostapd config, preserving user settings
#
# Usage: apply_profile.sh <interface> <profile_path>

INTERFACE="$1"
PROFILE_PATH="$2"
HOSTAPD_CONF="/etc/hostapd/hostapd.conf"
BACKUP_CONF="/etc/hostapd/hostapd.conf.backup"

# Validate parameters
if [ -z "$INTERFACE" ] || [ -z "$PROFILE_PATH" ]; then
echo "ERROR: Missing required parameters" >&2
echo "Usage: $0 <interface> <profile_path>" >&2
exit 1
fi

# Check if profile exists
if [ ! -f "$PROFILE_PATH" ]; then
echo "ERROR: Profile not found: $PROFILE_PATH" >&2
exit 1
fi

# Preserve existing SSID and passphrase if hostapd.conf exists
SSID=""
PASSPHRASE=""

if [ -f "$HOSTAPD_CONF" ]; then
SSID=$(grep -oP '^ssid=\K.*' "$HOSTAPD_CONF" | head -1)
PASSPHRASE=$(grep -oP '^wpa_passphrase=\K.*' "$HOSTAPD_CONF" | head -1)

cp "$HOSTAPD_CONF" "$BACKUP_CONF"
echo "Backed up existing configuration to $BACKUP_CONF"
fi

# Copy profile template
cp "$PROFILE_PATH" "$HOSTAPD_CONF"
echo "Applied profile: $PROFILE_PATH"

# Update interface in config
sed -i "s/^interface=.*/interface=$INTERFACE/" "$HOSTAPD_CONF"
echo "Updated interface to: $INTERFACE"

# Restore user's SSID if it exists and isn't default
if [ -n "$SSID" ] && [ "$SSID" != "RaspAP" ]; then
sed -i "s/^ssid=.*/ssid=$SSID/" "$HOSTAPD_CONF"
echo "Preserved existing SSID: $SSID"
fi

# Restore user's passphrase if it exists and isn't default
if [ -n "$PASSPHRASE" ] && [ "$PASSPHRASE" != "ChangeMe" ]; then
sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$PASSPHRASE/" "$HOSTAPD_CONF"
echo "Preserved existing passphrase"
fi

echo "Successfully applied adapter profile configuration"
exit 0

Empty file modified installers/common.sh
100644 → 100755
Empty file.
62 changes: 62 additions & 0 deletions installers/detect_adapter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
#
# RaspAP wireless adapter hardware detection
# Author: @billz <billzimmerman@gmail.com>
# Author URI: https://github.com/billz/
# License: GNU General Public License v3.0
# License URI: https://github.com/raspap/raspap-webgui/blob/master/LICENSE
#
# Usage: detect_adapter.sh <interface>
# Exit codes: 0=detected, 1=not found, 2=error
#
# Example output:
# INTERFACE=wlan1
# DRIVER=mt7921u
# VENDOR_ID=0e8d
# ADAPTER_PROFILE=hostapd-mt7921u-ax.conf
# DETECTED=true

INTERFACE="${1:-wlan0}"

# Check if interface exists
if [ ! -d "/sys/class/net/$INTERFACE" ]; then
echo "ERROR: Interface $INTERFACE does not exist" >&2
exit 2
fi

# Check if interface is wireless
if [ ! -d "/sys/class/net/$INTERFACE/wireless" ]; then
echo "ERROR: $INTERFACE is not a wireless interface" >&2
exit 2
fi

# Fetch udev properties
UDEV_INFO=$(udevadm info "/sys/class/net/$INTERFACE" 2>/dev/null)
if [ $? -ne 0 ]; then
echo "ERROR: Failed to get udev info for $INTERFACE" >&2
exit 2
fi

DRIVER=$(echo "$UDEV_INFO" | grep -oP 'E: ID_NET_DRIVER=\K.*' | head -1)
VENDOR_ID=$(echo "$UDEV_INFO" | grep -oP 'E: ID_VENDOR_ID=\K.*' | head -1)
MODEL_ID=$(echo "$UDEV_INFO" | grep -oP 'E: ID_MODEL_ID=\K.*' | head -1)
VENDOR_NAME=$(echo "$UDEV_INFO" | grep -oP 'E: ID_VENDOR_FROM_DATABASE=\K.*' | head -1)

# Output results as key-value pairs
echo "INTERFACE=$INTERFACE"
echo "DRIVER=${DRIVER:-unknown}"
echo "VENDOR_ID=${VENDOR_ID:-unknown}"
echo "MODEL_ID=${MODEL_ID:-unknown}"
echo "VENDOR_NAME=${VENDOR_NAME:-unknown}"

# Detect mt7921u driver, assign profile
if [ "$DRIVER" = "mt7921u" ]; then
echo "ADAPTER_PROFILE=hostapd-mt7921u-ax.conf"
echo "DETECTED=true"
exit 0
fi

# No profile detected
echo "DETECTED=false"
exit 1

Empty file modified installers/install_feature_clients.sh
100644 → 100755
Empty file.
Empty file modified installers/install_feature_firewall.sh
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion installers/raspapd.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
[Unit]
Description=RaspAP Service Daemon
DefaultDependencies=no
After=multi-user.target
After=multi-user.target network.target systemd-udev-settle.service
Wants=network.target systemd-udev-settle.service

[Service]
Type=oneshot
Expand Down
60 changes: 59 additions & 1 deletion installers/servicestart.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#!/bin/bash
#
# RaspAP service start script
#
# Author: @billz <billzimmerman@gmail.com>
# Author URI: https://github.com/billz/
# License: GNU General Public License v3.0
# License URI: https://github.com/raspap/raspap-webgui/blob/master/LICENSE
#
# When wireless client AP or Bridge mode is enabled, this script handles starting
# up network services in a specific order and timing to avoid race conditions.
# Detects wireless adapter hardware and applies adapter-specific configuration.

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
WEBROOT_DIR="/var/www/html"
NAME=raspapd
DESC="Service control for RaspAP"
CONFIGFILE="/etc/raspap/hostapd.ini"
Expand Down Expand Up @@ -42,7 +52,55 @@ if [ -r "$CONFIGFILE" ]; then
done < "$CONFIGFILE"
fi

# Set interface from config if not set by parameter
# Detect mt7921u adapter on any wireless interface
MT7921U_DETECTED=0
if [ -z "$interface" ] && [ -x "$WEBROOT_DIR/installers/detect_adapter.sh" ]; then
echo "Scanning for mt7921u compatible adapter..."

# Find all wireless interfaces
for iface in /sys/class/net/*/wireless; do
if [ -d "$iface" ]; then
iface_name=$(basename $(dirname "$iface"))

ADAPTER_INFO=$($WEBROOT_DIR/installers/detect_adapter.sh "$iface_name" 2>/dev/null)
DETECT_STATUS=$?

if [ $DETECT_STATUS -eq 0 ]; then
eval "$ADAPTER_INFO"

if [ "$DRIVER" = "mt7921u" ]; then
echo "Found mt7921u adapter on interface: $iface_name"
interface="$iface_name"
MT7921U_DETECTED=1

if [ -n "$ADAPTER_PROFILE" ]; then
PROFILE_PATH="$WEBROOT_DIR/config/$ADAPTER_PROFILE"

if [ -f "$PROFILE_PATH" ]; then
echo "Detected hardware profile: $ADAPTER_PROFILE"
echo "Applying adapter-specific configuration for $interface..."

# Apply profile configuration
if [ -x "$WEBROOT_DIR/installers/apply_profile.sh" ]; then
$WEBROOT_DIR/installers/apply_profile.sh "$interface" "$PROFILE_PATH"
fi
fi
fi

if [ -w "$CONFIGFILE" ]; then
sed -i '/^WifiInterface *= */d' "$CONFIGFILE"
echo "WifiInterface = $iface_name" >> "$CONFIGFILE"
echo "Updated $CONFIGFILE with WifiInterface = $iface_name"
fi

break
fi
fi
fi
done
fi

# Set interface from config if not set by parameter or auto-detection
if [ -z "$interface" ]; then
if [ -n "${config[WifiInterface]}" ]; then
interface="${config[WifiInterface]}"
Expand Down
Empty file modified installers/update_firewall.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion templates/dhcp/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="mb-3 col-md-8 mt-2">
<?php
if (($conf['log-dhcp'] ?? 0) == 1 || ($conf['log-queries'] ?? 0) == 1) {
echo '<textarea class="logoutput text-secondary" id="dnsmasq-log">'.htmlspecialchars($logdata, ENT_QUOTES).'</textarea>';
echo '<textarea class="logoutput text-secondary" id="dnsmasq-log" readonly>'.htmlspecialchars($logdata, ENT_QUOTES).'</textarea>';
} else {
echo '<textarea class="logoutput my-3"></textarea>';
}
Expand Down
2 changes: 1 addition & 1 deletion templates/hostapd/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="mb-3 col-md-8 mt-2">
<?php
if ($arrHostapdConf['LogEnable'] == 1) {
echo '<textarea class="logoutput text-secondary" id="hostapd-log">'.htmlspecialchars(implode("\n", $logOutput), ENT_QUOTES).'</textarea>';
echo '<textarea class="logoutput text-secondary" id="hostapd-log" readonly>'.htmlspecialchars(implode("\n", $logOutput), ENT_QUOTES).'</textarea>';
} else {
echo '<textarea class="logoutput my-3"></textarea>';
}
Expand Down
Loading