Commit 719a175b authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Adding automatic wireless mode detection, hostname edit, ... bugfixes

parent 04006ef0
......@@ -10,29 +10,40 @@ It comes with Armbian (from 5.27) by default. Login as super user and type:
**Configuration**
- wireless network connect,
- Bluetooth devices pair and connect,
- AP (hotspot) in bridged or NAT mode,
- freeze and unfreeze kernel and BSP upgrades,
- edit boot environment, network, FEX, welcome screen items,
- switching between avaliable kernels and nightly builds,
- enabling read only root filesystem (Ubuntu only),
- set display resolution (H3 boards with legacy kernel),
**Installation**
- [TV headend](https://tvheadend.org/) *(IPTV server)*
- [Syncthing](https://syncthing.net/) *(personal cloud)*
- [SoftEther VPN server](https://www.softether.org/) *(VPN server)*
- [Transmission](https://transmissionbt.com/) *(torrent server)*
- [ISPConfig](https://www.ispconfig.org/) *(WEB & MAIL server)*
- [Openmediavault NAS](http://www.openmediavault.org/) *(NAS server)*
- [PI hole](https://pi-hole.net) *(ad blocker)*
- [MiniDLNA](http://minidlna.sourceforge.net/) *(media sharing)*
[Project realisation example](http://www.igorpecovnik.com/2013/12/10/micro-home-server/)
- software
- softy
- [TV headend](https://tvheadend.org/) *(IPTV server)*
- [Syncthing](https://syncthing.net/) *(personal cloud)*
- [SoftEther VPN server](https://www.softether.org/) *(VPN server)*
- [Transmission](https://transmissionbt.com/) *(torrent server)*
- [ISPConfig](https://www.ispconfig.org/) *(WEB & MAIL server)*
- [Openmediavault NAS](http://www.openmediavault.org/) *(NAS server)*
- [PI hole](https://pi-hole.net) *(ad blocker)*
- [MiniDLNA](http://minidlna.sourceforge.net/) *(media sharing)*
- monitoring tools
- create diagnostics report
- install kernel headers
- networking
- select dynamic or static IP address
- manage hotspot. Automatic detection of: nl80211, realtek, 802.11n, 802.11a and 802.11ac
- connect to wireless
- Bluetooth devices pair and connect,
- edit IFUPDOWN interfaces
- system
- change timezone
- reconfigure locales, languages and charset
- change hostname
- toggle desktop (on desktop builds)
- toggle RDP (on desktop builds)
- toggle running servives (stock Debian app)
- enabling read only root filesystem (Ubuntu only)
- armbian
- install to SATA, eMMC, NAND or USB
- freeze and unfreeze kernel and BSP upgrades
- edit boot environment, network, FEX, welcome screen items
- switching between avaliable kernels and nightly builds
- about
- basic info about tool
----------
......
......@@ -16,7 +16,7 @@ while true; do
LIST=()
LIST+=( "Software" "System and 3rd party software install" )
LIST+=( "Networking" "Wireless, Bluetooth, Access point" )
LIST+=( "Networking" "Wired, Wireless, Bluetooth, Access point" )
LIST+=( "System" "General system settings" )
LIST+=( "Armbian" "Armbian specific: overlays, MOTD, loglevel" )
LIST+=( "About" "Information about this configuration tool" )
......
......@@ -128,9 +128,11 @@ function jobs ()
# select default interfaces if there is more than one
select_default_interface
dialog --title " IP address assignment " --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "DHCP" --no-label "Static" --yesno "\n\Z1DHCP:\Z0 automatic IP asignment by your router or DHCP server\n\n\Z1Static:\Z0 manually fixed IP address" 9 70
if [[ $? = 0 ]]; then
exitstatus=$?;
if [[ $exitstatus = 0 ]]; then
create_if_config "$DEFAULT_ADAPTER" "$DEFAULT_ADAPTER" "dynamic" > /etc/network/interfaces
elif [[ $? = 1 ]]; then
fi
if [[ $exitstatus = 1 ]]; then
create_if_config "$DEFAULT_ADAPTER" "$DEFAULT_ADAPTER" "fixed" > /dev/null
ip_editor "$DEFAULT_ADAPTER" "$DEFAULT_ADAPTER" "/etc/network/interfaces"
fi
......@@ -160,19 +162,21 @@ function jobs ()
exitstatus=$?;
if [[ $exitstatus = 0 ]]; then
dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nDisabling hotstop. Please wait!" 5 35
service hostapd stop
sed -i "s/^DAEMON_CONF=.*/DAEMON_CONF=/" /etc/init.d/hostapd
# disable DNS
systemctl daemon-reload
systemctl disable dnsmasq.service >/dev/null 2>&1
rm /etc/NetworkManager/conf.d/armbian.conf
ifdown $WIRELESS_ADAPTER 2> /dev/null
rm -f /etc/network/interfaces.d/armbian*
rm -f /etc/network/interfaces.d/armbian.ap.nat
rm -f /etc/network/interfaces.d/armbian.ap.bridge
sed -i '/^iptables/ d' /etc/rc.local
iptables -F
service network-manager reload
# reload services
reload-nety
[[ -n $HOSTAPDBRIDGE ]] && reboot
fi
if [[ $exitstatus = 1 ]]; then wlan_edit; service hostapd stop; sleep 1; service hostapd start; fi
if [[ $exitstatus = 1 ]]; then wlan_edit; reload-nety "reload"; fi
elif [[ -z $CURRENT_UUID ]]; then
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --msgbox "\nAll wireless connections are in use." 7 40
else
......@@ -202,6 +206,28 @@ function jobs ()
echo "ctrl_interface=/var/run/hostapd" >> /etc/hostapd.conf
echo "ctrl_interface_group=0" >> /etc/hostapd.conf
fi
CHECK=$(systemctl daemon-reload;service hostapd restart;service hostapd status|grep running)
# check n,a and ac modes
if [[ -n "$CHECK" ]]; then
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing wireless 802.11n \Z1(150-300Mbps)\Z0" 5 43
sleep 2
sed '/### IEEE 802.11n/,/^### IEEE 802.11n/ s/^# *//' -i /etc/hostapd.conf
CHECK=$(systemctl daemon-reload;service hostapd restart;service hostapd status|grep running)
if [[ -n "$CHECK" ]]; then
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing wireless 802.11a \Z1(5Ghz)\Z0" 5 36
sleep 2
sed '/### IEEE 802.11a/,/^### IEEE 802.11a/ s/^# *//' -i /etc/hostapd.conf
CHECK=$(systemctl daemon-reload;service hostapd restart;service hostapd status|grep running)
if [[ -n "$CHECK" ]]; then
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --colors --infobox "\nProbing wireless 802.11ac \Z1(433Mbps x n @ 5Ghz)\Z0" 5 51
sleep 2
else
sed '/## IEEE 802.11a/,/^## IEEE 802.11a/ s/.*/#&/' -i /etc/hostapd.conf
fi
else
sed '/## IEEE 802.11n/,/^## IEEE 802.11n/ s/.*/#&/' -i /etc/hostapd.conf
fi
fi
CHECK=$(systemctl daemon-reload;service hostapd restart;service hostapd status|grep fail)
if [[ -n "$CHECK" ]]; then
dialog --backtitle "$BACKTITLE" --title "Please wait" \
......@@ -306,12 +332,11 @@ function jobs ()
fi
else
ifdown $WIRELESS_ADAPTER 2> /dev/null
sleep 2
ifup $WIRELESS_ADAPTER 2> /dev/null
echo "nameserver 8.8.8.8" > /etc/resolvconf/resolv.conf.d/base
service network-manager restart
service dnsmasq restart
service hostapd restart
sleep 2
# reload services
reload-nety "reload"
fi
fi
;;
......@@ -333,6 +358,12 @@ function jobs ()
[[ $? = 0 ]] && mv /etc/network/interfaces.out /etc/network/interfaces && service network-manager restart && service networking restart
;;
# Remove automatic wifi conections
#
"Forget" )
nmcli --fields UUID,TIMESTAMP-REAL,TYPE con show | grep wireless | awk '{print $1}' | while read line; do nmcli con delete uuid $line; done > /dev/null
;;
......@@ -357,6 +388,24 @@ function jobs ()
;;
# Change Hostname
#
"Hostname" )
hostname_current=$(cat /etc/hostname)
hostname_new=$(\
dialog --no-cancel --title " Change hostname " --backtitle "$BACKTITLE" --inputbox "\nType new hostname\n " 10 50 $hostname_current \
3>&1 1>&2 2>&3 3>&- \
)
if [[ $? = 0 && -n $hostname_new ]]; then
sed -i "s/$hostname_current/$hostname_new/g" /etc/hosts
sed -i "s/$hostname_current/$hostname_new/g" /etc/hostname
hostname $hostname_new
systemctl restart systemd-logind.service
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --msgbox "\nYou need to logout to make the changes effective." 7 53
fi
;;
# Install to SATA, eMMC, NAND or USB
#
"Install" )
......
......@@ -58,6 +58,15 @@ function create_if_config() {
fi
} #
function reload-nety() {
if [[ "$1" == "reload" ]]; then WHATODO="Reloading services"; else WHATODO="Stopping services"; fi
(service network-manager stop; echo 10; sleep 1;\
service hostapd stop; echo 20; 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;\
service network-manager start; echo 90; sleep 5;) | dialog --backtitle "$BACKTITLE" --title " $WHATODO " --gauge "" 6 70 0
}
#-----------------------------------------------------------------------------------------------------------------------------------------#
# gather info about the board and start with loading menu
......@@ -154,15 +163,10 @@ function ip_editor ()
}
#-----------------------------------------------------------------------------------------------------------------------------------------#
# edit hostapd parameters
#
function wlan_edit ()
function wlan_edit_basic ()
{
source /etc/hostapd.conf
exec 3>&1
......@@ -183,6 +187,23 @@ function wlan_edit ()
}
}
#-----------------------------------------------------------------------------------------------------------------------------------------#
# edit hostapd parameters
#
function wlan_edit ()
{
# select default interfaces if there is more than one
select_default_interface
dialog --title " Configuration edit " --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Basic" --no-label "Advanced" --yesno "\n\Z1Basic:\Z0 Change SSID, password and channel\n\n\Z1Advanced:\Z0 Edit /etc/hostapd.conf file" 9 70
if [[ $? = 0 ]]; then
wlan_edit_basic
elif [[ $? = 1 ]]; then
dialog --backtitle "$BACKTITLE" --title " Edit hostapd configuration /etc/hostapd.conf" --no-collapse \
--ok-label "Save" --editbox /etc/hostapd.conf 30 0 2> /etc/hostapd.conf.out
[[ $? = 0 ]] && mv /etc/hostapd.conf.out /etc/hostapd.conf && service hostapd restart
fi
}
#-----------------------------------------------------------------------------------------------------------------------------------------#
# naming exceptions for packages
......@@ -344,11 +365,11 @@ while true; do
LIST=()
[[ -f /usr/bin/softy ]] && LIST+=( "Softy" "3rd party applications installer" )
if [[ -n $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'32032'"') ]]; then
LIST+=( "USB redirector" "Disable USB devices sharing over Ethernet" )
else
LIST+=( "USB redirector" "Enable USB devices sharing over Ethernet" )
fi
#if [[ -n $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".'32032'"') ]]; then
# LIST+=( "USB redirector" "Disable USB devices sharing over Ethernet" )
# else
# LIST+=( "USB redirector" "Enable USB devices sharing over Ethernet" )
#fi
[[ -f /usr/bin/h3consumption && "$LINUXFAMILY" = "sun8i" && "$BRANCH" = "default" ]] && \
LIST+=( "Consumption" "Control board consumption" )
[[ -f /usr/bin/armbianmonitor ]] && LIST+=( "Monitor" "Simple CLI monitoring" )
......@@ -388,6 +409,7 @@ done
#
function submenu_networking ()
{
select_default_interface
while true; do
LIST=()
LIST+=( "IP" "Select dynamic or edit static IP address" )
......@@ -401,29 +423,48 @@ while true; do
[[ -n $(nmcli device status | grep wifi | grep -w disconnected) ]] && LIST+=( "Hotspot" "Create WiFi access point" )
fi
[[ -n $(nmcli device status | grep wifi | grep -v unavailable) ]] && LIST+=( "WiFi" "Manage wireless networking" )
[[ -n $(nmcli device status | grep wifi | grep -v unavailable | grep -v unmanaged) ]] && LIST+=( "WiFi" "Manage wireless networking" )
if [[ -n $(service bluetooth status | grep -w active | grep -w running) ]]; then
[[ $(hcitool dev | sed '1d') != "" ]] && LIST+=( "Bluetooth" "Connect Bluetooth devices" )
fi
LIST+=( "Advanced" "Edit /etc/network/interfaces" )
[[ $(ls -1 /etc/NetworkManager/system-connections 2> /dev/null) ]] && LIST+=( "Forget" "Disconnect and forget all wireless connections" )
# count number of menu items to adjust window sizee
LISTLENGHT="$((11+${#LIST[@]}/2))"
LISTLENGHT="$((13+${#LIST[@]}/2))"
BOXLENGHT=${#LIST[@]}
WIFICONNECTED=$(nmcli -f NAME,TYPE connection show --active | grep wireless | awk 'NF{NF-=1};1')
local disclaimer=""
local ipadd=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)
if [[ -n $(grep $DEFAULT_ADAPTER /etc/network/interfaces | grep static) ]]; then
local ifup="\nStatic IP ($DEFAULT_ADAPTER) via IFUPDOWN: \Z1${ipadd}\n\Z0 "
elif [[ -n $(grep $DEFAULT_ADAPTER /etc/network/interfaces | grep dhcp) ]]; then
local ifup="\nDynamic IP ($DEFAULT_ADAPTER) via IFUPDOWN: \Z1${ipadd}\n\Z0 "
else
local ifup="\nDynamic IP ($DEFAULT_ADAPTER) via Network Manager: \Z1${ipadd}\n\Z0 "
fi
disclaimer="$ifup"
if [[ -n $WIFICONNECTED ]]; then
LISTLENGHT=$((LISTLENGHT+2))
local connected="\nConnected to SSID: \Z1${WIFICONNECTED}\n\Z0 "
disclaimer="$connected"
local connected="\n\Z0Connected to SSID: \Z1${WIFICONNECTED}\n\Z0 "
disclaimer=$disclaimer"$connected"
fi
if [[ -n $HOSTAPDINFO && -n $HOSTAPDSTATUS ]]; then
LISTLENGHT=$((LISTLENGHT+2))
disclaimer=$disclaimer$"\n\Z0Access point SSID: \Z1$HOSTAPDINFO\Zn ";
disclaimer=$disclaimer$"\n\Z0Hotspot SSID: \Z1$HOSTAPDINFO\Zn Band:";
if [[ `grep ^ieee80211a /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 ^ieee80211ac /etc/hostapd.conf` ]]; then local type="AC"; fi
disclaimer=$disclaimer$" \Z1${band} ${type}\Z0 "
if [ "$HOSTAPDCLIENTS" -gt "0" ]; then disclaimer=$disclaimer$" Connected clients: \Z1$HOSTAPDCLIENTS\Zn"; fi
disclaimer=$disclaimer$"\n";
fi
......@@ -440,7 +481,7 @@ while true; do
DIALOG_ESC=255
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wireless, Bluetooth, Hotspot " --clear \
selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wired, Wireless, Bluetooth, Hotspot " --clear \
--cancel-label "Back" --menu "${disclaimer}" $LISTLENGHT 70 $BOXLENGHT \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
......@@ -461,6 +502,7 @@ while true; do
# check for display manager statuses
LIST+=( "Timezone" "Change timezone ($(date +%Z))" )
LIST+=( "Locales" "Reconfigure language ($(locale | grep LANGUAGE | cut -d= -f2 | cut -d_ -f1)) and character set" )
LIST+=( "Hostname" "Change your hostname ($(cat /etc/hostname))" )
# check for display manager statuses
DISPLAY_MANAGER=""; DESKTOP_INSTALLED=""
[[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm"
......
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