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

Cleanup

parent 1059fe0a
...@@ -87,11 +87,13 @@ do ...@@ -87,11 +87,13 @@ do
[[ $(grep -c '^processor' /proc/cpuinfo) -gt 4 ]] && POLICY="policy4" [[ $(grep -c '^processor' /proc/cpuinfo) -gt 4 ]] && POLICY="policy4"
[[ ! -d /sys/devices/system/cpu/cpufreq/policy4 ]] && POLICY="policy0" [[ ! -d /sys/devices/system/cpu/cpufreq/policy4 ]] && POLICY="policy0"
num=$(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_min_freq 2> /dev/null) num=$(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_min_freq 2> /dev/null)
if [[ -f /etc/default/cpufrequtils && ! -z "${num##*[!0-9]*}" ]]; then if [[ -f /etc/default/cpufrequtils && ! -z "${num##*[!0-9]*}" ]]; then
FREQENCIES="\n"$(LC_ALL="C" cpufreq-info | grep policy | sed "s/ current policy: //" | sed 's/.*/\u&/' | tail -1)"\n"
LISTLENGTH=$((LISTLENGTH + 2)) LISTLENGTH=$((LISTLENGTH + 2))
FREQENCIES="\nSoC runs between \Z1$(($(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_min_freq) / 1000))\Z0 and \Z1$(($(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_max_freq) / 1000)) MHz\Z0 using \Z1$(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_governor)\Z0 governor.\n" MIN_CPU=$(($(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_min_freq) / 1000))
fi MAX_CPU=$(($(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_max_freq) / 1000))
GOVERNOR_CPU=$(cat /sys/devices/system/cpu/cpufreq/$POLICY/scaling_governor)
FREQENCIES="\nSoC runs between \Z1${MIN_CPU}\Z0 and \Z1${MAX_CPU} MHz\Z0 using \Z1${GOVERNOR_CPU}\Z0 governor.\n"
fi
[[ -n "${BOARD_NAME/ /}" ]] && MENUTITLE=$MENUTITLE" based \Z1Armbian\Z0 for the \Z1${BOARD_NAME}\Z0 " [[ -n "${BOARD_NAME/ /}" ]] && MENUTITLE=$MENUTITLE" based \Z1Armbian\Z0 for the \Z1${BOARD_NAME}\Z0 "
......
...@@ -58,38 +58,41 @@ function main(){ ...@@ -58,38 +58,41 @@ function main(){
# #
# compare two strings in dot separated version format # compare two strings in dot separated version format
# #
vercomp () { vercomp () {
if [[ $1 == $2 ]]
then if [[ $1 == $2 ]]
return 0 then
fi return 0
local IFS=. fi
local i ver1=($1) ver2=($2) local IFS=.
# fill empty fields in ver1 with zeros local i ver1=($1) ver2=($2)
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) # fill empty fields in ver1 with zeros
do for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
ver1[i]=0 do
done ver1[i]=0
for ((i=0; i<${#ver1[@]}; i++)) done
do for ((i=0; i<${#ver1[@]}; i++))
if [[ -z ${ver2[i]} ]] do
then if [[ -z ${ver2[i]} ]]
# fill empty fields in ver2 with zeros then
ver2[i]=0 # fill empty fields in ver2 with zeros
fi ver2[i]=0
if ((10#${ver1[i]} > 10#${ver2[i]})) fi
then if ((10#${ver1[i]} > 10#${ver2[i]}))
return 1 then
fi return 1
if ((10#${ver1[i]} < 10#${ver2[i]})) fi
then if ((10#${ver1[i]} < 10#${ver2[i]}))
return 2 then
fi return 2
done fi
return 0 done
return 0
} }
...@@ -99,18 +102,20 @@ vercomp () { ...@@ -99,18 +102,20 @@ vercomp () {
# test compare two strings $1="3.4.12" $2="5.4.2" $3="<" returns 0 if relation is correct # test compare two strings $1="3.4.12" $2="5.4.2" $3="<" returns 0 if relation is correct
# #
testvercomp () { testvercomp () {
vercomp $1 $2
case $? in vercomp $1 $2
0) op='=';; case $? in
1) op='>';; 0) op='=';;
2) op='<';; 1) op='>';;
esac 2) op='<';;
if [[ $op != $3 ]] esac
then if [[ $op != $3 ]]
then
return 1 return 1
else else
return 0 return 0
fi fi
} }
...@@ -121,13 +126,15 @@ testvercomp () { ...@@ -121,13 +126,15 @@ testvercomp () {
# #
function check_desktop() function check_desktop()
{ {
DISPLAY_MANAGER=""; DESKTOP_INSTALLED=""
check_if_installed nodm && DESKTOP_INSTALLED="nodm"; DISPLAY_MANAGER=""; DESKTOP_INSTALLED=""
check_if_installed lightdm && DESKTOP_INSTALLED="lightdm"; check_if_installed nodm && DESKTOP_INSTALLED="nodm";
check_if_installed lightdm && DESKTOP_INSTALLED="gnome"; check_if_installed lightdm && DESKTOP_INSTALLED="lightdm";
[[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm" check_if_installed lightdm && DESKTOP_INSTALLED="gnome";
[[ -n $(service nodm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="nodm" [[ -n $(service lightdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="lightdm"
[[ -n $(service gdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="gdm" [[ -n $(service nodm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="nodm"
[[ -n $(service gdm status 2> /dev/null | grep -w active) ]] && DISPLAY_MANAGER="gdm"
} }
...@@ -171,6 +178,7 @@ check_if_installed (){ ...@@ -171,6 +178,7 @@ check_if_installed (){
else else
return 0 return 0
fi fi
} }
...@@ -196,31 +204,38 @@ function is_package_manager_running() { ...@@ -196,31 +204,38 @@ function is_package_manager_running() {
# #
# wget with dialog progress bar $1=URL $2=parameters # wget with dialog progress bar $1=URL $2=parameters
# #
function fancy_wget() function fancy_wget()
{ {
LANG=C wget $2 --progress=bar:force:noscroll $1 2>&1 | stdbuf -i0 -o0 -e0 tr '>' '\n' | \
stdbuf -i0 -o0 -e0 sed -rn 's/^.*\<([0-9]+)%\[.*$/\1/p' | dialog --backtitle "$BACKTITLE" --title " Downloading " \ LANG=C wget $2 --progress=bar:force:noscroll $1 2>&1 | stdbuf -i0 -o0 -e0 tr '>' '\n' | \
--gauge "Please wait" 7 70 0 stdbuf -i0 -o0 -e0 sed -rn 's/^.*\<([0-9]+)%\[.*$/\1/p' | dialog --backtitle "$BACKTITLE" --title " Downloading " \
--gauge "Please wait" 7 70 0
} }
# #
# display qr code for authentication method # display qr code for authentication method
# #
function display_qr_code() function display_qr_code()
{ {
clear clear
SECRET=$(head -1 /root/.google_authenticator) SECRET=$(head -1 /root/.google_authenticator)
qrencode -m 2 -d 9 -8 -t ANSI256 "otpauth://totp/test?secret=$SECRET" qrencode -m 2 -d 9 -8 -t ANSI256 "otpauth://totp/test?secret=$SECRET"
echo -e "\nSetting up your OTP-generator\ echo -e "\nHow to setup your one type password generator?\n"
\nInstall a one-time password authenticator on your mobile device (e.g. FreeOTP) from the Android market or F-Droid.\ echo -e "\nInstall a one-time password authenticator on your mobile device (e.g. FreeOTP) from the Android \
\nIn the application menu, click the corresponding button to create a new account and either scan the QR code or enter the secret key manually:\ market or F-Droid. \n\nIn the application menu, click the corresponding button to create a new account and either \
\n\n$SECRET \n\nYou should now see a new passcode token being generated every 60 seconds on your phone.\n" | fold -sw 38 scan the QR code or enter the secret key manually:\\n\n$SECRET \n\nYou should now see a new passcode token being \
generated every 60 seconds on your phone.\n" | fold -sw 60
read -n 1 -s -r -p "Press any key to continue" read -n 1 -s -r -p "Press any key to continue"
} }
...@@ -231,10 +246,12 @@ function display_qr_code() ...@@ -231,10 +246,12 @@ function display_qr_code()
# #
function beta_disclaimer () function beta_disclaimer ()
{ {
exec 3>&1
ACKNOWLEDGEMENT=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse --title " Warning " \ exec 3>&1
--clear \--radiolist "\n$1\n \n" 11 56 5 "Yes, I understand" "" off 2>&1 1>&3) ACKNOWLEDGEMENT=$(dialog --colors --nocancel --backtitle "$BACKTITLE" --no-collapse --title " Warning " \
exec 3>&- --clear \--radiolist "\n$1\n \n" 0 56 5 "Yes, I understand" "" off 2>&1 1>&3)
exec 3>&-
} }
...@@ -245,7 +262,9 @@ exec 3>&- ...@@ -245,7 +262,9 @@ exec 3>&-
# #
function show_box () function show_box ()
{ {
dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " $1 " --clear --msgbox "\n$2\n \n" $3 56 dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " $1 " --clear --msgbox "\n$2\n \n" $3 56
} }
...@@ -333,64 +352,81 @@ function generic_select() ...@@ -333,64 +352,81 @@ function generic_select()
# #
function kernel_desc () function kernel_desc ()
{ {
[[ "$1" == "dev" ]] && echo "development, unstable"
[[ "$1" == "next" ]] && echo "mainline or 2nd generation" [[ "$1" == "dev" ]] && echo "development, unstable"
[[ "$1" == "default" ]] && echo "legacy, stock, 1st build" [[ "$1" == "next" ]] && echo "mainline or 2nd generation"
[[ "$1" == "default" ]] && echo "legacy, stock, 1st build"
} }
# #
# reload kernel, bsp and armbian-config # reload kernel, bsp and armbian-config
# #
function reload_bsp(){ function reload_bsp(){
debconf-apt-progress -- apt-get update
# test install packages debconf-apt-progress -- apt-get update
TARGET_BRANCH=$BRANCH # test install packages
exceptions "$INSTALL_KERNEL" TARGET_BRANCH=$BRANCH
exceptions "$INSTALL_KERNEL"
unset PACKAGE_LIST unset PACKAGE_LIST
[[ -n $(apt-cache search --names-only "^armbian-${LINUXFAMILY}$") ]] && PACKAGE_LIST=$PACKAGE_LIST" armbian-${LINUXFAMILY}" [[ -n $(apt-cache search --names-only "^armbian-${LINUXFAMILY}$") ]] && \
[[ -n $(apt-cache search --names-only "^armbian-${BOARD}$") ]] && PACKAGE_LIST=$PACKAGE_LIST" armbian-${BOARD}" PACKAGE_LIST=$PACKAGE_LIST" armbian-${LINUXFAMILY}"
[[ -n $(apt-cache search --names-only "^armbian-${DISTROID}$") ]] && PACKAGE_LIST=$PACKAGE_LIST" armbian-${DISTROID}" [[ -n $(apt-cache search --names-only "^armbian-${BOARD}$") ]] && \
[[ -n $(apt-cache search --names-only "^armbian-${DISTROID}-desktop-xfce$") ]] && PACKAGE_LIST=$PACKAGE_LIST" armbian-${DISTROID}-desktop-xfce" PACKAGE_LIST=$PACKAGE_LIST" armbian-${BOARD}"
[[ -n $(apt-cache search --names-only "^armbian-${DISTROID}$") ]] && \
PACKAGE_LIST=$PACKAGE_LIST" armbian-${DISTROID}"
[[ -n $(apt-cache search --names-only "^armbian-${DISTROID}-desktop-xfce$") ]] && \
PACKAGE_LIST=$PACKAGE_LIST" armbian-${DISTROID}-desktop-xfce"
# if new packages are absent, reinstall old ones # if new packages are absent, reinstall old ones
if [[ -z $PACKAGE_LIST ]]; then if [[ -z $PACKAGE_LIST ]]; then
PACKAGE_LIST="linux-${DISTROID}-root$TARGET_BRANCH-$BOARD" PACKAGE_LIST="linux-${DISTROID}-root$TARGET_BRANCH-$BOARD"
check_if_installed armbian-${DISTROID}-desktop && PACKAGE_LIST=$PACKAGE_LIST" armbian-${DISTROID}-desktop" check_if_installed armbian-${DISTROID}-desktop && PACKAGE_LIST=$PACKAGE_LIST" armbian-${DISTROID}-desktop"
fi fi
# reinstall headers only if they are already installed # reinstall headers only if they are already installed
check_if_installed linux-headers${TARGET_BRANCH}-${TARGET_FAMILY} && PACKAGE_LIST=$PACKAGE_LIST" linux-headers${TARGET_BRANCH}-${TARGET_FAMILY}" check_if_installed linux-headers${TARGET_BRANCH}-${TARGET_FAMILY} && \
PACKAGE_LIST=$PACKAGE_LIST" linux-headers${TARGET_BRANCH}-${TARGET_FAMILY}"
IFS=" " IFS=" "
[[ -n $(apt-cache search --names-only "^linux-dtb$TARGET_BRANCH-$TARGET_FAMILY") ]] && PACKAGE_LIST=$PACKAGE_LIST" linux-dtb$TARGET_BRANCH-$TARGET_FAMILY" [[ -n $(apt-cache search --names-only "^linux-dtb$TARGET_BRANCH-$TARGET_FAMILY") ]] && \
PACKAGE_LIST=$PACKAGE_LIST" linux-dtb$TARGET_BRANCH-$TARGET_FAMILY"
PACKAGE_LIST=$PACKAGE_LIST" linux-image${TARGET_BRANCH}-${TARGET_FAMILY}" PACKAGE_LIST=$PACKAGE_LIST" linux-image${TARGET_BRANCH}-${TARGET_FAMILY}"
debconf-apt-progress -- apt --download-only --allow-downgrades -y --no-install-recommends install $PACKAGE_LIST armbian-config debconf-apt-progress -- apt --download-only --allow-downgrades -y --no-install-recommends \
# if download is ok, remove old packages install $PACKAGE_LIST armbian-config
if [[ $? = 0 ]]; then # if download is ok, remove old packages
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel ..." 5 36 if [[ $? = 0 ]]; then
aptitude remove ~nlinux-image*${LINUXFAMILY} --quiet=100 -y >> /var/log/upgrade.log 2>&1 dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel ..." 5 36
aptitude remove ~nlinux-dtb --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~nlinux-image*${LINUXFAMILY} --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~nlinux-headers --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~nlinux-dtb --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~nlinux-${DISTROID}-root --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~nlinux-headers --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~narmbian-config --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~nlinux-${DISTROID}-root --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~narmbian-config --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~narmbian-${LINUXFAMILY} --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~narmbian-${LINUXFAMILY} --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~narmbian-${BOARD} --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~narmbian-${BOARD} --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~narmbian-${DISTROID} --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~narmbian-${DISTROID} --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~narmbian-${DISTROID}-desktop --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~narmbian-${DISTROID}-desktop --quiet=100 -y >> /var/log/upgrade.log 2>&1
aptitude remove ~narmbian-${DISTROID}-desktop-xfce --quiet=100 -y >> /var/log/upgrade.log 2>&1 aptitude remove ~narmbian-${DISTROID}-desktop-xfce --quiet=100 -y >> /var/log/upgrade.log 2>&1
# install packages # install packages
echo $PACKAGE_LIST >> /var/log/upgrade.log echo $PACKAGE_LIST >> /var/log/upgrade.log
debconf-apt-progress -- apt -y -qq --allow-downgrades --no-install-recommends --reinstall -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install $PACKAGE_LIST armbian-config debconf-apt-progress -- apt -y -qq --allow-downgrades --no-install-recommends --reinstall \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install $PACKAGE_LIST armbian-config
# clean apt cache # clean apt cache
apt clean apt clean
if [[ $? = 1 ]]; then if [[ $? = 1 ]]; then
echo "Something went wrong ... check logs."; exit; echo "Something went wrong ... check logs."; exit;
else else
reboot reboot
fi fi
fi fi
} }
function other_kernel_version () function other_kernel_version ()
{ {
...@@ -403,17 +439,18 @@ function other_kernel_version () ...@@ -403,17 +439,18 @@ function other_kernel_version ()
# check what is available from the repository # check what is available from the repository
debconf-apt-progress -- apt-get update debconf-apt-progress -- apt-get update
LIST=($(apt-cache show linux-image*${LINUXFAMILY} | grep -E "Package:|Version:|version:" | grep -v "Config-Version" | sed -n -e 's/^.*: //p' | sed 's/\.$//g')) LIST=($(apt-cache show linux-image*${LINUXFAMILY} | grep -E "Package:|Version:|version:" \
| grep -v "Config-Version" | sed -n -e 's/^.*: //p' | sed 's/\.$//g'))
new_list=() new_list=()
# create a human readable menu # create a human readable menu
for ((n=0;n<$((${#LIST[@]}));n++)); for ((n=0;n<$((${#LIST[@]}));n++));
do do
m=$(( $n + 1 )) m=$(( $n + 1 ))
prvi=$((3*$m - 3)) prvi=$((3*$m - 3))
drugi=$((3*$m - 2)) drugi=$((3*$m - 2))
tretji=$((3*$m - 1)) tretji=$((3*$m - 1))
[[ -z ${LIST[$prvi]} ]] && break [[ -z ${LIST[$prvi]} ]] && break
if [[ $CURRENT_VERSION != "${LIST[$prvi]}=${LIST[$drugi]}" ]]; then if [[ $CURRENT_VERSION != "${LIST[$prvi]}=${LIST[$drugi]}" ]]; then
new_list+=( "${LIST[$prvi]}=${LIST[$drugi]}" ) new_list+=( "${LIST[$prvi]}=${LIST[$drugi]}" )
new_list+=( ${LIST[$tretji]} ) new_list+=( ${LIST[$tretji]} )
...@@ -426,12 +463,14 @@ function other_kernel_version () ...@@ -426,12 +463,14 @@ function other_kernel_version ()
if [ "$LIST_LENGTH" -eq 0 ]; then if [ "$LIST_LENGTH" -eq 0 ]; then
dialog --backtitle "$BACKTITLE" --title " Warning " --msgbox "\nNo other kernels available!" 7 32 dialog --backtitle "$BACKTITLE" --title " Warning " --msgbox "\nNo other kernels available!" 7 32
else else
beta_disclaimer "Switching between kernels might change functionality of your board or it might fail to boot." beta_disclaimer "Switching between kernels might change functionality of your board or it might fail to boot. \
\n\n\Z1In case of troubles expect no help!\Z0"
if [[ -n $ACKNOWLEDGEMENT ]]; then if [[ -n $ACKNOWLEDGEMENT ]]; then
exec 3>&1 exec 3>&1
TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \ TARGET_VERSION=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \
--title "Switch from and reboot" --clear --menu "\n${CURRENT_VERSION} $(uname -r) \n \n" $((9+${LIST_LENGTH})) 62 25 "${LIST[@]}" 2>&1 1>&3) --title "Switch from and reboot" --clear --menu "\n${CURRENT_VERSION} $(uname -r) \n \n" \
$((9+${LIST_LENGTH})) 62 25 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?; exitstatus=$?;
exec 3>&- exec 3>&-
if [[ $exitstatus = 0 ]]; then if [[ $exitstatus = 0 ]]; then
...@@ -441,9 +480,11 @@ function other_kernel_version () ...@@ -441,9 +480,11 @@ function other_kernel_version ()
TARGET_VERSION_DTB=${TARGET_VERSION/image/dtb} TARGET_VERSION_DTB=${TARGET_VERSION/image/dtb}
TARGET_VERSION_PRE=$(echo $TARGET_VERSION_DTB | cut -f1 -d"=") TARGET_VERSION_PRE=$(echo $TARGET_VERSION_DTB | cut -f1 -d"=")
TARGET_VERSION_SUB=$(echo $TARGET_VERSION_DTB | cut -f2 -d"=") TARGET_VERSION_SUB=$(echo $TARGET_VERSION_DTB | cut -f2 -d"=")
[[ -n $(apt-cache madison "$TARGET_VERSION_PRE" | grep $TARGET_VERSION_SUB ) ]] && PACKAGE_LIST=$PACKAGE_LIST" $TARGET_VERSION_DTB" [[ -n $(apt-cache madison "$TARGET_VERSION_PRE" | grep $TARGET_VERSION_SUB ) ]] && \
PACKAGE_LIST=$PACKAGE_LIST" $TARGET_VERSION_DTB"
echo $PACKAGE_LIST > /tmp/switch_kernel.log 2>&1 echo $PACKAGE_LIST > /tmp/switch_kernel.log 2>&1
debconf-apt-progress -- apt --download-only --allow-downgrades -y --no-install-recommends install $PACKAGE_LIST debconf-apt-progress -- apt --download-only --allow-downgrades -y \
--no-install-recommends install $PACKAGE_LIST
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
# remove old kernel # remove old kernel
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel ..." 5 36 dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel ..." 5 36
...@@ -463,7 +504,8 @@ function other_kernel_version () ...@@ -463,7 +504,8 @@ function other_kernel_version ()
apt clean apt clean
if [[ $? = 0 ]]; then reboot; fi if [[ $? = 0 ]]; then reboot; fi
else else
dialog --backtitle "$BACKTITLE" --title "Warning" --msgbox "\nTest install failed. Can't change firmware \n\nCheck /tmp/switch_kernel.log" 9 48 dialog --backtitle "$BACKTITLE" --title "Warning" --msgbox \
"\nTest install failed. Can't change firmware \n\nCheck /tmp/switch_kernel.log" 9 48
fi fi
fi fi
fi fi
...@@ -472,6 +514,7 @@ function other_kernel_version () ...@@ -472,6 +514,7 @@ function other_kernel_version ()
# #
# check if board has alternative kernels # check if board has alternative kernels
# #
...@@ -497,7 +540,8 @@ function aval_dtbs () ...@@ -497,7 +540,8 @@ function aval_dtbs ()
else else
exec 3>&1 exec 3>&1
TARGET_BOARD=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \ TARGET_BOARD=$(dialog --cancel-label "Cancel" --backtitle "$BACKTITLE" --no-collapse \
--title "Select optimised board configuration" --clear --menu "" $((6+${LIST_LENGTH})) ${width} 25 "${LIST[@]}" 2>&1 1>&3) --title "Select optimised board configuration" --clear --menu \
"" $((6+${LIST_LENGTH})) ${width} 25 "${LIST[@]}" 2>&1 1>&3)
exitstatus=$?; exitstatus=$?;
exec 3>&- exec 3>&-
fi fi
...@@ -529,7 +573,8 @@ function get_a20modes () ...@@ -529,7 +573,8 @@ function get_a20modes ()
else else
exec 3>&1 exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu "" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3) --title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
...@@ -560,7 +605,8 @@ function get_odroidmodes () ...@@ -560,7 +605,8 @@ function get_odroidmodes ()
else else
exec 3>&1 exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu "" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3) --title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
...@@ -591,7 +637,8 @@ function get_h3modes () ...@@ -591,7 +637,8 @@ function get_h3modes ()
else else
exec 3>&1 exec 3>&1
SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \ SCREEN_RESOLUTION=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse \
--title "Select video mode" --clear --menu "" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3) --title "Select video mode" --clear --menu \
"" $((6+${LIST_LENGTH})) 25 $((1+${LIST_LENGTH})) "${LIST[@]}" 2>&1 1>&3)
exec 3>&- exec 3>&-
fi fi
...@@ -613,12 +660,13 @@ function add_choose_user () ...@@ -613,12 +660,13 @@ function add_choose_user ()
local LIST=() local LIST=()
for i in "${USERS[@]}" for i in "${USERS[@]}"
do do
LIST+=( "${i[0]//[[:blank:]]/}" "" ) LIST+=( "${i[0]//[[:blank:]]/}" "" )
done done
LIST_LENGTH=$((${#LIST[@]}/2)); LIST_LENGTH=$((${#LIST[@]}/2));
if [ "$LIST_LENGTH" -eq 0 ]; then if [ "$LIST_LENGTH" -eq 0 ]; then
dialog --backtitle "$BACKTITLE" --title " Notice " --msgbox "\nWe didn't find any unprivileged user with sudo rights which is required to run this service.\ dialog --backtitle "$BACKTITLE" --title " Notice " --msgbox \
"\nWe didn't find any unprivileged user with sudo rights which is required to run this service.\
\n\nPress enter to create one!" 10 48 \n\nPress enter to create one!" 10 48
read -t 0 temp read -t 0 temp
echo -e "\nPlease provide a username (eg. your forename) or leave blank for canceling user creation: \c" echo -e "\nPlease provide a username (eg. your forename) or leave blank for canceling user creation: \c"
...@@ -647,17 +695,18 @@ function add_choose_user () ...@@ -647,17 +695,18 @@ function add_choose_user ()
function google_token_allusers () function google_token_allusers ()
{ {
if [[ -f /root/.google_authenticator ]]; then if [[ -f /root/.google_authenticator ]]; then
local USERS=($(awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd)) local USERS=($(awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd))
for i in "${USERS[@]}" for i in "${USERS[@]}"
do do
USER=${i[0]//[[:blank:]]/} USER=${i[0]//[[:blank:]]/}
if [[ -d /home/$USER ]]; then if [[ -d /home/$USER ]]; then
cp /root/.google_authenticator /home/$USER/ cp /root/.google_authenticator /home/$USER/
chown ${USER}:${USER} /home/${USER}/.google_authenticator chown ${USER}:${USER} /home/${USER}/.google_authenticator
fi fi
done done
fi fi
} }
...@@ -682,11 +731,14 @@ function configure_desktop () ...@@ -682,11 +731,14 @@ function configure_desktop ()
# remove desktop package to secure proper install # remove desktop package to secure proper install
if check_if_installed armbian-${DISTROID}-desktop ; then if check_if_installed armbian-${DISTROID}-desktop ; then
debconf-apt-progress -- apt-get -y remove armbian-${DISTROID}-desktop${PACKAGE_SUFIX} lightdm lightdm-gtk-greeter debconf-apt-progress -- apt-get -y \
remove armbian-${DISTROID}-desktop${PACKAGE_SUFIX} lightdm lightdm-gtk-greeter
fi fi
# install desktop package # install desktop package
debconf-apt-progress -- apt-get --reinstall -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y install $1 armbian-${DISTROID}-desktop${PACKAGE_SUFIX} lightdm lightdm-gtk-greeter debconf-apt-progress -- apt-get --reinstall -o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" -y \
install $1 armbian-${DISTROID}-desktop${PACKAGE_SUFIX} lightdm lightdm-gtk-greeter
# in case previous install was interrupted # in case previous install was interrupted
[[ $? -eq 130 ]] && dpkg --configure -a [[ $? -eq 130 ]] && dpkg --configure -a
...@@ -699,7 +751,8 @@ function configure_desktop () ...@@ -699,7 +751,8 @@ function configure_desktop ()
usermod -aG ${additionalgroup} ${CHOSEN_USER} 2>/dev/null usermod -aG ${additionalgroup} ${CHOSEN_USER} 2>/dev/null
done done
# Prevent loading paralel printer port drivers which we don't need here.Suppress boot error if kernel modules are absent # Prevent loading paralel printer port drivers which we don't need here.
# suppress boot error if kernel modules are absent
if [[ -f /etc/modules-load.d/cups-filters.conf ]]; then if [[ -f /etc/modules-load.d/cups-filters.conf ]]; then
sed "s/^lp/#lp/" -i /etc/modules-load.d/cups-filters.conf sed "s/^lp/#lp/" -i /etc/modules-load.d/cups-filters.conf
sed "s/^ppdev/#ppdev/" -i /etc/modules-load.d/cups-filters.conf sed "s/^ppdev/#ppdev/" -i /etc/modules-load.d/cups-filters.conf
......
...@@ -94,15 +94,15 @@ while true; do ...@@ -94,15 +94,15 @@ while true; do
fi fi
else else
if [[ -n $DESKTOP_INSTALLED ]]; then if [[ -n $DESKTOP_INSTALLED ]]; then
LIST+=( "Desktop" "Enable desktop" ) LIST+=( "Desktop" "Enable desktop" )
if ! check_if_installed mpv ; then if ! check_if_installed mpv ; then
LIST+=( "Default" "Install desktop with browser and extras" ) LIST+=( "Default" "Install desktop with browser and extras" )
fi fi
else else
LIST+=( "Minimal" "Install minimal desktop" ) LIST+=( "Minimal" "Install minimal desktop" )
if ! check_if_installed mpv ; then if ! check_if_installed mpv ; then
LIST+=( "Default" "Install desktop with browser and extras" ) LIST+=( "Default" "Install desktop with browser and extras" )
fi fi
fi fi
fi fi
...@@ -129,8 +129,10 @@ while true; do ...@@ -129,8 +129,10 @@ while true; do
tag_key_selected_color = (WHITE,RED,ON) tag_key_selected_color = (WHITE,RED,ON)
EOF EOF
[[ -n ${mark} ]] && local sys_title=" Warning - firmware packages frozen" [[ -n ${mark} ]] && local sys_title=" Warning - firmware packages frozen"
[[ -n $(grep -w beta /etc/apt/sources.list.d/armbian.list 2> /dev/null) ]] && local sys_title=" Warning - attached to beta repository" [[ -n $(grep -w beta /etc/apt/sources.list.d/armbian.list 2> /dev/null) ]] && \
[[ -n ${mark} && -n $(grep -w beta /etc/apt/sources.list.d/armbian.list 2> /dev/null) ]] && sys_title=" Warning - frozen & attached to beta repository" local sys_title=" Warning - attached to beta repository"
[[ -n ${mark} && -n $(grep -w beta /etc/apt/sources.list.d/armbian.list 2> /dev/null) ]] && \
sys_title=" Warning - frozen & attached to beta repository"
else else
local sys_title=" System settings " local sys_title=" System settings "
echo > $temp_rc echo > $temp_rc
...@@ -182,7 +184,8 @@ while true; do ...@@ -182,7 +184,8 @@ while true; do
HOSTAPDCLIENTS=$(hostapd_cli all_sta 2> /dev/null | grep connected_time | wc -l) HOSTAPDCLIENTS=$(hostapd_cli all_sta 2> /dev/null | grep connected_time | wc -l)
LIST+=( "Hotspot" "Manage active wireless access point" ) LIST+=( "Hotspot" "Manage active wireless access point" )
else else
[[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep wifi | grep -w disconnected) ]] && LIST+=( "Hotspot" "Create WiFi access point" ) [[ -n $(LC_ALL=C nmcli device status 2> /dev/null | grep wifi | grep -w disconnected) ]] && \
LIST+=( "Hotspot" "Create WiFi access point" )
fi fi
...@@ -297,7 +300,9 @@ done ...@@ -297,7 +300,9 @@ done
} }
#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# personal # personal
# #
function submenu_personal () function submenu_personal ()
...@@ -333,7 +338,9 @@ done ...@@ -333,7 +338,9 @@ done
} }
#-----------------------------------------------------------------------------------------------------------------------------------------#
#
# software # software
# #
function submenu_software () function submenu_software ()
......
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