Commit a3b2ba2e authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Various bugfixes, mostly in hostapd area

parent 964d7db1
...@@ -186,6 +186,7 @@ function jobs () ...@@ -186,6 +186,7 @@ function jobs ()
rm -f /etc/network/interfaces.d/armbian.ap.nat rm -f /etc/network/interfaces.d/armbian.ap.nat
rm -f /etc/network/interfaces.d/armbian.ap.bridge rm -f /etc/network/interfaces.d/armbian.ap.bridge
sed -i '/^iptables/ d' /etc/rc.local sed -i '/^iptables/ d' /etc/rc.local
sed '/keyfile\|unmanaged-devices/ d' -i /etc/NetworkManager/NetworkManager.conf
iptables -F iptables -F
# reload services # reload services
reload-nety reload-nety
...@@ -197,7 +198,14 @@ function jobs () ...@@ -197,7 +198,14 @@ function jobs ()
else else
# remove interfaces from managed list # remove interfaces from managed list
sed '/keyfile\|unmanaged-devices/ d' -i /etc/NetworkManager/NetworkManager.conf sed '/keyfile\|unmanaged-devices/ d' -i /etc/NetworkManager/NetworkManager.conf
service network-manager restart; sleep 2
# start with basic config
if grep -q "^## IEEE 802.11ac" /etc/hostapd.conf; then sed '/## IEEE 802.11ac\>/,/^## IEEE 802.11ac\>/ s/.*/#&/' -i /etc/hostapd.conf; fi
if grep -q "^## IEEE 802.11a" /etc/hostapd.conf; then sed '/## IEEE 802.11a\>/,/^## IEEE 802.11a\>/ s/.*/#&/' -i /etc/hostapd.conf; fi
if grep -q "^## IEEE 802.11n" /etc/hostapd.conf; then sed '/## IEEE 802.11n/,/^## IEEE 802.11n/ s/.*/#&/' -i /etc/hostapd.conf; fi
sed -i "s/^channel=.*/channel=5/" /etc/hostapd.conf
service network-manager restart; sleep 3
# change special adapters to AP mode # change special adapters to AP mode
wlan_exceptions "on" wlan_exceptions "on"
# check for WLAN interfaces # check for WLAN interfaces
...@@ -205,7 +213,7 @@ function jobs () ...@@ -205,7 +213,7 @@ function jobs ()
# add interface to unmanaged list # add interface to unmanaged list
echo "[keyfile]" >> /etc/NetworkManager/NetworkManager.conf echo "[keyfile]" >> /etc/NetworkManager/NetworkManager.conf
echo "unmanaged-devices=interface-name:$WIRELESS_ADAPTER" >> /etc/NetworkManager/NetworkManager.conf echo "unmanaged-devices=interface-name:$WIRELESS_ADAPTER" >> /etc/NetworkManager/NetworkManager.conf
service network-manager restart; sleep 2 service network-manager restart; sleep 3
# display dialog # display dialog
dialog --colors --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nWireless adapter: \Z1${WIRELESS_ADAPTER}\Z0\n\nProbing nl80211 hostapd driver compatibility." 7 50 dialog --colors --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nWireless adapter: \Z1${WIRELESS_ADAPTER}\Z0\n\nProbing nl80211 hostapd driver compatibility." 7 50
apt-get -o Dpkg::Options::="--force-confnew" -y -qq --no-install-recommends install hostapd > /dev/null apt-get -o Dpkg::Options::="--force-confnew" -y -qq --no-install-recommends install hostapd > /dev/null
...@@ -229,7 +237,6 @@ function jobs () ...@@ -229,7 +237,6 @@ function jobs ()
apt-get -o Dpkg::Options::="--force-confnew" -y -qq --no-install-recommends install hostapd-realtek > /dev/null apt-get -o Dpkg::Options::="--force-confnew" -y -qq --no-install-recommends install hostapd-realtek > /dev/null
# change to selected interface # change to selected interface
sed -i "s/^interface=.*/interface=$WIRELESS_ADAPTER/" /etc/hostapd.conf sed -i "s/^interface=.*/interface=$WIRELESS_ADAPTER/" /etc/hostapd.conf
fi
# add allow cli access if not exists. temporally # add allow cli access if not exists. temporally
if ! grep -q "ctrl_interface" /etc/hostapd.conf; then if ! grep -q "ctrl_interface" /etc/hostapd.conf; then
echo "ctrl_interface=/var/run/hostapd" >> /etc/hostapd.conf echo "ctrl_interface=/var/run/hostapd" >> /etc/hostapd.conf
...@@ -238,6 +245,8 @@ function jobs () ...@@ -238,6 +245,8 @@ function jobs ()
# #
check_advanced_modes check_advanced_modes
# #
fi
CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;service hostapd status|grep fail) CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;service hostapd status|grep fail)
# if both fails there is other problem # if both fails there is other problem
if [[ -n "$CHECK" ]]; then if [[ -n "$CHECK" ]]; then
......
...@@ -57,6 +57,10 @@ CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd st ...@@ -57,6 +57,10 @@ CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd st
sleep 2 sleep 2
sed '/### IEEE 802.11a\>/,/^### IEEE 802.11a\>/ s/^# *//' -i /etc/hostapd.conf sed '/### IEEE 802.11a\>/,/^### IEEE 802.11a\>/ s/^# *//' -i /etc/hostapd.conf
CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail) CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
if [[ -n "$CHECK" ]]; then
check_channels
fi
CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;service hostapd status|grep fail)
if [[ -z "$CHECK" ]]; then if [[ -z "$CHECK" ]]; then
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing wireless 802.11ac \Z1(433Mbps x n @ 5Ghz)\Z0" 5 51 dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing wireless 802.11ac \Z1(433Mbps x n @ 5Ghz)\Z0" 5 51
sleep 2 sleep 2
...@@ -68,6 +72,7 @@ CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd st ...@@ -68,6 +72,7 @@ CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd st
fi fi
else else
dialog --title " Reverting configuration " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nWireless 802.11a \Z1(5Ghz)\Z0 is not supported!" 5 45 dialog --title " Reverting configuration " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nWireless 802.11a \Z1(5Ghz)\Z0 is not supported!" 5 45
sed -i "s/^channel=.*/channel=5/" /etc/hostapd.conf
sed '/## IEEE 802.11a\>/,/^## IEEE 802.11a\>/ s/.*/#&/' -i /etc/hostapd.conf sed '/## IEEE 802.11a\>/,/^## IEEE 802.11a\>/ s/.*/#&/' -i /etc/hostapd.conf
fi fi
else else
...@@ -104,6 +109,7 @@ service hostapd stop; echo 20; sleep 1;\ ...@@ -104,6 +109,7 @@ service hostapd stop; echo 20; sleep 1;\
service dnsmasq stop; echo 30; sleep 1;\ service dnsmasq stop; echo 30; sleep 1;\
[[ "$1" == "reload" ]] && service dnsmasq start && echo 60 && sleep 1 && service hostapd start && echo 80 && sleep 1;\ [[ "$1" == "reload" ]] && service dnsmasq start && echo 60 && sleep 1 && service hostapd start && echo 80 && sleep 1;\
service network-manager start; echo 90; sleep 5;) | dialog --backtitle "$BACKTITLE" --title " $WHATODO " --gauge "" 6 70 0 service network-manager start; echo 90; sleep 5;) | dialog --backtitle "$BACKTITLE" --title " $WHATODO " --gauge "" 6 70 0
systemctl restart systemd-resolved.service
} }
...@@ -156,15 +162,29 @@ dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " $1 " --clear -- ...@@ -156,15 +162,29 @@ dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " $1 " --clear --
function check_ht_capab () function check_ht_capab ()
{ {
declare -a arr=("[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40][SMPS-STATIC]" "[HT40-][SHORT-GI-40][SHORT-GI-40][DSSS_CCK-40]" "[SHORT-GI-20][SHORT-GI-40][HT40+]") declare -a arr=("[HT40+][LDPC][SHORT-GI-20][SHORT-GI-40][TX-STBC][RX-STBC1][DSSS_CCK-40][SMPS-STATIC]" "[HT40-][SHORT-GI-40][SHORT-GI-40][DSSS_CCK-40]" "[SHORT-GI-20][SHORT-GI-40][HT40+]")
local j=0
for i in "${arr[@]}" for i in "${arr[@]}"
do do
echo "$i" j=$((j+1))
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing high throughput capabilities \Z1(${j})\Z0" 5 46
sed -i "s/^ht_capab=.*/ht_capab=$i/" /etc/hostapd.conf sed -i "s/^ht_capab=.*/ht_capab=$i/" /etc/hostapd.conf
CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail) CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
if [[ -z "$CHECK" ]]; then break; fi if [[ -z "$CHECK" ]]; then break; fi
done done
} }
function check_channels ()
{
declare -a arr=("36" "40")
for i in "${arr[@]}"
do
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing channels \Z1(${i})\Z0" 5 26
sed -i "s/^channel=.*/channel=$i/" /etc/hostapd.conf
CHECK=$(systemctl daemon-reload;service hostapd stop; sleep 2;service hostapd start;sleep 2;service hostapd status|grep fail)
if [[ -z "$CHECK" ]]; then break; fi
done
}
#-----------------------------------------------------------------------------------------------------------------------------------------# #-----------------------------------------------------------------------------------------------------------------------------------------#
...@@ -355,12 +375,14 @@ function get_wlan_interface () ...@@ -355,12 +375,14 @@ function get_wlan_interface ()
IFS=$'\r\n' IFS=$'\r\n'
GLOBIGNORE='*' GLOBIGNORE='*'
WLAN_INTERFACES=($(nmcli dev status | grep wifi | grep disconnected |awk '{print $1}')) WLAN_INTERFACES=($(nmcli dev status | grep wifi | grep disconnected |awk '{print $1}'))
local LIST=() local LIST=()
for i in "${WLAN_INTERFACES[@]}" for i in "${WLAN_INTERFACES[@]}"
do do
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
done done
LIST_LENGHT=$((${#LIST[@]}/2)); LIST_LENGHT=$((${#LIST[@]}/2));
if [ "$LIST_LENGHT" -eq 1 ]; then if [ "$LIST_LENGHT" -eq 1 ]; then
WIRELESS_ADAPTER=${WLAN_INTERFACES[0]} WIRELESS_ADAPTER=${WLAN_INTERFACES[0]}
else else
...@@ -545,12 +567,15 @@ while true; do ...@@ -545,12 +567,15 @@ while true; do
if [[ -n $HOSTAPDINFO && -n $HOSTAPDSTATUS ]]; then if [[ -n $HOSTAPDINFO && -n $HOSTAPDSTATUS ]]; then
LISTLENGHT=$((LISTLENGHT+2)) LISTLENGHT=$((LISTLENGHT+2))
chipid=$(dmesg | grep $(grep ^interface /etc/hostapd.conf | sed 's/interface=//g') | head -1 | sed 's/\[.*\]//g' | awk '{print $1}')
disclaimer=$disclaimer$"\n\Z0Hotspot SSID: \Z1$HOSTAPDINFO\Zn Band:"; disclaimer=$disclaimer$"\n\Z0Hotspot SSID: \Z1$HOSTAPDINFO\Zn Band:";
if [[ `grep ^hw_mode=a /etc/hostapd.conf` ]]; then local band="5Ghz"; else band="2.4Ghz"; fi if [[ `grep ^hw_mode=a /etc/hostapd.conf` ]]; then local band="5Ghz"; else band="2.4Ghz"; fi
if [[ `grep ^ieee80211n /etc/hostapd.conf` ]]; then local type="N"; fi if [[ `grep ^ieee80211n /etc/hostapd.conf` ]]; then local type="N"; fi
if [[ `grep ^ieee80211ac /etc/hostapd.conf` ]]; then local type="AC"; fi if [[ `grep ^ieee80211ac /etc/hostapd.conf` ]]; then local type="AC"; fi
disclaimer=$disclaimer$" \Z1${band} ${type}\Z0 " disclaimer=$disclaimer$" \Z1${band} ${type}\Z0"
if [ -n $chipid ]; then disclaimer=$disclaimer$"\n\nChip: \Z1${chipid}\Z0"; fi
if [ "$HOSTAPDCLIENTS" -gt "0" ]; then disclaimer=$disclaimer$" Connected clients: \Z1$HOSTAPDCLIENTS\Zn"; fi if [ "$HOSTAPDCLIENTS" -gt "0" ]; then disclaimer=$disclaimer$" Connected clients: \Z1$HOSTAPDCLIENTS\Zn"; fi
if [ -n $chip ] || [ "$HOSTAPDCLIENTS" -gt "0" ]; then LISTLENGHT=$((LISTLENGHT+2)); fi
disclaimer=$disclaimer$"\n"; disclaimer=$disclaimer$"\n";
fi fi
#disclaimer=$disclaimer"\n" #disclaimer=$disclaimer"\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment