Skip to content

Commit

Permalink
v8.14
Browse files Browse the repository at this point in the history
- WiFi | From Debian Bookworm on, the crda package is not available anymore. Since Linux 4.15 it is also obsolete, as the kernel is able to load this data directly. It requires however the data stored in /lib/firmware, which is the case from Bullseye (or Buster backports) on. For these cases, we do not not pre-install the crda package anymore, and offer to have it removed on next DietPi update. Our tools are adjusted to check for the existence of a key crda file to know whether to apply the country code to its config file and show the related menu option or not. The only other case, where the country code plays a role, is the WiFi hotspot, to provide it via hostapd. If the WiFi hotspot is installed but crda is now, the country code can still be selected, but is installed to the hostapd config only and not to crda or the interface directly (iw reg set).
  • Loading branch information
MichaIng committed Jan 24, 2023
1 parent 2a88ae3 commit 959c5b8
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 84 deletions.
76 changes: 34 additions & 42 deletions .build/images/dietpi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -862,16 +862,6 @@ _EOF_
# All but VMs: Drive power management control
(( $G_HW_MODEL == 20 )) || aPACKAGES_REQUIRED_INSTALL+=('hdparm')

# WiFi related
if (( $WIFI_REQUIRED ))
then
aPACKAGES_REQUIRED_INSTALL+=('iw') # Tools to configure WiFi adapters
aPACKAGES_REQUIRED_INSTALL+=('wireless-tools') # Same as "iw", deprecated but still required for non-nl80211 adapters
# Set WiFi frequencies according to local regulations, based on WiFi country code. CRDA is not available since Bookworm, kernels are supposed to obtain it from wireless-regdb themselves.
(( $DISTRO_TARGET > 6 )) && aPACKAGES_REQUIRED_INSTALL+=('wireless-regdb') || aPACKAGES_REQUIRED_INSTALL+=('crda')
aPACKAGES_REQUIRED_INSTALL+=('wpasupplicant') # Support for WPA-protected WiFi network connection
fi

# x86_64: Kernel/bootloader/initramfs
# - We need to install those directly to allow G_AGA() autoremove possible older packages later: https://github.com/MichaIng/DietPi/issues/1285#issuecomment-354602594
if (( $G_HW_ARCH == 10 ))
Expand Down Expand Up @@ -917,7 +907,7 @@ _EOF_
# Assure that dir for additional sources is present
[[ -d '/etc/apt/sources.list.d' ]] || G_EXEC mkdir /etc/apt/sources.list.d

# - DietPi-Build with Armbian kernel/bootloader/firmware
# DietPi-Build with Armbian kernel/bootloader/firmware
if [[ ( $G_HW_MODEL =~ ^(12|15|16|40|42|43|44|45|46|47|48|52|54|55|56|57|58|59|60|62|63|64|65|66|67|68|72|73|74|77|78)$ && -f '/boot/dietpiEnv.txt' ) || ( $G_HW_MODEL == 11 && $(findmnt -Ufnro TARGET -T /boot) == '/' ) || ( $G_HW_MODEL == 10 && $(findmnt -t vfat -M /boot) ) ]]
then
# Bootstrap Armbian repository
Expand Down Expand Up @@ -1039,7 +1029,7 @@ _EOF_
G_EXEC rm u-boot-nanopir1.bin
fi

# - Armbian grab currently installed packages
# Armbian grab currently installed packages
elif [[ $G_HW_MODEL != 75 && $(dpkg-query -Wf '${Package} ') == *'armbian'* ]]; then

systemctl stop armbian-*
Expand Down Expand Up @@ -1104,7 +1094,7 @@ _EOF_
G_EXEC rm /etc/apt/sources.list.d/*
G_EXEC eval "echo 'deb https://apt.armbian.com/ ${DISTRO_TARGET_NAME/bookworm/bullseye} main' > /etc/apt/sources.list.d/armbian.list"

# - RPi
# RPi
elif (( $G_HW_MODEL < 10 )); then

# ARMv6/7: Add raspi-copies-and-fills
Expand All @@ -1124,7 +1114,7 @@ _EOF_
[[ -f '/etc/apt/trusted.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg
[[ -f '/etc/apt/trusted.gpg~' ]] && G_EXEC rm '/etc/apt/trusted.gpg~'

# - ROCK Pi S/Radxa Zero: Official legacy Radxa Debian image
# ROCK Pi S/Radxa Zero: Official legacy Radxa Debian image
elif [[ $G_HW_MODEL =~ ^(73|74)$ ]] && grep -q 'apt\.radxa\.com' /etc/apt/sources.list.d/*.list; then

# Install Radxa APT repo cleanly: No Bookworm repo available yet
Expand All @@ -1145,7 +1135,7 @@ _EOF_
# And install "file" which is used to detect whether the kernel image is compressed and in case uncompress it
(( $G_HW_MODEL == 74 )) && G_AGI initramfs-tools linux-5.10-radxa-zero-latest bc file

# - Quartz64
# Quartz64
elif [[ $G_HW_MODEL == 49 && $(findmnt -Ufnro TARGET -T /boot) == '/' ]]
then
case $HW_VARIANT in
Expand All @@ -1157,28 +1147,28 @@ _EOF_
G_EXEC_OUTPUT=1 G_EXEC dpkg -i "firmware-$variant.deb"
G_EXEC rm "firmware-$variant.deb"

# - NanoPi R5S
# NanoPi R5S
elif (( $G_HW_MODEL == 76 )) && { [[ ! $(find /lib/modules -mindepth 1 -maxdepth 1 -type d) ]] || dpkg-query -s 'firmware-nanopi5' &> /dev/null; }
then
G_EXEC curl -sSfO 'https://dietpi.com/downloads/binaries/firmware-nanopi5.deb'
G_EXEC_OUTPUT=1 G_EXEC dpkg -i firmware-nanopi5.deb
G_EXEC rm firmware-nanopi5.deb

# - NanoPi R6S
# NanoPi R6S
elif (( $G_HW_MODEL == 79 )) && { [[ ! $(find /lib/modules -mindepth 1 -maxdepth 1 -type d) ]] || dpkg-query -s 'firmware-nanopi6' &> /dev/null; }
then
G_EXEC curl -sSfO 'https://dietpi.com/downloads/binaries/firmware-nanopi6.deb'
G_EXEC_OUTPUT=1 G_EXEC dpkg -i firmware-nanopi6.deb
G_EXEC rm firmware-nanopi6.deb

# - NanoPi M2/T2/Fire2 Linux 4.4: Requires dedicated boot partition, starting at 4 MiB for U-Boot, with ext4 filesystem
# NanoPi M2/T2/Fire2 Linux 4.4: Requires dedicated boot partition, starting at 4 MiB for U-Boot, with ext4 filesystem
elif [[ $G_HW_MODEL == 61 && $(findmnt -Ufnro FSTYPE -M /boot) == 'ext4' ]] && (( $(sfdisk -qlo Start "$BOOT_DEVICE" | mawk 'NR==2') >= 8192 ))
then
G_EXEC curl -sSfO 'https://dietpi.com/downloads/binaries/firmware-nanopi2.deb'
G_EXEC_OUTPUT=1 G_EXEC dpkg -i firmware-nanopi2.deb
G_EXEC rm firmware-nanopi2.deb

# - Generic kernel + device tree + U-Boot package auto detect + initramfs-tools
# Generic kernel + device tree + U-Boot package auto detect + initramfs-tools
elif (( $G_HW_MODEL != 75 ))
then
mapfile -t apackages < <(dpkg-query -Wf '${Package}\n' | grep -E '^linux-(image|dtb|u-boot)-|^u-boot')
Expand All @@ -1188,33 +1178,36 @@ _EOF_
fi
G_EXEC apt-get clean # Remove downloaded archives

# - Firmware
if (( $G_HW_MODEL != 75 )) && dpkg-query -s 'armbian-firmware' &> /dev/null
then
aPACKAGES_REQUIRED_INSTALL+=('armbian-firmware')

# - Radxa Zero: Do not install additional firmware on official Debian image for now, as it overwrites required non-packaged firmware files
elif [[ $G_HW_MODEL != 7[45] ]]
# WiFi and firmware packages: Usually no firmware should be necessary for VMs. If user manually passes though some USB device, user might need to install the firmware then.
if (( $G_HW_MODEL != 20 && $G_HW_MODEL != 75 ))
then
# Usually no firmware should be necessary for VMs. If user manually passes though some USB device, user might need to install the firmware then.
if (( $G_HW_MODEL != 20 ))
then
aPACKAGES_REQUIRED_INSTALL+=('firmware-realtek') # Realtek Eth+WiFi/BT firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-linux-free') # Misc free firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-misc-nonfree') # Misc non-free firmware incl. Ralink and MediaTek WiFi/BT
fi

if (( $WIFI_REQUIRED ))
then
aPACKAGES_REQUIRED_INSTALL+=('firmware-atheros') # Qualcomm/Atheros WiFi/BT firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-brcm80211') # Broadcom WiFi/BT firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-iwlwifi') # Intel WiFi/BT firmware
if (( $G_HW_MODEL == 20 ))
aPACKAGES_REQUIRED_INSTALL+=('iw') # Tools to configure WiFi adapters
aPACKAGES_REQUIRED_INSTALL+=('wireless-tools') # Same as "iw", deprecated but still required for non-nl80211 adapters
aPACKAGES_REQUIRED_INSTALL+=('wpasupplicant') # Support for WPA-protected WiFi network connections
# Set WiFi frequencies according to local regulations, based on WiFi country code.
# - CRDA is not available from Debian Bookworm on and irrelevant from Linux 4.15 on, kernels are supposed to obtain it from wireless-regdb themselves: https://bugs.debian.org/1003903
if (( $DISTRO_TARGET < 7 )) && dpkg --compare-versions "$(find /lib/modules -mindepth 1 -maxdepth 1 -type d -name '[0-9]*' -printf '%f\n' | sort -Vr | head -1)" lt-nl 4.15
then
aPACKAGES_REQUIRED_INSTALL+=('firmware-realtek') # Realtek Eth+WiFi/BT firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-misc-nonfree') # Misc non-free firmware incl. Ralink and MediaTek WiFi/BT
aPACKAGES_REQUIRED_INSTALL+=('crda')
else
aPACKAGES_REQUIRED_INSTALL+=('wireless-regdb')
fi
fi

# Firmware: Armbian or Debian
if dpkg-query -s 'armbian-firmware' &> /dev/null
then
aPACKAGES_REQUIRED_INSTALL+=('armbian-firmware')
else
aPACKAGES_REQUIRED_INSTALL+=('firmware-realtek') # Realtek Eth+WiFi/BT firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-linux-free') # Misc free firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-misc-nonfree') # Misc non-free firmware incl. Ralink and MediaTek WiFi/BT
aPACKAGES_REQUIRED_INSTALL+=('firmware-atheros') # Qualcomm/Atheros WiFi/BT firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-brcm80211') # Broadcom WiFi/BT firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-iwlwifi') # Intel WiFi/BT firmware
fi
fi

G_DIETPI-NOTIFY 2 'Generating list of minimal packages, required for DietPi installation'
Expand Down Expand Up @@ -2008,8 +2001,7 @@ _EOF_
fi

# Apply cgroups-v2 workaround if the kernel does not support it: https://github.com/MichaIng/DietPi/issues/4705
# - This is required on Bullseye only, but we'll apply it on Buster as well to cover later distro upgrades, since the logic is too complicated for our upgrade blog article.
if [[ $G_HW_MODEL != 75 && ! $(find /lib/modules -mindepth 1 -maxdepth 1 -type d -name '[5-9].[0-9]*') ]]
if (( $G_HW_MODEL != 75 )) && dpkg --compare-versions "$(find /lib/modules -mindepth 1 -maxdepth 1 -type d -name '[0-9]*' -printf '%f\n' | sort -Vr | head -1)" lt-nl 4.15
then
# Odroids
if [[ $G_HW_MODEL -gt 9 && $G_HW_MODEL -le 16 && -f '/boot/boot.ini' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/boot.ini
Expand Down
16 changes: 15 additions & 1 deletion .update/patches
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ Patch_8_2()

# Apply cgroups-v2 workaround if the kernel does not support it: https://github.com/MichaIng/DietPi/issues/4705
# - This is required on Bullseye only, but we'll apply it on Buster as well to cover later distro upgrades, since the logic is too complicated for our upgrade blog article.
if (( $(uname -r | mawk -F'.' '{print $1}') < 4 || ( $(uname -r | mawk -F'.' '{print $1}') == 4 && $(uname -r | mawk -F'.' '{print $2}') < 15 ) ))
if dpkg --compare-versions "$(uname -r)" lt-nl 4.15
then
# Odroids
if [[ $G_HW_MODEL -gt 9 && $G_HW_MODEL -le 16 && -f '/boot/boot.ini' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/boot.ini
Expand Down Expand Up @@ -1061,6 +1061,20 @@ Patch_8_14()
\nYou can do this manually any time later:
# rm /var/www/apc.php /var/www/opcache.php /var/www/phpinfo.php' && G_EXEC rm -f /var/www/{apc,opcache,phpinfo}.php
fi

if (( $G_DISTRO > 5 )) && dpkg --compare-versions "$(uname -r)" ge 4.15 && dpkg-query -s crda &> /dev/null
then
if G_WHIP_BUTTON_CANCEL_TEXT='Keep' G_WHIP_BUTTON_OK_TEXT='Remove' G_WHIP_YESNO 'Removing obsolete CRDA package
\nFrom Debian Bullseye on since Linux v4.15, the CRDA package for informing the kernel about WiFi country code changes, is obsolete. The kernel is now able to load this data directly.
More info: https://bugs.debian.org/1003903
\nShall we remove this package now?
\nYou can do this manually any time later:
# apt autopurge crda'
then
G_EXEC apt-mark manual wireless-regdb
G_AGP crda
fi
fi
}

# v6.35 => v7 migration
Expand Down
1 change: 1 addition & 0 deletions dietpi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ AUTO_SETUP_NET_WIFI_ENABLED=0
AUTO_SETUP_NET_ETH_FORCE_SPEED=0

# WiFi country code: 2 uppercase character value (e.g. GB US DE JP): https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
# - On Debian Bookworm and from Linux 4.15 on, this setting is relevant for the WiFi Hotspot (hostapd) installation only.
AUTO_SETUP_NET_WIFI_COUNTRY_CODE=GB

# Enter your static network details below, if applicable.
Expand Down
77 changes: 42 additions & 35 deletions dietpi/dietpi-config
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
_EOF_
fi

# Remove wireless-power setting, if not supported by adapter/firmware
# Remove wireless-power setting if not supported by adapter/firmware
iwconfig "$WIFI_DEV_IFACE" power off 2> /dev/null || sed -i '/^wireless-power/d' /etc/network/interfaces

# Update WiFi db/wpa_supplicant
Expand Down Expand Up @@ -2272,15 +2272,24 @@ _EOF_
fi
local wifi_country_code_target=$G_WHIP_RETURNED_VALUE

/boot/dietpi/func/dietpi-set_hardware wificountrycode "$wifi_country_code_target"
# CRDA is not available from Debian Bookworm on and irrelevant from Linux 4.15 on: https://bugs.debian.org/1003903
if [[ -f '/lib/crda/crda' ]]
then
/boot/dietpi/func/dietpi-set_hardware wificountrycode "$wifi_country_code_target"

Network_Restart
Network_Restart

# Check if country code was successfully applied
WIFI_COUNTRYCODE=$(iw reg get | mawk '/country/{print $2;exit}'); WIFI_COUNTRYCODE=${WIFI_COUNTRYCODE%:}
[[ $WIFI_COUNTRYCODE == "$wifi_country_code_target" ]] && return 0
G_WHIP_MSG "[FAILED] Country code \"$wifi_country_code_target\" could not been applied.\n\nPlease check the country code and try again.\n\nIf problems persist, this may be a limitation with the driver/chipset."
return 1
# Check if country code was successfully applied
WIFI_COUNTRYCODE=$(iw reg get | mawk '/country/{print $2;exit}'); WIFI_COUNTRYCODE=${WIFI_COUNTRYCODE%:}
[[ $WIFI_COUNTRYCODE == "$wifi_country_code_target" ]] && return 0
G_WHIP_MSG "[FAILED] Country code \"$wifi_country_code_target\" could not be applied.\n\nPlease check the country code and try again.\n\nIf problems persist, this may be a limitation with the driver/chipset."
return 1
else
# Apply for WiFi Hotspot only if CRDA is not available
WIFI_COUNTRYCODE=$wifi_country_code_target
G_CONFIG_INJECT 'country_code=' "country_code=$WIFI_COUNTRYCODE" /etc/hostapd/hostapd.conf
G_CONFIG_INJECT 'AUTO_SETUP_NET_WIFI_COUNTRY_CODE=' "AUTO_SETUP_NET_WIFI_COUNTRY_CODE=$WIFI_COUNTRYCODE" /boot/dietpi.txt
fi

}

Expand Down Expand Up @@ -2348,7 +2357,14 @@ NB: All Ethernet connections will be temporarily dropped!' && Network_ApplyChang
WIFI_SIGNALSTRENGTH=0
command -v hostapd &> /dev/null && WIFI_HOTSPOT=1 || WIFI_HOTSPOT=0
WIFI_COUNTRYCODE='Unknown'
command -v iw &> /dev/null && WIFI_COUNTRYCODE=$(iw reg get | mawk '/country/{print $2;exit}' | tr -d ':')
if command -v iw &> /dev/null && [[ -f '/lib/crda/crda' ]]
then
WIFI_COUNTRYCODE=$(iw reg get | mawk '/country/{print $2;exit}' | tr -d ':')

elif (( $WIFI_HOTSPOT ))
then
WIFI_COUNTRYCODE=$(sed -n '/^[[:blank:]]*country_code=/{s/^[^=]*=//p;q}' /etc/hostapd/hostapd.conf)
fi

# Convert CIDR integer to net mask, e.g. "192.168.0.100/24" (take "24") to "255.255.255.0"
cidr2mask()
Expand Down Expand Up @@ -2839,8 +2855,8 @@ NB: Auto-negotiation is highly recommended as long as you do not have issues wit
fi

G_WHIP_MENU_ARRAY+=('' '●─ Additional Options ')
# Country code: Not available from Debian Bookworm on: https://bugs.debian.org/1003903
if (( $G_DISTRO < 7 ))
# Country code: Not available from Debian Bookworm on and irrelevant from Linux 4.15 on, aside of for hostapd: https://bugs.debian.org/1003903
if (( $WIFI_HOTSPOT )) || [[ -f '/lib/crda/crda' ]]
then
if [[ $WIFI_COUNTRYCODE == '00' ]]
then
Expand All @@ -2851,14 +2867,11 @@ NB: Auto-negotiation is highly recommended as long as you do not have issues wit
fi

G_WHIP_MENU_ARRAY+=('' '●─ Toggle State ')
if (( $WIFI_HOTSPOT )); then

if (( $WIFI_HOTSPOT ))
then
G_WHIP_MENU_ARRAY+=('State' ": $hotspot_active_state_text")

else

G_WHIP_MENU_ARRAY+=('Disable' ': Disable WiFi adapter')

fi

G_WHIP_MENU_ARRAY+=('' '●─ Apply ')
Expand Down Expand Up @@ -2940,25 +2953,22 @@ NB: Auto-negotiation is highly recommended as long as you do not have issues wit

'Apply')

if (( $WIFI_HOTSPOT == 1 )); then

# - update dietpi.txt
sed -i "/SOFTWARE_WIFI_HOTSPOT_SSID=/c\SOFTWARE_WIFI_HOTSPOT_SSID=$HOTSPOT_SSID" /boot/dietpi.txt
sed -i "/SOFTWARE_WIFI_HOTSPOT_CHANNEL=/c\SOFTWARE_WIFI_HOTSPOT_CHANNEL=$HOTSPOT_CHANNEL" /boot/dietpi.txt
sed -i "/SOFTWARE_WIFI_HOTSPOT_KEY=/c\SOFTWARE_WIFI_HOTSPOT_KEY=$HOTSPOT_KEY" /boot/dietpi.txt
if (( $WIFI_HOTSPOT ))
then
# Update dietpi.txt
G_CONFIG_INJECT 'SOFTWARE_WIFI_HOTSPOT_SSID=' "SOFTWARE_WIFI_HOTSPOT_SSID=$HOTSPOT_SSID" /boot/dietpi.txt
G_CONFIG_INJECT 'SOFTWARE_WIFI_HOTSPOT_CHANNEL=' "SOFTWARE_WIFI_HOTSPOT_CHANNEL=$HOTSPOT_CHANNEL" /boot/dietpi.txt
G_CONFIG_INJECT 'SOFTWARE_WIFI_HOTSPOT_KEY=' "SOFTWARE_WIFI_HOTSPOT_KEY=$HOTSPOT_KEY" /boot/dietpi.txt

# - update hostapd conf
sed -i "/ssid=/c\ssid=$HOTSPOT_SSID" /etc/hostapd/hostapd.conf
sed -i "/channel=/c\channel=$HOTSPOT_CHANNEL" /etc/hostapd/hostapd.conf
sed -i "/wpa_passphrase=/c\wpa_passphrase=$HOTSPOT_KEY" /etc/hostapd/hostapd.conf
# Update hostapd.conf
G_CONFIG_INJECT 'ssid=' "ssid=$HOTSPOT_SSID" /etc/hostapd/hostapd.conf
G_CONFIG_INJECT 'channel=' "channel=$HOTSPOT_CHANNEL" /etc/hostapd/hostapd.conf
G_CONFIG_INJECT 'wpa_passphrase=' "wpa_passphrase=$HOTSPOT_KEY" /etc/hostapd/hostapd.conf

# - Apply/Restart network
# Apply/Restart network
Network_ApplyChanges

else

Wifi_Reconnect

fi
;;

Expand All @@ -2974,14 +2984,11 @@ NB: Auto-negotiation is highly recommended as long as you do not have issues wit

'State')

if (( $hotspot_active_state )); then

if (( $hotspot_active_state ))
then
G_EXEC systemctl stop hostapd

else

G_EXEC systemctl start hostapd

fi
;;

Expand Down
8 changes: 5 additions & 3 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -7741,12 +7741,13 @@ _EOF_
/boot/dietpi/func/dietpi-set_hardware wifimodules enable

# Set WiFi Country Code
(( $G_DISTRO > 6 )) || /boot/dietpi/func/dietpi-set_hardware wificountrycode "$(sed -n '/^[[:blank:]]*AUTO_SETUP_NET_WIFI_COUNTRY_CODE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)"
local country_code=$(sed -n '/^[[:blank:]]*AUTO_SETUP_NET_WIFI_COUNTRY_CODE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
[[ -f '/lib/crda/crda' ]] && /boot/dietpi/func/dietpi-set_hardware wificountrycode "${country_code:=00}"

local eth_iface=$(G_GET_NET -t eth iface)
local wifi_iface=$(G_GET_NET -t wlan iface)

# DHCPD Config
# DHCP server config
G_BACKUP_FP /etc/dhcp/dhcpd.conf
cat << '_EOF_' > /etc/dhcp/dhcpd.conf
ddns-update-style none;
Expand Down Expand Up @@ -7794,6 +7795,7 @@ _EOF_
interface=$wifi_iface
driver=nl80211
ssid=$(sed -n '/^[[:blank:]]*SOFTWARE_WIFI_HOTSPOT_SSID=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
country_code=$country_code
hw_mode=g
channel=$(sed -n '/^[[:blank:]]*SOFTWARE_WIFI_HOTSPOT_CHANNEL=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
macaddr_acl=0
Expand All @@ -7811,7 +7813,7 @@ _EOF_
[[ $G_HW_MODEL == [34] ]] && G_CONFIG_INJECT 'ieee80211n=' 'ieee80211n=1' /etc/hostapd/hostapd.conf

# Enable access point config
echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' > /etc/default/hostapd
G_EXEC eval 'echo '\''DAEMON_CONF="/etc/hostapd/hostapd.conf"'\'' > /etc/default/hostapd'

Enable_IP_forwarding wifihotspot

Expand Down
6 changes: 5 additions & 1 deletion dietpi/func/dietpi-set_hardware
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,8 @@ _EOF_

# Use country code from command input: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
INPUT_DEVICE_VALUE=${INPUT_DEVICE_VALUE^^} # Needs to be uppercase while all input is made lowercase (ToDo)
if (( $G_DISTRO > 6 ))
# - Not available from Debian Bookworm on and irrelevant from Linux 4.15 on: https://bugs.debian.org/1003903
if [[ ! -f '/lib/crda/crda' ]]
then
Unsupported_Input_Name

Expand All @@ -1452,6 +1453,9 @@ _EOF_
# Update /etc/default/crda to apply country code via udev rules
G_CONFIG_INJECT 'REGDOMAIN=' "REGDOMAIN=$INPUT_DEVICE_VALUE" /etc/default/crda || EXIT_CODE=1

# Apply to hostapd if installed
[[ ! -f '/etc/hostapd/hostapd.conf' ]] || G_CONFIG_INJECT 'country_code=' "country_code=$INPUT_DEVICE_VALUE" /etc/hostapd/hostapd.conf || EXIT_CODE=1

# Apply country code now
G_EXEC_NOHALT=1 G_EXEC iw reg set "$INPUT_DEVICE_VALUE" || EXIT_CODE=1

Expand Down
Loading

0 comments on commit 959c5b8

Please sign in to comment.