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

RFC to beta state

parent 3fc6bc46
...@@ -15,9 +15,10 @@ source "$0""-jobs" ...@@ -15,9 +15,10 @@ source "$0""-jobs"
while true; do while true; do
LIST=() LIST=()
LIST+=( "Software" "System and 3rd party" ) LIST+=( "Software" "System and 3rd party software install" )
LIST+=( "Networking" "WiFI, BT, Hotspot" ) LIST+=( "Networking" "Wireless, Bluetooth, Access point" )
LIST+=( "Settings" "Board and system settings" ) LIST+=( "System" "General system settings" )
LIST+=( "Armbian" "Armbian specific: overlays, MOTD, loglevel" )
LIST+=( "About" "Information about this configuration tool" ) LIST+=( "About" "Information about this configuration tool" )
# count number of menu items to adjust window sizee # count number of menu items to adjust window sizee
...@@ -29,7 +30,7 @@ while true; do ...@@ -29,7 +30,7 @@ while true; do
DIALOG_ESC=255 DIALOG_ESC=255
exec 3>&1 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "armbian-config" --clear \ selection=$(dialog --backtitle "$BACKTITLE" --title " armbian-config " --clear \
--cancel-label "Exit to shell" --menu "\nConfiguration tool for the $BOARD_NAME running $DISTRO $DISTROID \n " $LISTLENGHT 70 $BOXLENGHT \ --cancel-label "Exit to shell" --menu "\nConfiguration tool for the $BOARD_NAME running $DISTRO $DISTROID \n " $LISTLENGHT 70 $BOXLENGHT \
"${LIST[@]}" 2>&1 1>&3) "${LIST[@]}" 2>&1 1>&3)
exit_status=$? exit_status=$?
...@@ -45,9 +46,12 @@ while true; do ...@@ -45,9 +46,12 @@ while true; do
"Networking" ) "Networking" )
submenu_networking submenu_networking
;; ;;
"Settings" ) "System" )
submenu_settings submenu_settings
;; ;;
"Armbian" )
submenu_hardware
;;
"About" ) "About" )
show_box "Info" "This tool provides a straightforward way of doing initial configuration of the ${BOARD_NAME}. Although it can be run at any time, some of the options may have difficulties if you have heavily customised your installation.\n\nSources: https://github.com/armbian/config\n\nSupport: https://forum.armbian.com" "15" show_box "Info" "This tool provides a straightforward way of doing initial configuration of the ${BOARD_NAME}. Although it can be run at any time, some of the options may have difficulties if you have heavily customised your installation.\n\nSources: https://github.com/armbian/config\n\nSupport: https://forum.armbian.com" "15"
;; ;;
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
function jobs () function jobs ()
{ {
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection})) # Shows box with loading ...
#
dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection}))
case $1 in case $1 in
#-------------------------------------------------------------------------------------------------------------------------------------# #-------------------------------------------------------------------------------------------------------------------------------------#
...@@ -135,24 +137,34 @@ function jobs () ...@@ -135,24 +137,34 @@ function jobs ()
systemctl daemon-reload systemctl daemon-reload
CURRENT_UUID=$(nmcli -f DEVICE,TYPE,STATE device status | grep -w " wifi " | grep -w " disconnected") CURRENT_UUID=$(nmcli -f DEVICE,TYPE,STATE device status | grep -w " wifi " | grep -w " disconnected")
if [[ -n $(service hostapd status | grep -w active | grep -w running) ]]; then if [[ -n $(service hostapd status | grep -w active | grep -w running) ]]; then
dialog --title "Hostapd service is running" --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Stop" \ if [[ -n $HOSTAPDBRIDGE ]]; then
--no-label "Edit" --yesno "\nStop: stop and disable\n\nEdit: change basic parameters: SSID, password and channel" 9 70 dialog --title " Hostapd service is running " --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Stop and reboot" --no-label "Edit" --yesno "\n\Z1Stop:\Z0 stop and reboot\n\n\Z1Edit:\Z0 change basic parameters: SSID, password and channel" 9 70
else
dialog --title " Hostapd service is running " --colors --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Stop" --no-label "Edit" --yesno "\n\Z1Stop:\Z0 stop providing Access Point\n\n\Z1Edit:\Z0 change basic parameters: SSID, password and channel" 9 70
fi
exitstatus=$?; exitstatus=$?;
if [[ $exitstatus = 0 ]]; then if [[ $exitstatus = 0 ]]; then
dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nDisabling hotstop. Please wait!" 5 35
service hostapd stop service hostapd stop
sed -i "s/^DAEMON_CONF=.*/DAEMON_CONF=/" /etc/init.d/hostapd sed -i "s/^DAEMON_CONF=.*/DAEMON_CONF=/" /etc/init.d/hostapd
systemctl daemon-reload systemctl daemon-reload
systemctl disable dnsmasq.service >/dev/null 2>&1 systemctl disable dnsmasq.service >/dev/null 2>&1
rm /etc/NetworkManager/conf.d/armbian.conf rm /etc/NetworkManager/conf.d/armbian.conf
rm -f /etc/network/interfaces.d/bridge.conf ifdown $WIRELESS_ADAPTER 2> /dev/null
rm -f /etc/network/interfaces.d/nat.conf ln -sf /etc/network/interfaces.default /etc/network/interfaces
service network-manager reload
sed -i '/^iptables/ d' /etc/rc.local sed -i '/^iptables/ d' /etc/rc.local
iptables -F
service network-manager reload
[[ -n $HOSTAPDBRIDGE ]] && reboot
fi fi
if [[ $exitstatus = 1 ]]; then wlan_edit; service hostapd stop; sleep 1; service hostapd start; fi if [[ $exitstatus = 1 ]]; then wlan_edit; service hostapd stop; sleep 1; service hostapd start; fi
elif [[ -z $CURRENT_UUID ]]; then elif [[ -z $CURRENT_UUID ]]; then
dialog --title "Info" --backtitle "$BACKTITLE" --no-collapse --msgbox "\nAll wireless connections are in use." 7 40 dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --msgbox "\nAll wireless connections are in use." 7 40
else else
# remove interfaces from managed list
rm -f /etc/NetworkManager/conf.d/armbian.conf
service network-manager reload
# 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
...@@ -170,6 +182,12 @@ function jobs () ...@@ -170,6 +182,12 @@ function jobs ()
# add hostapd.conf to services # add hostapd.conf to services
sed -i "s/^DAEMON_CONF=.*/DAEMON_CONF=\/etc\/hostapd.conf/" /etc/init.d/hostapd sed -i "s/^DAEMON_CONF=.*/DAEMON_CONF=\/etc\/hostapd.conf/" /etc/init.d/hostapd
# check both options # check both options
# add allow cli access if not exists. temporally
if ! grep -q "ctrl_interface" /etc/hostapd.conf; then
echo "" >> /etc/hostapd.conf
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 fail) CHECK=$(systemctl daemon-reload;service hostapd restart;service hostapd status|grep fail)
if [[ -n "$CHECK" ]]; then if [[ -n "$CHECK" ]]; then
dialog --backtitle "$BACKTITLE" --title "Please wait" \ dialog --backtitle "$BACKTITLE" --title "Please wait" \
...@@ -178,6 +196,11 @@ function jobs () ...@@ -178,6 +196,11 @@ function jobs ()
# 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 fi
# add allow cli access if not exists. temporally
if ! grep -q "ctrl_interface" /etc/hostapd.conf; then
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 fail) CHECK=$(systemctl daemon-reload;service hostapd restart;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
...@@ -189,35 +212,40 @@ function jobs () ...@@ -189,35 +212,40 @@ function jobs ()
break break
fi fi
dialog --title "Choose Access Point mode for $WIRELESS_ADAPTER" --backtitle "$BACKTITLE" --help-button \ dialog --title " Choose Access Point mode for $WIRELESS_ADAPTER " --colors --backtitle "$BACKTITLE" --no-label "Bridge" \
--help-label "Manual" --yes-label "Bridge" --no-label "NAT" --yesno "\nBridge: wireless clients will use your routers DHCP \ --yes-label "NAT" --yesno "\n\Z1NAT:\Z0 with own DHCP server, out of your primary network\n\n\Z1Bridge:\Z0 wireless clients will use your routers DHCP server" 9 70
server\n\nNAT: with own DHCP server, out of your primary network\n\nManual: edit configuration manually" 11 70
response=$? response=$?
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
NETWORK_CONF="/etc/network/interfaces"
dialog --title "Network configuration" --backtitle "$BACKTITLE" --yesno "\nStart with clean config?" 7 29
[[ $? = 0 ]] && NETWORK_CONF="/etc/network/interfaces.default";
TEMP_CONF="/etc/network/interfaces.out" # select default interfaces if there is more than one
cp $NETWORK_CONF $TEMP_CONF select_default_interface
NETWORK_CONF="/etc/network/interfaces"
case $response in case $response in
# bridge # bridge
0) 1)
sed -i 's/^bridge=.*/bridge=br0/' /etc/hostapd.conf TEMP_CONF="/etc/network/interfaces.ap.bridge"
sed -i 's/.bridge=.*/bridge=br0/' /etc/hostapd.conf
if [[ $DEFAULT_ADAPTER == "br0" ]]; then NEW_DEFAULT_ADAPTER="eth0"; else NEW_DEFAULT_ADAPTER="$DEFAULT_ADAPTER"; fi if [[ $DEFAULT_ADAPTER == "br0" ]]; then NEW_DEFAULT_ADAPTER="eth0"; else NEW_DEFAULT_ADAPTER="$DEFAULT_ADAPTER"; fi
echo -e "#bridged wireless for hostapd by armbian-config\n" > /etc/network/interfaces.d/bridge.conf echo -e "#bridged wireless for hostapd by armbian-config\n" > $TEMP_CONF
echo -e "auto lo br0\niface lo inet loopback" >> /etc/network/interfaces.d/bridge.conf echo -e "auto lo br0\niface lo inet loopback" >> $TEMP_CONF
echo -e "\nauto $NEW_DEFAULT_ADAPTER\nallow-hotplug $NEW_DEFAULT_ADAPTER\niface $NEW_DEFAULT_ADAPTER inet manual" >> /etc/network/interfaces.d/bridge.conf echo -e "\nauto $NEW_DEFAULT_ADAPTER\nallow-hotplug $NEW_DEFAULT_ADAPTER\niface $NEW_DEFAULT_ADAPTER inet manual" >> $TEMP_CONF
echo -e "\nauto $WIRELESS_ADAPTER\nallow-hotplug $WIRELESS_ADAPTER\niface $WIRELESS_ADAPTER inet manual\n" >> /etc/network/interfaces.d/bridge.conf echo -e "\nauto $WIRELESS_ADAPTER\nallow-hotplug $WIRELESS_ADAPTER\niface $WIRELESS_ADAPTER inet manual\n" >> $TEMP_CONF
create_if_config "$DEFAULT_ADAPTER" "br0" >> /etc/network/interfaces.d/bridge.conf create_if_config "$DEFAULT_ADAPTER" "br0" >> $TEMP_CONF
echo -e "\nbridge_ports $NEW_DEFAULT_ADAPTER $WIRELESS_ADAPTER" >> /etc/network/interfaces.d/bridge.conf echo -e "\nbridge_ports $NEW_DEFAULT_ADAPTER $WIRELESS_ADAPTER" >> $TEMP_CONF
;; ;;
# NAT # NAT
1) 0)
debconf-apt-progress -- apt-get -qq -y --no-install-recommends install dnsmasq iptables TEMP_CONF="/etc/network/interfaces.ap.nat"
echo -e "\nallow-hotplug $WIRELESS_ADAPTER\niface $WIRELESS_ADAPTER inet static " > /etc/network/interfaces.d/nat.conf if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dnsmasq 2>/dev/null) != *ii* ]]; then
echo -e "\naddress 172.24.1.1\nnetmask 255.255.255.0\nnetwork 172.24.1.0\nbroadcast 172.24.1.255" >> /etc/network/interfaces.d/nat.conf debconf-apt-progress -- apt-get -qq -y --no-install-recommends install dnsmasq
fi
if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' iptables 2>/dev/null) != *ii* ]]; then
debconf-apt-progress -- apt-get -qq -y --no-install-recommends install iptables
fi
echo -e "# armbian NAT hostapd\nallow-hotplug $WIRELESS_ADAPTER\niface $WIRELESS_ADAPTER inet static " > $TEMP_CONF
echo -e "\taddress 172.24.1.1\n\tnetmask 255.255.255.0\n\tnetwork 172.24.1.0\n\tbroadcast 172.24.1.255" >> $TEMP_CONF
# create new configuration # create new configuration
echo "interface=$WIRELESS_ADAPTER # Use interface $WIRELESS_ADAPTER" > /etc/dnsmasq.conf echo "interface=$WIRELESS_ADAPTER # Use interface $WIRELESS_ADAPTER" > /etc/dnsmasq.conf
echo "listen-address=172.24.1.1 # Explicitly specify the address to listen on" >> /etc/dnsmasq.conf echo "listen-address=172.24.1.1 # Explicitly specify the address to listen on" >> /etc/dnsmasq.conf
...@@ -238,7 +266,6 @@ function jobs () ...@@ -238,7 +266,6 @@ function jobs ()
iptables -A FORWARD -i $WIRELESS_ADAPTER -o $DEFAULT_ADAPTER -j ACCEPT iptables -A FORWARD -i $WIRELESS_ADAPTER -o $DEFAULT_ADAPTER -j ACCEPT
# - Save IP tables, applied during ifup in /etc/network/interfaces. # - Save IP tables, applied during ifup in /etc/network/interfaces.
iptables-save > /etc/iptables.ipv4.nat iptables-save > /etc/iptables.ipv4.nat
service dnsmasq restart
sed -i 's/^bridge=.*/#&/' /etc/hostapd.conf sed -i 's/^bridge=.*/#&/' /etc/hostapd.conf
sed -e 's/exit 0//g' -i /etc/rc.local sed -e 's/exit 0//g' -i /etc/rc.local
echo "iptables-restore < /etc/iptables.ipv4.nat" >> /etc/rc.local echo "iptables-restore < /etc/iptables.ipv4.nat" >> /etc/rc.local
...@@ -248,17 +275,30 @@ function jobs () ...@@ -248,17 +275,30 @@ function jobs ()
255) exit;; 255) exit;;
esac esac
dialog --title "Manually adjust network configuration if needed" --backtitle "$BACKTITLE" \
--ok-label "Reboot to apply new settings" --no-collapse --editbox $TEMP_CONF 30 0 2> $TEMP_CONF".tmp" dialog --backtitle "$BACKTITLE" --title " Please wait " --infobox "\nEnabling hotstop. Please wait!" 5 34
response=$?
service hostapd stop #
if [[ $response = 0 ]]; then # only for bridged connection we need to check and reboot. tdlr check if it can be done on the fly
echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces HOSTAPDBRIDGE=$(cat /etc/hostapd.conf 2> /dev/null | grep -w "^bridge=br0")
reboot if [[ -n $HOSTAPDBRIDGE ]]; then
else dialog --title "Manually adjust network configuration if needed" --backtitle "$BACKTITLE" \
# remove conf --ok-label "Reboot to apply new settings" --no-collapse --editbox $TEMP_CONF 30 0 2> $TEMP_CONF".tmp"
rm -f /etc/network/interfaces.d/bridge.conf response=$?
rm -f /etc/network/interfaces.d/nat.conf if [[ $response = 0 ]]; then
mv $TEMP_CONF".tmp" $TEMP_CONF
ln -sf $TEMP_CONF /etc/network/interfaces
reboot
fi
else
ln -sf $TEMP_CONF /etc/network/interfaces
ifdown $WIRELESS_ADAPTER 2> /dev/null
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
fi fi
fi fi
;; ;;
...@@ -267,7 +307,7 @@ function jobs () ...@@ -267,7 +307,7 @@ function jobs ()
# Connect to Bluetooth # Connect to Bluetooth
# #
"Bluetooth" ) "Bluetooth" )
dialog --backtitle "$BACKTITLE" --title "Bluetooth" --msgbox "\nMake sure your Bluetooth devices are discoverable!" 7 54 dialog --backtitle "$BACKTITLE" --title " Bluetooth " --msgbox "\nMake sure your Bluetooth devices are discoverable!" 7 54
connect_bt_interface connect_bt_interface
;; ;;
...@@ -275,9 +315,9 @@ function jobs () ...@@ -275,9 +315,9 @@ function jobs ()
# Edit network settings # Edit network settings
# #
"Network" ) "Network" )
dialog --backtitle "$BACKTITLE" --title "Edit network configuration" --no-collapse \ dialog --backtitle "$BACKTITLE" --title " Edit ifupdown network configuration /etc/network/interfaces" --no-collapse \
--ok-label "Save" --editbox /etc/network/interfaces 30 0 2> /etc/network/interfaces.out --ok-label "Save" --editbox /etc/network/interfaces 30 0 2> /etc/network/interfaces.out
[[ $? = 0 ]] && mv /etc/network/interfaces.out /etc/network/interfaces && service network-manager restart [[ $? = 0 ]] && mv /etc/network/interfaces.out /etc/network/interfaces && service network-manager restart && service networking restart
;; ;;
...@@ -297,6 +337,13 @@ function jobs () ...@@ -297,6 +337,13 @@ function jobs ()
;; ;;
# Change locales
#
"Locales" )
dpkg-reconfigure locales
;;
# Install to SATA, eMMC, NAND or USB # Install to SATA, eMMC, NAND or USB
# #
"Install" ) "Install" )
...@@ -307,7 +354,7 @@ function jobs () ...@@ -307,7 +354,7 @@ function jobs ()
# Freeze and unfreeze kernel and board support packages # Freeze and unfreeze kernel and board support packages
# #
"Hold" | "Unhold" ) "Hold" | "Unhold" )
dialog --title "Update" --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" \ dialog --title " Update " --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" \
--yesno "\nDo you want to ${1,,} kernel updates?" 7 50 --yesno "\nDo you want to ${1,,} kernel updates?" 7 50
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
TARGET_BRANCH=$BRANCH TARGET_BRANCH=$BRANCH
...@@ -326,12 +373,12 @@ function jobs () ...@@ -326,12 +373,12 @@ function jobs ()
# #
"Desktop" ) "Desktop" )
if [[ -n $(service lightdm status 2> /dev/null | grep -w active | grep -w running) || -n $(service nodm status | grep -w active | grep -w running) ]]; then if [[ -n $(service lightdm status 2> /dev/null | grep -w active | grep -w running) || -n $(service nodm status | grep -w active | grep -w running) ]]; then
dialog --title "Desktop is enabled and running" --backtitle "$BACKTITLE" \ dialog --title " Desktop is enabled and running " --backtitle "$BACKTITLE" \
--yes-label "Stop" --no-label "Cancel" --yesno "\nDo you want to stop and disable this service?" 7 50 --yes-label "Stop" --no-label "Cancel" --yesno "\nDo you want to stop and disable this service?" 7 50
exitstatus=$?; exitstatus=$?;
[[ $exitstatus = 0 ]] && service nodm stop && service lightdm stop && sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm [[ $exitstatus = 0 ]] && service nodm stop && service lightdm stop && sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm
else else
dialog --title "Choose a display manager" --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Lightdm" \ dialog --title " Choose a display manager " --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Lightdm" \
--no-label "Nodm" --yesno "\nLightdm = full featured login display manager\nNodm = autoloading into desktop" 8 70 --no-label "Nodm" --yesno "\nLightdm = full featured login display manager\nNodm = autoloading into desktop" 8 70
exitstatus=$?; exitstatus=$?;
[[ $exitstatus = 0 ]] && [[ -f /etc/X11/default-display-manager ]] && echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager && debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install lightdm-gtk-greeter lightdm && systemctl start lightdm.service [[ $exitstatus = 0 ]] && [[ -f /etc/X11/default-display-manager ]] && echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager && debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install lightdm-gtk-greeter lightdm && systemctl start lightdm.service
...@@ -374,7 +421,7 @@ function jobs () ...@@ -374,7 +421,7 @@ function jobs ()
# Stop low-level messages on console # Stop low-level messages on console
# #
"Lowlevel" ) "Lowlevel" )
dialog --title "Kernel messages" --backtitle "$BACKTITLE" --help-button \ dialog --title " Kernel messages " --backtitle "$BACKTITLE" --help-button \
--help-label "Yes & reboot" --yes-label "Yes" --no-label "Cancel" --yesno "\nStop low-level messages on console?" 7 64 --help-label "Yes & reboot" --yes-label "Yes" --no-label "Cancel" --yesno "\nStop low-level messages on console?" 7 64
exitstatus=$?; exitstatus=$?;
[[ $exitstatus = 0 ]] && sed -i 's/^#kernel.printk\(.*\)/kernel.printk\1/' /etc/sysctl.conf [[ $exitstatus = 0 ]] && sed -i 's/^#kernel.printk\(.*\)/kernel.printk\1/' /etc/sysctl.conf
...@@ -385,7 +432,7 @@ function jobs () ...@@ -385,7 +432,7 @@ function jobs ()
# Edit boot environment # Edit boot environment
# #
"Bootenv" ) "Bootenv" )
dialog --title "Edit u-boot environment" --ok-label "Save" \ dialog --title " Edit u-boot environment " --ok-label "Save" \
--no-collapse --editbox /boot/armbianEnv.txt 30 0 2> /boot/armbianEnv.txt.out --no-collapse --editbox /boot/armbianEnv.txt 30 0 2> /boot/armbianEnv.txt.out
[[ $? = 0 ]] && mv /boot/armbianEnv.txt.out /boot/armbianEnv.txt [[ $? = 0 ]] && mv /boot/armbianEnv.txt.out /boot/armbianEnv.txt
;; ;;
...@@ -394,7 +441,7 @@ function jobs () ...@@ -394,7 +441,7 @@ function jobs ()
# #
"Bootscript" ) "Bootscript" )
if [[ -f /boot/boot.ini ]]; then if [[ -f /boot/boot.ini ]]; then
dialog --title "Edit boot.ini script" --ok-label "Save" \ dialog --title " Edit boot.ini script " --ok-label "Save" \
--no-collapse --editbox /boot/boot.ini 30 0 2> /boot/boot.ini.out --no-collapse --editbox /boot/boot.ini 30 0 2> /boot/boot.ini.out
[[ $? = 0 ]] && mv /boot/boot.ini.out /boot/boot.ini [[ $? = 0 ]] && mv /boot/boot.ini.out /boot/boot.ini
fi fi
...@@ -410,7 +457,7 @@ function jobs () ...@@ -410,7 +457,7 @@ function jobs ()
# Toggle welcome screen items # Toggle welcome screen items
# #
"Overlay" ) "Overlays" )
# check if user agree to enter this area # check if user agree to enter this area
beta_disclaimer "You are entering beta area. Functions are not yet done - in case of troubles and advanced usage, check https://docs.armbian.com" beta_disclaimer "You are entering beta area. Functions are not yet done - in case of troubles and advanced usage, check https://docs.armbian.com"
if [[ -n $ACKNOWLEDGEMENT ]]; then if [[ -n $ACKNOWLEDGEMENT ]]; then
...@@ -502,7 +549,7 @@ function jobs () ...@@ -502,7 +549,7 @@ function jobs ()
# Switch to daily builds # Switch to daily builds
# #
"Nightly" ) "Nightly" )
dialog --title "Warning" --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \ dialog --title " Warning " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \
--yesno "\nYou are switching to automated nightly repository which is untested and might break your system.\ --yesno "\nYou are switching to automated nightly repository which is untested and might break your system.\
Are you fine with that?" 9 48 Are you fine with that?" 9 48
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
...@@ -519,7 +566,7 @@ function jobs () ...@@ -519,7 +566,7 @@ function jobs ()
# Switch to stable builds # Switch to stable builds
# #
"Stable" ) "Stable" )
dialog --title "Warning" --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \ dialog --title " Warning " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \
--yesno "\nYou are switching back to stable respository where you are going to get future updates.\ --yesno "\nYou are switching back to stable respository where you are going to get future updates.\
Are you fine with that?" 9 44 Are you fine with that?" 9 44
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
...@@ -538,7 +585,7 @@ function jobs () ...@@ -538,7 +585,7 @@ function jobs ()
"Switch" ) "Switch" )
aval_kernel aval_kernel
exceptions "$INSTALL_KERNEL" exceptions "$INSTALL_KERNEL"
dialog --title "Install and reboot" --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \ dialog --title " Install and reboot " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \
--yesno "\nSwitching to linux-image${TARGET_BRANCH}-${TARGET_FAMILY} \n\nMake sure you know what you are doing! \ --yesno "\nSwitching to linux-image${TARGET_BRANCH}-${TARGET_FAMILY} \n\nMake sure you know what you are doing! \
\n\nBoard config will be reverted to defaults." 11 46 \n\nBoard config will be reverted to defaults." 11 46
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
...@@ -571,7 +618,7 @@ function jobs () ...@@ -571,7 +618,7 @@ function jobs ()
# #
"Overlayroot" ) "Overlayroot" )
if [[ -n $(mount | grep -w overlay) ]]; then if [[ -n $(mount | grep -w overlay) ]]; then
dialog --title "Root overlay" --backtitle "$BACKTITLE" --yes-label "Disable" \ dialog --title " Root overlay " --backtitle "$BACKTITLE" --yes-label "Disable" \
--no-label "Cancel" \ --no-label "Cancel" \
--yesno "\nYour system is already virtual read-only.\n\nDo you want to disable this feature and reboot?" 9 60 --yesno "\nYour system is already virtual read-only.\n\nDo you want to disable this feature and reboot?" 9 60
[[ $? = 0 ]] && overlayroot-chroot sed -i "s/^overlayroot=.*/overlayroot=\"\"/" /etc/overlayroot.conf && \ [[ $? = 0 ]] && overlayroot-chroot sed -i "s/^overlayroot=.*/overlayroot=\"\"/" /etc/overlayroot.conf && \
......
...@@ -67,8 +67,6 @@ KERNELID=$(uname -r) ...@@ -67,8 +67,6 @@ KERNELID=$(uname -r)
BACKTITLE="Configuration utility, $ARMBIAN, https://www.armbian.com" BACKTITLE="Configuration utility, $ARMBIAN, https://www.armbian.com"
TITLE="$BOARD_NAME " TITLE="$BOARD_NAME "
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)') DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
#IPADDRESS=$(get_ip_addresses "br0" "eth0" > /tmp/x)
IPADDRESS=$(create_if_config "br0" "eth0" )
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Armbian configuration utility ... " 5 45 dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Armbian configuration utility ... " 5 45
...@@ -90,7 +88,7 @@ check_port () ...@@ -90,7 +88,7 @@ check_port ()
function beta_disclaimer () function beta_disclaimer ()
{ {
exec 3>&1 exec 3>&1
ACKNOWLEDGEMENT=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse --title "Warning" --clear \--radiolist "\n$1.\n \n" 12 56 7 "Yes, I understand" "" off 2>&1 1>&3) ACKNOWLEDGEMENT=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse --title " Warning " --clear \--radiolist "\n$1.\n \n" 12 56 7 "Yes, I understand" "" off 2>&1 1>&3)
exec 3>&- exec 3>&-
} }
...@@ -101,7 +99,7 @@ exec 3>&- ...@@ -101,7 +99,7 @@ exec 3>&-
# #
function show_box () function show_box ()
{ {
dialog --no-shadow --backtitle "$BACKTITLE" --no-collapse --title "$1" --clear --msgbox "\n$2\n \n" $3 56 dialog --no-shadow --backtitle "$BACKTITLE" --no-collapse --title " $1 " --clear --msgbox "\n$2\n \n" $3 56
} }
...@@ -230,7 +228,7 @@ function get_wlan_interface () ...@@ -230,7 +228,7 @@ function get_wlan_interface ()
{ {
IFS=$'\r\n' IFS=$'\r\n'
GLOBIGNORE='*' GLOBIGNORE='*'
WLAN_INTERFACES=($(nmcli dev status | grep wifi |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
...@@ -248,6 +246,31 @@ function get_wlan_interface () ...@@ -248,6 +246,31 @@ function get_wlan_interface ()
} }
#-----------------------------------------------------------------------------------------------------------------------------------------#
# select interface if there is more than one
#
function select_default_interface ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
local ADAPTER=($(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)'))
local LIST=()
for i in "${ADAPTER[@]}"
do
LIST+=( "${i[0]//[[:blank:]]/}" "" )
done
LIST_LENGHT=$((${#LIST[@]}/2));
if [ "$LIST_LENGHT" -eq 1 ]; then
DEFAULT_ADAPTER=${ADAPTER[0]}
else
exec 3>&1
DEFAULT_ADAPTER=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select default interface" --clear --menu "" $((6+${LIST_LENGHT})) 30 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
# search for BT devices and connect # search for BT devices and connect
# #
function connect_bt_interface () function connect_bt_interface ()
...@@ -343,17 +366,20 @@ function submenu_networking () ...@@ -343,17 +366,20 @@ function submenu_networking ()
{ {
while true; do while true; do
LIST=() LIST=()
if [[ -n $(service hostapd status | grep -w active | grep -w running) ]]; then HOSTAPDBRIDGE=$(cat /etc/hostapd.conf 2> /dev/null | grep -w "^bridge=br0")
HOSTAPDINFO=$(hostapd_cli get_config | grep ^ssid | sed 's/ssid=//g') HOSTAPDSTATUS=$(service hostapd status | grep -w active | grep -w running)
[[ -n $(nmcli device status | grep wifi | grep connected) ]] && LIST+=( "Hotspot" "Manage active wireless access point" ) if [[ -n "$HOSTAPDSTATUS" ]]; then
HOSTAPDINFO=$(hostapd_cli get_config 2> /dev/null | grep ^ssid | sed 's/ssid=//g')
HOSTAPDCLIENTS=$(hostapd_cli all_sta 2> /dev/null | grep connected_time | wc -l)
LIST+=( "Hotspot" "Manage active wireless access point" )
else else
[[ -n $(nmcli device status | grep wifi | grep disconnected) ]] && LIST+=( "Hotspot" "Create WiFi access point" ) [[ -n $(nmcli device status | grep wifi | grep -w disconnected) ]] && LIST+=( "Hotspot" "Create WiFi access point" )
fi fi
[[ -n $(nmcli device status | grep wifi | grep -v unavailable) ]] && LIST+=( "WiFi" "Manage wireless networking" ) [[ -n $(nmcli device status | grep wifi | grep -v unavailable) ]] && LIST+=( "WiFi" "Manage wireless networking" )
[[ $(hcitool dev | sed '1d') != "" && -n $(service bluetooth status | grep -w active | grep -w running) ]] && LIST+=( "Bluetooth" "Connect Bluetooth devices" ) [[ $(hcitool dev | sed '1d') != "" && -n $(service bluetooth status | grep -w active | grep -w running) ]] && LIST+=( "Bluetooth" "Connect Bluetooth devices" )
LIST+=( "Network" "Edit network settings" ) LIST+=( "Network" "Edit /etc/network/interfaces" )
# count number of menu items to adjust window sizee # count number of menu items to adjust window sizee
LISTLENGHT="$((11+${#LIST[@]}/2))" LISTLENGHT="$((11+${#LIST[@]}/2))"
...@@ -363,19 +389,21 @@ while true; do ...@@ -363,19 +389,21 @@ while true; do
local disclaimer="" local disclaimer=""
if [[ -n $WIFICONNECTED ]]; then if [[ -n $WIFICONNECTED ]]; then
LISTLENGHT=$((LISTLENGHT+2)) LISTLENGHT=$((LISTLENGHT+2))
local connected="\nConnected to SSID: $WIFICONNECTED\n" local connected="\nConnected to SSID: \Z1${WIFICONNECTED}\n\Z0 "
disclaimer=$connected disclaimer="$connected"
fi fi
if [[ -n $HOSTAPDINFO ]]; then if [[ -n $HOSTAPDINFO && -n $HOSTAPDSTATUS ]]; then
LISTLENGHT=$((LISTLENGHT+2)) LISTLENGHT=$((LISTLENGHT+2))
disclaimer=$disclaimer$"\nAccess point SSID: $HOSTAPDINFO\n" disclaimer=$disclaimer$"\n\Z0Access point SSID: \Z1$HOSTAPDINFO\Zn ";
if [ "$HOSTAPDCLIENTS" -gt "0" ]; then disclaimer=$disclaimer$" Connected clients: \Z1$HOSTAPDCLIENTS\Zn"; fi
disclaimer=$disclaimer$"\n";
fi fi
#disclaimer=$disclaimer"\n" #disclaimer=$disclaimer"\n"
# display warning only we have wifi # display warning only we have wifi
#if [[ " ${LIST[*]} " == *" Hotspot "* ]]; then #if [[ " ${LIST[*]} " == *" Hotspot "* ]]; then
disclaimer=$disclaimer"\nNote: wireless networking in Linux is problematic. Our tools make it easy for some cases but can't enable AP on every random WiFi chip. If this tool fail, you are on your own.\n " disclaimer=$disclaimer"\n\Z1Note\Zn: wireless networking in Linux is problematic. Our tools make it easy for some cases but can't enable AP on every random WiFi chip. If this tool fail, you are on your own.\n "
#else #else
# LISTLENGHT="$((6+${#LIST[@]}/2))" # LISTLENGHT="$((6+${#LIST[@]}/2))"
#fi #fi
...@@ -384,8 +412,8 @@ while true; do ...@@ -384,8 +412,8 @@ while true; do
DIALOG_ESC=255 DIALOG_ESC=255
exec 3>&1 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "Wireless, Bluetooth, Hotspot" --clear \ selection=$(dialog --backtitle "$BACKTITLE" --colors --title " Wireless, Bluetooth, Hotspot " --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \ --cancel-label "Back" --menu "${disclaimer}" $LISTLENGHT 70 $BOXLENGHT \
"${LIST[@]}" 2>&1 1>&3) "${LIST[@]}" 2>&1 1>&3)
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
...@@ -403,13 +431,8 @@ while true; do ...@@ -403,13 +431,8 @@ while true; do
LIST=() LIST=()
# check for display manager statuses # check for display manager statuses
LIST+=( "Timezone" "Change your timezone" ) LIST+=( "Timezone" "Change timezone ($(date +%Z))" )
[[ $(sed -n 's/^DEVNAME=//p' /sys/dev/block/$(mountpoint -d /)/uevent) == mmcblk* && -f /usr/sbin/nand-sata-install ]] && LIST+=( "Install" "Install to SATA, eMMC, NAND or USB" ) LIST+=( "Locales" "Reconfigure language ($(locale | grep LANGUAGE | cut -d= -f2 | cut -d_ -f1)) and character set" )
if [[ -n $(apt-mark showhold | grep -w "$BOARD") ]]; then
LIST+=( "Unhold" "Un-Freeze kernel and board support packages" )
else
LIST+=( "Hold" "Freeze kernel and board support packages" )
fi
# check for display manager statuses # check for display manager statuses
DISPLAY_MANAGER=""; DESKTOP_INSTALLED="" DISPLAY_MANAGER=""; DESKTOP_INSTALLED=""
[[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm" [[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm"
...@@ -430,11 +453,57 @@ while true; do ...@@ -430,11 +453,57 @@ while true; do
LIST+=( "RDP" "Enable remote desktop access from Windows" ) LIST+=( "RDP" "Enable remote desktop access from Windows" )
fi fi
fi fi
LIST+=( "Services" "Toggle running services" )
if [[ "$DISTRO" == "Ubuntu" && "$(modinfo overlay > /dev/null 2>&1; echo $?)" == "0" ]]; then
if [ -n "$(mount | grep -w tmpfs-root)" ]; then
LIST+=( "Overlayroot" "Disable virtual read-only root filesystem" )
else
LIST+=( "Overlayroot" "Enable virtual read-only root filesystem" )
fi
fi
# count number of menu items to adjust window sizee
LISTLENGHT="$((11+${#LIST[@]}/2))"
BOXLENGHT=${#LIST[@]}
# display warning only we have wifi
if [[ " ${LIST[*]} " == *" Hotspot "* ]]; then
local disclaimer="\nNote: wireless networking in Linux is problematic. Our tools make it easy for some cases but can't enable AP on every random WiFi chip. If this tool fail, you are on your own.\n "
else
LISTLENGHT="$((6+${#LIST[@]}/2))"
fi
DIALOG_CANCEL=1
DIALOG_ESC=255
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title " System settings " --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
"${LIST[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
jobs "$selection"
done
}
#-----------------------------------------------------------------------------------------------------------------------------------------#
# menu for armbian
#
function submenu_hardware ()
{
while true; do
LIST=()
[[ $(sed -n 's/^DEVNAME=//p' /sys/dev/block/$(mountpoint -d /)/uevent) == mmcblk* && -f /usr/sbin/nand-sata-install ]] && LIST+=( "Install" "Install to SATA, eMMC, NAND or USB" )
if [[ -n $(apt-mark showhold | grep -w "$BOARD") ]]; then
LIST+=( "Unhold" "Un-Freeze kernel and board support packages" )
else
LIST+=( "Hold" "Freeze kernel and board support packages" )
fi
[[ -n $(grep -w "#kernel.printk" /etc/sysctl.conf ) ]] && LIST+=( "Lowlevel" "Stop low-level messages on console" ) [[ -n $(grep -w "#kernel.printk" /etc/sysctl.conf ) ]] && LIST+=( "Lowlevel" "Stop low-level messages on console" )
[[ -f /boot/armbianEnv.txt ]] && LIST+=( "Bootenv" "Edit boot environment" ) [[ -f /boot/armbianEnv.txt ]] && LIST+=( "Bootenv" "Edit boot environment" )
[[ -f /boot/boot.ini ]] && LIST+=( "Bootscript" "Edit boot script" ) [[ -f /boot/boot.ini ]] && LIST+=( "Bootscript" "Edit boot script" )
LIST+=( "Services" "Toggle running services" )
[[ -d /boot/dtb/overlay && $LINUXFAMILY == sunxi && $BRANCH != default ]] && LIST+=( "Overlay" "Toggle board functions: UART, I2C, SPI, ..." )
LIST+=( "Welcome" "Toggle welcome screen items" ) LIST+=( "Welcome" "Toggle welcome screen items" )
if [[ -z $(apt-mark showhold | grep -w "$BOARD") ]]; then if [[ -z $(apt-mark showhold | grep -w "$BOARD") ]]; then
[[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w apt /etc/apt/sources.list.d/armbian.list) ]] \ [[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w apt /etc/apt/sources.list.d/armbian.list) ]] \
...@@ -442,15 +511,9 @@ while true; do ...@@ -442,15 +511,9 @@ while true; do
[[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w beta /etc/apt/sources.list.d/armbian.list) ]] \ [[ -f /etc/apt/sources.list.d/armbian.list ]] && [[ -n $(grep -w beta /etc/apt/sources.list.d/armbian.list) ]] \
&& LIST+=( "Stable" "Switch to stable builds" ) && LIST+=( "Stable" "Switch to stable builds" )
fi fi
[[ -d /boot/dtb/overlay && $LINUXFAMILY == sunxi && $BRANCH != default ]] && LIST+=( "Overlays" "Toggle board functions: UART, I2C, SPI, ..." )
[[ $(apt-cache search --names-only '^linux-'$(lsb_release -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \ [[ $(apt-cache search --names-only '^linux-'$(lsb_release -cs)'-root.*.'$BOARD'' | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' \
| wc -l) -gt 1 ]] && LIST+=( "Switch" "Switch to alternative kernels" ) | wc -l) -gt 1 ]] && LIST+=( "Switch" "Switch to alternative kernels" )
if [[ "$DISTRO" == "Ubuntu" && "$(modinfo overlay > /dev/null 2>&1; echo $?)" == "0" ]]; then
if [ -n "$(mount | grep -w tmpfs-root)" ]; then
LIST+=( "Overlayroot" "Disable virtual read-only root filesystem" )
else
LIST+=( "Overlayroot" "Enable virtual read-only root filesystem" )
fi
fi
# count number of menu items to adjust window sizee # count number of menu items to adjust window sizee
LISTLENGHT="$((11+${#LIST[@]}/2))" LISTLENGHT="$((11+${#LIST[@]}/2))"
...@@ -467,7 +530,7 @@ while true; do ...@@ -467,7 +530,7 @@ while true; do
DIALOG_ESC=255 DIALOG_ESC=255
exec 3>&1 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "Board and system settings" --clear \ selection=$(dialog --backtitle "$BACKTITLE" --title " Armbian specific settings " --clear \
--cancel-label "Back" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \ --cancel-label "Back" --menu "$disclaimer" $LISTLENGHT 70 $BOXLENGHT \
"${LIST[@]}" 2>&1 1>&3) "${LIST[@]}" 2>&1 1>&3)
exit_status=$? exit_status=$?
...@@ -475,4 +538,4 @@ while true; do ...@@ -475,4 +538,4 @@ while true; do
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
jobs "$selection" jobs "$selection"
done done
} }
\ No newline at end of file
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