Commit 085265ac authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Added SSHd configurator & many fixes.

parent a3b2ba2e
...@@ -7,12 +7,51 @@ ...@@ -7,12 +7,51 @@
# warranty of any kind, whether express or implied. # warranty of any kind, whether express or implied.
#-----------------------------------------------------------------------------------------------------------------------------------------#
# check for root
#
if [[ $EUID != 0 ]]; then
echo "Warning. This script requires root privileges. Exiting ..."
sleep 2
exit
fi
#-----------------------------------------------------------------------------------------------------------------------------------------#
# check if we have internet connection to install dependencies
#
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
read -n 1 -s -p "Warning. Configurator can't work properly without internet connection. \
Press CTRL C to stop to stop or any key to ignore and continue."
else
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' bc 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install bc
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' expect 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install expect
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' rcconf 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install rcconf
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dialog 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install dialog
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' network-manager 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install network-manager
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' sunxi-tools 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install sunxi-tools
fi
#-----------------------------------------------------------------------------------------------------------------------------------------#
# load functions # load functions
source "$0""-submenu" source "$0""-submenu"
source "$0""-jobs" source "$0""-jobs"
#-----------------------------------------------------------------------------------------------------------------------------------------#
# Main menu # Main menu
#
while true; do while true; do
LIST=() LIST=()
LIST+=( "Software" "System and 3rd party software install" ) LIST+=( "Software" "System and 3rd party software install" )
...@@ -21,9 +60,10 @@ while true; do ...@@ -21,9 +60,10 @@ while true; do
LIST+=( "Armbian" "Armbian specific: overlays, MOTD, loglevel" ) LIST+=( "Armbian" "Armbian specific: overlays, MOTD, loglevel" )
LIST+=( "Help" "Documentation, support, sources" ) LIST+=( "Help" "Documentation, support, sources" )
# count number of menu items to adjust window sizee # count number of menu items to adjust window size
LISTLENGHT="$((9+${#LIST[@]}/2))" LISTLENGHT="$((11+${#LIST[@]}/2))"
BOXLENGHT=${#LIST[@]} BOXLENGHT=${#LIST[@]}
MENUTITLE="Configuration tool for the \Z1${BOARD_NAME}\Z0 running \Z1$DISTRO $DISTROID\Z0"
# main dialog routine # main dialog routine
DIALOG_CANCEL=1 DIALOG_CANCEL=1
...@@ -31,13 +71,15 @@ while true; do ...@@ -31,13 +71,15 @@ while true; do
exec 3>&1 exec 3>&1
selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \ selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \
--cancel-label "Exit to shell" --menu "\nConfiguration tool for the \Z1${BOARD_NAME}\Z0 running \Z1$DISTRO $DISTROID\Z0 \n " $LISTLENGHT 70 $BOXLENGHT \ --cancel-label "Exit to shell" --menu "\n$MENUTITLE \n \nSupport: \Z1https://www.armbian.com\Z0\n " \
"${LIST[@]}" 2>&1 1>&3) $LISTLENGHT ${#MENUTITLE} $BOXLENGHT "${LIST[@]}" 2>&1 1>&3)
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && exit [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && exit
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection})) dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading ${selection,,} submodule ... " 5 $((26+${#selection}))
case $selection in case $selection in
"Software" ) "Software" )
...@@ -53,7 +95,12 @@ while true; do ...@@ -53,7 +95,12 @@ while true; do
submenu_hardware submenu_hardware
;; ;;
"Help" ) "Help" )
show_box "Info" "This tool provides a straightforward way of configuring the \Z2${BOARD_NAME}\Z0. \n \nAlthough it can be run at any time, some of the options may have difficulties if you alter system settings manually.\n\n\Z1Documentation:\Z0 https://docs.armbian.com\n\n\Z1Support:\Z0 https://forum.armbian.com\n\n\Z1Sources:\Z0 https://github.com/armbian/config" "18" show_box "Info" "This tool provides a straightforward way of configuring the \Z2${BOARD_NAME}\Z0. \
\n \nAlthough it can be run at any time, some of the options may have difficulties if you alter system settings manually.\n\
\n\Z1Documentation:\Z0 https://docs.armbian.com\n\n\Z1Support:\Z0 https://forum.armbian.com\n
\n\Z1Sources:\Z0 https://github.com/armbian/config" "18"
;; ;;
esac esac
done done
#-----------------------------------------------------------------------------------------------------------------------------------------#
\ No newline at end of file
...@@ -106,11 +106,19 @@ function jobs () ...@@ -106,11 +106,19 @@ function jobs ()
"Display" ) "Display" )
# show display modes menu # show display modes menu
get_h3modes get_h3modes
dialog --title " Display output type " --colors --help-button --help-label "Back" --no-label "DVI" --yes-label "HDMI" --backtitle "$BACKTITLE" --yesno "\nIn case you use an HDMI-to-DVI converter choose DVI!" 7 57 dialog --title " Display output type " --colors --help-button --help-label "Back" --no-label "DVI" --yes-label "HDMI" \
--backtitle "$BACKTITLE" --yesno "\nIn case you use an HDMI-to-DVI converter choose DVI!" 7 57
output_type=$? output_type=$?
if [[ $output_type = 0 || $output_type = 1 ]]; then if [[ $output_type = 0 || $output_type = 1 ]]; then
if [[ $output_type = 0 ]]; then display_cmd="h3disp -m $SCREEN_RESOLUTION"; else display_cmd="h3disp -m $SCREEN_RESOLUTION -d";fi
dialog --title " Display resolution " --colors --no-label "Back" --backtitle "$BACKTITLE" --yesno "\nSetting new screen mode.\n\nExecuting \Z1$display_cmd\Z0 and reboot? " 9 56 if [[ $output_type = 0 ]]; then
display_cmd="h3disp -m $SCREEN_RESOLUTION";
else
display_cmd="h3disp -m $SCREEN_RESOLUTION -d";
fi
dialog --title " Display resolution " --colors --no-label "Back" --backtitle "$BACKTITLE" --yesno \
"\nSetting new screen mode.\n\nExecuting \Z1$display_cmd\Z0 and reboot? " 9 56
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
eval $display_cmd > /dev/null eval $display_cmd > /dev/null
reboot reboot
...@@ -130,7 +138,9 @@ function jobs () ...@@ -130,7 +138,9 @@ function jobs ()
"IP" ) "IP" )
# select default interfaces if there is more than one # select default interfaces if there is more than one
select_default_interface 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 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
exitstatus=$?; exitstatus=$?;
if [[ $exitstatus = 0 ]]; then if [[ $exitstatus = 0 ]]; then
create_if_config "$DEFAULT_ADAPTER" "$DEFAULT_ADAPTER" "dynamic" > /etc/network/interfaces create_if_config "$DEFAULT_ADAPTER" "$DEFAULT_ADAPTER" "dynamic" > /etc/network/interfaces
...@@ -150,6 +160,7 @@ function jobs () ...@@ -150,6 +160,7 @@ function jobs ()
nmtui-connect nmtui-connect
;; ;;
# Connect to wireless access point # Connect to wireless access point
# #
"Clear" ) "Clear" )
...@@ -169,10 +180,14 @@ function jobs () ...@@ -169,10 +180,14 @@ function jobs ()
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
if [[ -n $HOSTAPDBRIDGE ]]; then if [[ -n $HOSTAPDBRIDGE ]]; then
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 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 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 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 fi
exitstatus=$?; exitstatus=$?;
if [[ $exitstatus = 0 ]]; then if [[ $exitstatus = 0 ]]; then
...@@ -215,7 +230,8 @@ function jobs () ...@@ -215,7 +230,8 @@ function jobs ()
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 3 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
# 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
...@@ -233,7 +249,8 @@ function jobs () ...@@ -233,7 +249,8 @@ function jobs ()
# #
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 if [[ -n "$CHECK" ]]; then
dialog --colors --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nWireless adapter: \Z1${WIRELESS_ADAPTER}\Z0\n\nProbing Realtek hostapd driver compatibility." 7 50 dialog --colors --backtitle "$BACKTITLE" --title "Please wait" --infobox \
"\nWireless adapter: \Z1${WIRELESS_ADAPTER}\Z0\n\nProbing Realtek hostapd driver compatibility." 7 50
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
...@@ -260,9 +277,15 @@ function jobs () ...@@ -260,9 +277,15 @@ function jobs ()
break break
fi fi
# dialog --title " Choose Access Point mode for $WIRELESS_ADAPTER " --colors --backtitle "$BACKTITLE" --no-label "Bridge" --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 # let's remove bridge out for this simple configurator
#
# dialog --title " Choose Access Point mode for $WIRELESS_ADAPTER " --colors --backtitle "$BACKTITLE" --no-label "Bridge" \
# --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
# response=$? # response=$?
# let's remove bridge for this simple configurator #
# let's remove bridge out for this simple configurator
response=0 response=0
# select default interfaces if there is more than one # select default interfaces if there is more than one
...@@ -287,8 +310,15 @@ function jobs () ...@@ -287,8 +310,15 @@ function jobs ()
# NAT # NAT
0) 0)
TEMP_CONF="/etc/network/interfaces.d/armbian.ap.nat" TEMP_CONF="/etc/network/interfaces.d/armbian.ap.nat"
if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dnsmasq 2>/dev/null) != *ii* ]]; then 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 # install dnsmas and iptables
if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dnsmasq 2>/dev/null) != *ii* ]]; then
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 "# 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 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
...@@ -360,13 +390,14 @@ function jobs () ...@@ -360,13 +390,14 @@ function jobs ()
"Advanced" ) "Advanced" )
dialog --backtitle "$BACKTITLE" --title " Edit ifupdown network configuration /etc/network/interfaces" --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 && service networking restart [[ $? = 0 ]] && mv /etc/network/interfaces.out /etc/network/interfaces && reload-nety "reload"
;; ;;
# Remove automatic wifi conections # Remove automatic wifi conections
# #
"Forget" ) "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 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
;; ;;
...@@ -423,7 +454,8 @@ function jobs () ...@@ -423,7 +454,8 @@ function jobs ()
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
debconf-apt-progress -- apt-get update debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get -y upgrade debconf-apt-progress -- apt-get -y upgrade
dialog --title " Firmware update " --colors --no-label "Back" --backtitle "$BACKTITLE" --yesno "\nFirmware has been updated. Reboot? " 7 39 dialog --title " Firmware update " --colors --no-label "Back" --backtitle "$BACKTITLE" --yesno \
"\nFirmware has been updated. Reboot? " 7 39
if [[ $? = 0 ]]; then reboot; fi if [[ $? = 0 ]]; then reboot; fi
fi fi
;; ;;
...@@ -439,7 +471,8 @@ function jobs () ...@@ -439,7 +471,8 @@ 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" --yesno "\nDo you want to ${1,,} kernel updates?" 7 50 dialog --title " Update " --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" --yesno \
"\nDo you want to ${1,,} kernel updates?" 7 50
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
TARGET_BRANCH=$BRANCH TARGET_BRANCH=$BRANCH
exceptions "$BRANCH" exceptions "$BRANCH"
...@@ -543,20 +576,18 @@ function jobs () ...@@ -543,20 +576,18 @@ function jobs ()
# #
"Overlays" ) "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" CHANGES="false"
if [[ -n $ACKNOWLEDGEMENT ]]; then while true; do
overlay_prefix=$(cat /boot/armbianEnv.txt | grep overlay_prefix | sed 's/overlay_prefix=//g') overlay_prefix=$(cat /boot/armbianEnv.txt | grep overlay_prefix | sed 's/overlay_prefix=//g')
TARGET_BRANCH=$BRANCH TARGET_BRANCH=$BRANCH
exceptions "$BRANCH" exceptions "$BRANCH"
while true; do
HOME="/boot/dtb/overlay" HOME="/boot/dtb/overlay"
MOTD=() MOTD=()
LINES=() LINES=()
LIST_CONST=2 LIST_CONST=-3
j=0 j=0
DIALOG_CANCEL=1 DIALOG_CANCEL=1
DIALOG_ESC=255 DIALOG_ESC=255
while read line while read line
do do
STATUS=$([[ -n $(cat /boot/armbianEnv.txt | grep overlays | grep -w ${line}) ]] && echo "on") STATUS=$([[ -n $(cat /boot/armbianEnv.txt | grep overlays | grep -w ${line}) ]] && echo "on")
...@@ -564,27 +595,40 @@ function jobs () ...@@ -564,27 +595,40 @@ function jobs ()
MOTD+=( "$line" "$DESC" "$STATUS") MOTD+=( "$line" "$DESC" "$STATUS")
LINES[ $j ]=$line LINES[ $j ]=$line
(( j++ )) (( j++ ))
done < <(ls -1 $HOME/${overlay_prefix}*.dtbo | sed 's/^.*\('${overlay_prefix}'.*\)/\1/g' | sed 's/'${overlay_prefix}'-//g' | sed 's/.dtbo//g' ) done < <(ls -1 ${HOME}/${overlay_prefix}*.dtbo | sed 's/^.*\('${overlay_prefix}'.*\)/\1/g' | sed 's/'${overlay_prefix}'-//g' | sed 's/.dtbo//g' )
LISTLENGHT="$(($LIST_CONST+${#MOTD[@]}/2))" LISTLENGHT="$(($LIST_CONST+${#MOTD[@]}/2))"
exec 3>&1 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title "Toggle hardware config" --clear --cancel-label \ selection=$(dialog --backtitle "$BACKTITLE" --title "Toggle hardware config" --clear --cancel-label \
"Exit" --ok-label "Save" --checklist "\nChoose what you want to enable or disable:\n " \ "Back" --ok-label "Save" --checklist "\nChoose what you want to enable or disable:\n " \
$LISTLENGHT 70 22 "${MOTD[@]}" 2>&1 1>&3) $LISTLENGHT 70 $LISTLENGHT "${MOTD[@]}" 2>&1 1>&3)
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
case $exit_status in case $exit_status in
$DIALOG_CANCEL | $DIALOG_ESC) $DIALOG_ESC)
break break
;; ;;
0) 0)
CHANGES="true"
newoverlays="$(echo "$selection" | sed "s|[^ ]* *|&|g")" newoverlays="$(echo "$selection" | sed "s|[^ ]* *|&|g")"
sed -i "s/^overlays=.*/overlays=$newoverlays/" /boot/armbianEnv.txt || cat "overlays=$newoverlays" >> /boot/armbianEnv.txt sed -i "s/^overlays=.*/overlays=$newoverlays/" /boot/armbianEnv.txt
if ! grep -q "overlays" /boot/armbianEnv.txt; then echo "overlays=$newoverlays" >> /boot/armbianEnv.txt; fi
if [[ -z $newoverlays ]]; then sed -i "/^overlays/d" /boot/armbianEnv.txt; fi
;;
1)
if [[ "$CHANGES" == "true" ]]; then
dialog --title " Applying changes " --backtitle "$BACKTITLE" --yes-label "Reboot" \
--no-label "Cancel" --yesno "\nReboot to enable new features?" 7 34
if [[ $? = 0 ]]; then reboot; else break; fi
else
break
fi
;; ;;
esac esac
done done
fi
;; ;;
...@@ -630,6 +674,60 @@ function jobs () ...@@ -630,6 +674,60 @@ function jobs ()
;; ;;
# Toggle sshd options
#
"SSHd" )
while true; do
DIALOG_CANCEL=1
DIALOG_ESC=255
LIST_CONST=8
PermitRootLogin="";
PubkeyAuthentication="";
X11Forwarding="";
[[ $(grep "^PermitRootLogin" /etc/ssh/sshd_config | awk '{print $2}') == "yes" ]] && PermitRootLogin="on"
[[ $(grep "^PubkeyAuthentication" /etc/ssh/sshd_config | awk '{print $2}') == "yes" ]] && PubkeyAuthentication="on"
[[ $(grep "^X11Forwarding" /etc/ssh/sshd_config | awk '{print $2}') == "yes" ]] && X11Forwarding="on"
MOTD=("X11Forwarding" "X11 forwarding" "$X11Forwarding" \
"PermitRootLogin" "Allow root login" "$PermitRootLogin" \
"PubkeyAuthentication" "Using public keys for SSH authentication" "$PubkeyAuthentication")
LISTLENGHT="$(($LIST_CONST+${#MOTD[@]}/2))"
exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title " Toggle sshd options " --clear --cancel-label \
"Exit" --ok-label "Save" --checklist "\nChoose what you want to enable or disable:\n " \
$LISTLENGHT 74 21 "${MOTD[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-
case $exit_status in
$DIALOG_CANCEL | $DIALOG_ESC)
break
;;
0)
# read values, adjust config and restart service
my_array=($selection)
for((n=0;n<${#MOTD[@]};n++)); do
if (( $(($n % 3 )) == 0 )); then
if [[ " ${my_array[*]} " == *" ${MOTD[$n]} "* ]]; then
sed -i "s/#\?${MOTD[$n]}.*/${MOTD[$n]} yes/" /etc/ssh/sshd_config
else
sed -i "s/#\?${MOTD[$n]}.*/${MOTD[$n]} no/" /etc/ssh/sshd_config
fi
fi
done
service sshd restart
;;
esac
done
;;
# Switch to daily builds # Switch to daily builds
# #
"Nightly" ) "Nightly" )
...@@ -668,7 +766,7 @@ function jobs () ...@@ -668,7 +766,7 @@ function jobs ()
# #
"Switch" ) "Switch" )
aval_kernel aval_kernel
[[ $exitstatus = 1 ]] && break if [[ $exitstatus = 0 ]]; then
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! \
...@@ -696,6 +794,7 @@ function jobs () ...@@ -696,6 +794,7 @@ function jobs ()
exitstatus=$?; exitstatus=$?;
[[ $exitstatus = 0 ]] && reboot [[ $exitstatus = 0 ]] && reboot
fi fi
fi
;; ;;
......
...@@ -7,37 +7,11 @@ ...@@ -7,37 +7,11 @@
# warranty of any kind, whether express or implied. # warranty of any kind, whether express or implied.
#-----------------------------------------------------------------------------------------------------------------------------------------# DIALOG_CANCEL=1
# check for root DIALOG_ESC=255
#
if [[ $EUID != 0 ]]; then
echo "Warning. This script requires root privileges. Exiting ..."
sleep 2
exit
fi
#-----------------------------------------------------------------------------------------------------------------------------------------#
# check if we have internet connection to install dependencies
#
echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
read -n 1 -s -p "Warning. Configurator can't work properly without internet connection. \
Press CTRL C to stop to stop or any key to ignore and continue."
else
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' bc 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install bc
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' expect 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install expect
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' rcconf 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install rcconf
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dialog 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install dialog
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' network-manager 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install network-manager
[[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' sunxi-tools 2>/dev/null) != *ii* ]] && \
apt-get -qq -y --no-install-recommends install sunxi-tools
fi
function check_advanced_modes () function check_advanced_modes ()
...@@ -613,6 +587,7 @@ while true; do ...@@ -613,6 +587,7 @@ while true; do
LIST+=( "Timezone" "Change timezone \Z5($(date +%Z))\Z0" ) LIST+=( "Timezone" "Change timezone \Z5($(date +%Z))\Z0" )
LIST+=( "Locales" "Reconfigure language \Z5($(locale | grep LANGUAGE | cut -d= -f2 | cut -d_ -f1))\Z0 and character set" ) LIST+=( "Locales" "Reconfigure language \Z5($(locale | grep LANGUAGE | cut -d= -f2 | cut -d_ -f1))\Z0 and character set" )
LIST+=( "Hostname" "Change your hostname \Z5($(cat /etc/hostname))\Z0" ) LIST+=( "Hostname" "Change your hostname \Z5($(cat /etc/hostname))\Z0" )
LIST+=( "SSHd" "Reconfigure SSH daemon" )
LIST+=( "Firmware" "Upgrade board firmware" ) LIST+=( "Firmware" "Upgrade board firmware" )
# check for display manager statuses # check for display manager statuses
...@@ -673,15 +648,18 @@ while true; do ...@@ -673,15 +648,18 @@ while true; do
done done
} }
#-----------------------------------------------------------------------------------------------------------------------------------------# #-----------------------------------------------------------------------------------------------------------------------------------------#
# menu for armbian # Armbian specific settings
# #
function submenu_hardware () function submenu_hardware ()
{ {
while true; do while true; do
LIST=() 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" )
[[ $(sed -n 's/^DEVNAME=//p' /sys/dev/block/$(mountpoint -d /)/uevent 2> /dev/null) == 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 if [[ -n $(apt-mark showhold | grep -w "$BOARD") ]]; then
LIST+=( "Unhold" "Un-Freeze kernel and board support packages" ) LIST+=( "Unhold" "Un-Freeze kernel and board support packages" )
else else
...@@ -697,23 +675,14 @@ while true; do ...@@ -697,23 +675,14 @@ 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 == sun*i && $BRANCH != default ]] && LIST+=( "Overlays" "Toggle board functions: UART, I2C, SPI, ..." ) [[ -d /boot/dtb/overlay && $LINUXFAMILY == sun*i && $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" )
# count number of menu items to adjust window sizee # 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))" LISTLENGHT="$((6+${#LIST[@]}/2))"
fi BOXLENGHT=${#LIST[@]}
DIALOG_CANCEL=1
DIALOG_ESC=255
exec 3>&1 exec 3>&1
selection=$(dialog --backtitle "$BACKTITLE" --title " Armbian specific settings " --clear \ selection=$(dialog --backtitle "$BACKTITLE" --title " Armbian specific settings " --clear \
...@@ -722,6 +691,9 @@ while true; do ...@@ -722,6 +691,9 @@ while true; do
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
[[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break [[ $exit_status == $DIALOG_CANCEL || $exit_status == $DIALOG_ESC ]] && clear && break
# run main function
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