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

Add option to switch between avaliable kernels - will work properly from next...

Add option to switch between avaliable kernels - will work properly from next release or nightly builds. Tested: sun8 and few sun7 ... still need some fixing and testing for others
parent 30fbed76
......@@ -44,12 +44,48 @@ fi
}
}
function exceptions ()
{
TARGET_FAMILY=$LINUXFAMILY
UBOOT_BRANCH=$TARGET_BRANCH # uboot naming is different
case $BOARD in
cubietruck | cubieboard2 | bananapipro | lamobo-r1 | orangepi | orangepimini | lime | lime2 | micro | lime2emmc | pcduino3 | pcduino3nano)
if [[ $TARGET_BRANCH == "default" ]]; then TARGET_FAMILY="sun7i"; TARGET_BRANCH=""; else TARGET_FAMILY="sunxi"; TARGET_BRANCH="-"$TARGET_BRANCH; fi
;;
cubieboard | lime-a10 | pcduino2)
if [[ $TARGET_BRANCH == "default" ]]; then TARGET_FAMILY="sun4i"; TARGET_BRANCH=""; else TARGET_FAMILY="sunxi"; TARGET_BRANCH="-"$TARGET_BRANCH; fi
;;
*)
if [[ $TARGET_BRANCH == "default" ]]; then TARGET_BRANCH=""; else TARGET_BRANCH="-"$TARGET_BRANCH; fi
esac
}
function wlan_exceptions ()
{
[[ -n "$(lsmod | grep -w dhd)" && $1 = "on" ]] && echo 'options dhd op_mode=2' >/etc/modprobe.d/ap6212.conf && rmmod dhd && modprobe dhd
[[ -n "$(lsmod | grep -w dhd)" && $1 = "off" ]] && rm /etc/modprobe.d/ap6212.conf && rmmod dhd && modprobe dhd
}
function aval_kernel ()
{
IFS=$'\r\n'
GLOBIGNORE='*'
AVAL_KERNEL=($(apt-cache search --names-only '^linux-'$(lsb_release -cs)'-root.*.'$BOARD'*' | grep -w "$BOARD " | sed 's/.*(\(.*\))/\1/' | awk '{print $1}' | grep -v "$BRANCH" ))
local LIST=()
for i in "${AVAL_KERNEL[@]}"
do
LIST+=( "${i[0]//[[:blank:]]/}" "" )
done
LIST_LENGHT=$((${#LIST[@]}/2));
if [ "$LIST_LENGHT" -eq 1 ]; then
TARGET_BRANCH=${AVAL_KERNEL[0]}
else
exec 3>&1
TARGET_BRANCH=$(dialog --nocancel --backtitle "$BACKTITLE" --no-collapse --title "Upgrade from $BRANCH to:" --clear --menu "" $((6+${LIST_LENGHT})) 40 15 "${LIST[@]}" 2>&1 1>&3)
exec 3>&-
fi
}
function get_wlan_interface ()
{
# search for wlan interfaces and provide a selection menu if there are more than one
......@@ -78,6 +114,7 @@ cp /etc/network/interfaces /etc/network/interfaces.debian-config.backup
# gather some info
#
[[ -f /etc/armbian-release ]] && source /etc/armbian-release && ARMBIAN="Armbian $VERSION $IMAGE_TYPE";
DISTRO=$(lsb_release -is)
DISTROID=$(lsb_release -rs)
BACKTITLE="$ARMBIAN $DISTRO $DISTROID configuration utility, http://www.armbian.com"
......@@ -100,6 +137,7 @@ fi
[[ -n $(grep -w apt /etc/apt/sources.list.d/armbian.list) ]] && LIST+=( "Nightly" "Switch to daily builds" )
LIST+=( "Hotspot" "Manage wireless access point" )
LIST+=( "Network" "Edit network settings" )
[[ $(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" )
[[ -f /boot/armbianEnv.txt ]] && LIST+=( "Booting" "Edit boot environment" )
[[ -f /usr/sbin/nand-sata-install ]] && LIST+=( "Install" "Install Armbian to SATA, eMMC, NAND, USB" )
LIST+=( "Services" "Toggle running services" )
......@@ -370,6 +408,22 @@ while true; do
softy
;;
"Switch" )
aval_kernel
exceptions "$INSTALL_KERNEL"
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! \n\nBoard config will be reverted to defaults." 11 46
if [[ $? = 0 ]]; then
# remove old
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel." 5 28
aptitude remove ~nlinux-image --quiet=100 >> /var/log/upgrade.log
aptitude remove ~nlinux-dtb --quiet=100 >> /var/log/upgrade.log
aptitude remove ~nlinux-headers --quiet=100 >> /var/log/upgrade.log
# install new
debconf-apt-progress -- apt-get -y --no-install-recommends install linux-image${TARGET_BRANCH}-${TARGET_FAMILY} linux-headers${TARGET_BRANCH}-${TARGET_FAMILY} linux-u-boot-${BOARD}-${UBOOT_BRANCH} linux-$(lsb_release -cs)-root$TARGET_BRANCH-$BOARD
[[ $UBOOT_BRANCH != "default" ]] && debconf-apt-progress -- apt-get -y --no-install-recommends install linux-dtb$TARGET_BRANCH-$TARGET_FAMILY
reboot
fi
;;
"Monitor" )
clear
armbianmonitor -m | dialog --backtitle "$BACKTITLE" --title "Simple CLI monitoring $BOARD" --progressbox 15 64
......
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