Commit 2992430d authored by Igor Pecovnik's avatar Igor Pecovnik
Browse files

Add checking if package manager is running, introducing new file for functins ... rfc next time

parent 8590c46d
...@@ -33,6 +33,7 @@ fi ...@@ -33,6 +33,7 @@ fi
# load functions # load functions
[[ -f /usr/lib/armbian-config/jobs.sh ]] && source /usr/lib/armbian-config/jobs.sh || source ${BASH_SOURCE}-jobs [[ -f /usr/lib/armbian-config/jobs.sh ]] && source /usr/lib/armbian-config/jobs.sh || source ${BASH_SOURCE}-jobs
[[ -f /usr/lib/armbian-config/submenu.sh ]] && source /usr/lib/armbian-config/submenu.sh || source ${BASH_SOURCE}-submenu [[ -f /usr/lib/armbian-config/submenu.sh ]] && source /usr/lib/armbian-config/submenu.sh || source ${BASH_SOURCE}-submenu
[[ -f /usr/lib/armbian-config/functions.sh ]] && source /usr/lib/armbian-config/functions.sh || source ${BASH_SOURCE}-functions
...@@ -60,7 +61,7 @@ do ...@@ -60,7 +61,7 @@ do
DIALOG_ESC=255 DIALOG_ESC=255
TITLELENGHT=${#MENUTITLE} TITLELENGHT=${#MENUTITLE}
[[ "$TITLELENGHT" -lt 50 ]] && TITLELENGHT="50" [[ "$TITLELENGHT" -lt 60 ]] && TITLELENGHT="60"
exec 3>&1 exec 3>&1
selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \ selection=$(dialog --colors --backtitle "$BACKTITLE" --title " armbian-config " --clear \
......
#!/bin/bash
#
# Copyright (c) 2017 Igor Pecovnik, igor.pecovnik@gma**.com
#
# This file is licensed under the terms of the GNU General Public
# License version 2. This program is licensed "as is" without any
# warranty of any kind, whether express or implied.
#-----------------------------------------------------------------------------------------------------------------------------------------#
# gather info about the board and start with loading menu
#
DIALOG_CANCEL=1
DIALOG_ESC=255
[[ -f /etc/armbian-release ]] && source /etc/armbian-release && ARMBIAN="Armbian $VERSION $IMAGE_TYPE";
DISTRO=$(lsb_release -is)
DISTROID=$(lsb_release -sc)
KERNELID=$(uname -r)
[[ -z "${ARMBIAN// }" ]] && ARMBIAN="$DISTRO $DISTROID"
BACKTITLE="Configuration utility, $ARMBIAN, https://www.armbian.com"
TITLE="$BOARD_NAME "
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
[[ -z "${DEFAULT_ADAPTER// }" ]] && DEFAULT_ADAPTER="lo"
OVERLAYDIR="/boot/dtb/overlay";
[[ "$LINUXFAMILY" == "sunxi64" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay";
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Armbian configuration utility ... " 5 45
sleep 1
#-----------------------------------------------------------------------------------------------------------------------------------------#
# check if package manager is doing something
#
function is_package_manager_running() {
fuser -s /var/lib/dpkg/lock
if [[ $? = 0 ]]; then
# 0 = true
dialog --colors --title " \Z1Error\Z0 " --backtitle "$BACKTITLE" --no-collapse --msgbox \
"\n\Z1Package manager is running in the background. \n\nCan't proceed. Try again later." 9 53
return 0
else
# 1 = false
return 1
fi
}
...@@ -27,29 +27,37 @@ function jobs () ...@@ -27,29 +27,37 @@ function jobs ()
# Remove BT # Remove BT
# #
"BT remove" ) "BT remove" )
debconf-apt-progress -- apt-get -y remove bluetooth bluez bluez-tools if ! is_package_manager_running; then
check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y remove pulseaudio-module-bluetooth blueman debconf-apt-progress -- apt-get -y remove bluetooth bluez bluez-tools
debconf-apt-progress -- apt -y -qq autoremove check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y remove pulseaudio-module-bluetooth blueman
debconf-apt-progress -- apt -y -qq autoremove
fi
;; ;;
# Enabling BT # Enabling BT
# #
"BT install" ) "BT install" )
debconf-apt-progress -- apt-get -y install bluetooth bluez bluez-tools if ! is_package_manager_running; then
check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y --no-install-recommends install pulseaudio-module-bluetooth blueman debconf-apt-progress -- apt-get -y install bluetooth bluez bluez-tools
check_if_installed xserver-xorg && debconf-apt-progress -- apt-get -y --no-install-recommends install pulseaudio-module-bluetooth blueman
fi
;; ;;
# Removing IR # Removing IR
# #
"Remove IR" ) "Remove IR" )
debconf-apt-progress -- apt-get -y remove lirc if ! is_package_manager_running; then
debconf-apt-progress -- apt -y -qq autoremove debconf-apt-progress -- apt-get -y remove lirc
debconf-apt-progress -- apt -y -qq autoremove
fi
;; ;;
# Enabling IR # Enabling IR
# #
"IR" ) "IR" )
debconf-apt-progress -- apt-get -y --no-install-recommends install lirc if ! is_package_manager_running; then
debconf-apt-progress -- apt-get -y --no-install-recommends install lirc
fi
;; ;;
...@@ -129,12 +137,14 @@ function jobs () ...@@ -129,12 +137,14 @@ function jobs ()
# Install kernel headers # Install kernel headers
# #
"Headers" ) "Headers" )
TARGET_BRANCH=$BRANCH if ! is_package_manager_running; then
exceptions "$BRANCH" TARGET_BRANCH=$BRANCH
if [[ -n $(dpkg -l | grep linux-headers) ]]; then exceptions "$BRANCH"
debconf-apt-progress -- apt-get -y remove linux-headers${TARGET_BRANCH}-${TARGET_FAMILY} if [[ -n $(dpkg -l | grep linux-headers) ]]; then
else debconf-apt-progress -- apt-get -y remove linux-headers${TARGET_BRANCH}-${TARGET_FAMILY}
debconf-apt-progress -- apt-get -y install linux-headers${TARGET_BRANCH}-${TARGET_FAMILY} else
debconf-apt-progress -- apt-get -y install linux-headers${TARGET_BRANCH}-${TARGET_FAMILY}
fi
fi fi
;; ;;
...@@ -262,6 +272,7 @@ function jobs () ...@@ -262,6 +272,7 @@ function jobs ()
# Create WiFi access point # Create WiFi access point
# #
"Hotspot" ) "Hotspot" )
if ! is_package_manager_running; then
systemctl daemon-reload systemctl daemon-reload
CURRENT_UUID=$(LC_ALL=C nmcli -f DEVICE,TYPE,STATE device status | grep -w " wifi " | grep -w " disconnected") CURRENT_UUID=$(LC_ALL=C 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
...@@ -480,6 +491,7 @@ function jobs () ...@@ -480,6 +491,7 @@ function jobs ()
reload-nety "reload" reload-nety "reload"
fi fi
fi fi
fi
;; ;;
...@@ -654,19 +666,21 @@ function jobs () ...@@ -654,19 +666,21 @@ function jobs ()
# Firmware update # Firmware update
# #
"Firmware" ) "Firmware" )
clear if ! is_package_manager_running; then
exec 3>&1 clear
monitor=$(dialog --print-maxsize 2>&1 1>&3) exec 3>&1
exec 3>&- monitor=$(dialog --print-maxsize 2>&1 1>&3)
mon_x=$(echo $monitor | awk '{print $2}' | sed 's/,//');mon_x=$(( $mon_x / 2 )) exec 3>&-
mon_y=$(echo $monitor | awk '{print $3}' | sed 's/,//'); mon_x=$(echo $monitor | awk '{print $2}' | sed 's/,//');mon_x=$(( $mon_x / 2 ))
dialog --title " Update " --backtitle "$BACKTITLE" --no-label "Cancel" --yesno "\nDo you want to update board firmware?" 7 41 mon_y=$(echo $monitor | awk '{print $3}' | sed 's/,//');
if [[ $? = 0 ]]; then dialog --title " Update " --backtitle "$BACKTITLE" --no-label "Cancel" --yesno "\nDo you want to update board firmware?" 7 41
debconf-apt-progress -- apt-get update if [[ $? = 0 ]]; then
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y upgrade debconf-apt-progress -- apt-get update
dialog --title " Firmware update " --colors --no-label "Cancel" --backtitle "$BACKTITLE" --yesno \ debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y upgrade
"\nFirmware has been updated. Reboot? " 7 39 dialog --title " Firmware update " --colors --no-label "Cancel" --backtitle "$BACKTITLE" --yesno \
if [[ $? = 0 ]]; then reboot; fi "\nFirmware has been updated. Reboot? " 7 39
if [[ $? = 0 ]]; then reboot; fi
fi
fi fi
;; ;;
...@@ -681,6 +695,7 @@ function jobs () ...@@ -681,6 +695,7 @@ function jobs ()
# Freeze and unfreeze kernel and board support packages # Freeze and unfreeze kernel and board support packages
# #
"Freeze" | "Defreeze" ) "Freeze" | "Defreeze" )
if ! is_package_manager_running; then
dialog --title " Updating " --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" --yesno \ dialog --title " Updating " --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" --yesno \
"\nDo you want to ${1,,} kernel updates?" 7 44 "\nDo you want to ${1,,} kernel updates?" 7 44
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
...@@ -695,6 +710,7 @@ function jobs () ...@@ -695,6 +710,7 @@ function jobs ()
[[ $1 == "Freeze" ]] && local command="hold" [[ $1 == "Freeze" ]] && local command="hold"
for word in $PACKAGE_LIST; do apt-mark $command $word; done | dialog --backtitle "$BACKTITLE" --title "Packages ${1,,}" --progressbox $((${#words[@]}+2)) 64 for word in $PACKAGE_LIST; do apt-mark $command $word; done | dialog --backtitle "$BACKTITLE" --title "Packages ${1,,}" --progressbox $((${#words[@]}+2)) 64
fi fi
fi
;; ;;
...@@ -708,20 +724,22 @@ function jobs () ...@@ -708,20 +724,22 @@ function jobs ()
[[ $exitstatus = 0 ]] && service nodm stop >/dev/null 2>&1 && service lightdm stop >/dev/null 2>&1 && \ [[ $exitstatus = 0 ]] && service nodm stop >/dev/null 2>&1 && service lightdm stop >/dev/null 2>&1 && \
sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm
else else
if [[ -n $DESKTOP_INSTALLED ]]; then if ! is_package_manager_running; then
dialog --colors --title " Choose a display manager " --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Lightdm" \ if [[ -n $DESKTOP_INSTALLED ]]; then
--no-label "Nodm" --yesno "\n\Z1Lightdm\Z0 = full featured login display manager\n\Z1Nodm\Z0 = autoloading into desktop" 8 70 dialog --colors --title " Choose a display manager " --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Lightdm" \
exitstatus=$?; --no-label "Nodm" --yesno "\n\Z1Lightdm\Z0 = full featured login display manager\n\Z1Nodm\Z0 = autoloading into desktop" 8 70
[[ $exitstatus = 0 ]] && [[ -f /etc/X11/default-display-manager ]] && \ exitstatus=$?;
echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager && \ [[ $exitstatus = 0 ]] && [[ -f /etc/X11/default-display-manager ]] && \
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install lightdm-gtk-greeter lightdm \ echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager && \
&& systemctl start lightdm.service debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install lightdm-gtk-greeter lightdm \
[[ $exitstatus = 1 ]] && [[ -f /etc/X11/default-display-manager ]] && \ && systemctl start lightdm.service
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install nodm \ [[ $exitstatus = 1 ]] && [[ -f /etc/X11/default-display-manager ]] && \
&& echo "/usr/sbin/nodm" > /etc/X11/default-display-manager && \ debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install nodm \
sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=true/" /etc/default/nodm && service nodm start && echo "/usr/sbin/nodm" > /etc/X11/default-display-manager && \
else sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=true/" /etc/default/nodm && service nodm start
configure_desktop else
configure_desktop
fi
fi fi
fi fi
;; ;;
...@@ -737,12 +755,14 @@ function jobs () ...@@ -737,12 +755,14 @@ function jobs ()
"Lightdm" ) "Lightdm" )
[[ -f /etc/X11/default-display-manager ]] && echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager if ! is_package_manager_running; then
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install lightdm-gtk-greeter lightdm [[ -f /etc/X11/default-display-manager ]] && echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager
service nodm stop && sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install lightdm-gtk-greeter lightdm
systemctl enable lightdm.service >/dev/null 2>&1 service nodm stop && sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm
systemctl start lightdm.service >/dev/null 2>&1 systemctl enable lightdm.service >/dev/null 2>&1
DISPLAY_MANAGER="lightdm" systemctl start lightdm.service >/dev/null 2>&1
DISPLAY_MANAGER="lightdm"
fi
;; ;;
...@@ -751,11 +771,14 @@ function jobs () ...@@ -751,11 +771,14 @@ function jobs ()
systemctl stop xrdp.service >/dev/null 2>&1 systemctl stop xrdp.service >/dev/null 2>&1
systemctl disable xrdp.service >/dev/null 2>&1 systemctl disable xrdp.service >/dev/null 2>&1
else else
debconf-apt-progress -- apt-get -y install xrdp vnc4server if ! is_package_manager_running; then
systemctl enable xrdp.service >/dev/null 2>&1 debconf-apt-progress -- apt-get -y install xrdp vnc4server
systemctl start xrdp.service >/dev/null 2>&1 systemctl enable xrdp.service >/dev/null 2>&1
dialog --title "Info" --backtitle "$BACKTITLE" --nocancel --no-collapse --pause \ systemctl start xrdp.service >/dev/null 2>&1
"\nRemote graphical login to $BOARD_NAME using Microsoft Remote Desktop Protocol (RDP) is enabled." 11 57 3 dialog --title "Info" --backtitle "$BACKTITLE" --nocancel --no-collapse --pause \
"\nRemote graphical login to $BOARD_NAME using Microsoft Remote Desktop Protocol (RDP) is enabled." 11 57 3
fi
fi fi
;; ;;
...@@ -1024,16 +1047,18 @@ function jobs () ...@@ -1024,16 +1047,18 @@ function jobs ()
# Switch to daily builds # Switch to daily builds
# #
"Nightly" ) "Nightly" )
dialog --colors --title " \Z1Warning\Z0 " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" --yesno \ if ! is_package_manager_running; then
"\nYou are switching to untested auto-build repository which might break your system.\n\nAre you fine with that?" 10 48 dialog --colors --title " \Z1Warning\Z0 " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" --yesno \
"\nYou are switching to untested auto-build repository which might break your system.\n\nAre you fine with that?" 10 48
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
sed -i 's/apt.armbian.com/beta.armbian.com/' /etc/apt/sources.list.d/armbian.list sed -i 's/apt.armbian.com/beta.armbian.com/' /etc/apt/sources.list.d/armbian.list
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 "Switching to nightly" --backtitle "$BACKTITLE" --yes-label "Reboot" \ dialog --title "Switching to nightly" --backtitle "$BACKTITLE" --yes-label "Reboot" \
--no-label "Cancel" --yesno "\nReboot to apply new settings?" 7 34 --no-label "Cancel" --yesno "\nReboot to apply new settings?" 7 34
if [[ $? = 0 ]]; then reboot; fi if [[ $? = 0 ]]; then reboot; fi
fi
fi fi
;; ;;
...@@ -1041,74 +1066,80 @@ function jobs () ...@@ -1041,74 +1066,80 @@ function jobs ()
# Switch to stable builds # Switch to stable builds
# #
"Stable" ) "Stable" )
dialog --colors --title " \Z1Warning\Z0 " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \ if ! is_package_manager_running; then
--yesno "\nYou are switching back to stable respository where you are going to get future updates. Are you fine with that?" 9 44 dialog --colors --title " \Z1Warning\Z0 " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \
if [[ $? = 0 ]]; then --yesno "\nYou are switching back to stable respository where you are going to get future updates. Are you fine with that?" 9 44
sed -i 's/beta.armbian.com/apt.armbian.com/' /etc/apt/sources.list.d/armbian.list if [[ $? = 0 ]]; then
debconf-apt-progress -- apt-get update sed -i 's/beta.armbian.com/apt.armbian.com/' /etc/apt/sources.list.d/armbian.list
debconf-apt-progress -- apt-get -y upgrade debconf-apt-progress -- apt-get update
dialog --title "Switching to stable" --backtitle "$BACKTITLE" --yes-label "Reboot" --no-label "Cancel" --yesno \ debconf-apt-progress -- apt-get -y upgrade
"\nReboot to apply new settings?" 7 34 dialog --title "Switching to stable" --backtitle "$BACKTITLE" --yes-label "Reboot" --no-label "Cancel" --yesno \
if [[ $? = 0 ]]; then reboot; fi "\nReboot to apply new settings?" 7 34
if [[ $? = 0 ]]; then reboot; fi
fi
fi fi
;; ;;
# Switch to alternative kernels # Switch to alternative kernels
# #
"DTB" ) "DTB" )
aval_cubox if ! is_package_manager_running; then
if [[ $exitstatus = 0 ]]; then aval_cubox
BOX_LENGHT=$((${#TARGET_BOARD}+24)); if [[ $exitstatus = 0 ]]; then
dialog --title "Switching board config" --backtitle "$BACKTITLE" --yes-label "Reboot" --no-label "Cancel" --yesno "\nReboot to $TARGET_BOARD settings?" 7 $BOX_LENGHT BOX_LENGHT=$((${#TARGET_BOARD}+24));
if [[ $? = 0 ]]; then dialog --title "Switching board config" --backtitle "$BACKTITLE" --yes-label "Reboot" --no-label "Cancel" --yesno "\nReboot to $TARGET_BOARD settings?" 7 $BOX_LENGHT
sed -i "s/^fdt_file=.*/fdt_file=$TARGET_BOARD/" /boot/armbianEnv.txt && grep -q "fdt_file=$TARGET_BOARD" /boot/armbianEnv.txt || echo "fdt_file=$TARGET_BOARD" >> /boot/armbianEnv.txt if [[ $? = 0 ]]; then
reboot; sed -i "s/^fdt_file=.*/fdt_file=$TARGET_BOARD/" /boot/armbianEnv.txt && grep -q "fdt_file=$TARGET_BOARD" /boot/armbianEnv.txt || echo "fdt_file=$TARGET_BOARD" >> /boot/armbianEnv.txt
fi reboot;
fi
fi
fi fi
;; ;;
# Switch to alternative kernels # Switch to alternative kernels
# #
"Switch" ) "Switch" )
aval_kernel if ! is_package_manager_running; then
if [[ -n $TARGET_BRANCH ]]; then aval_kernel
exceptions "$INSTALL_KERNEL" if [[ -n $TARGET_BRANCH ]]; then
dialog --title " Install and reboot " --colors --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" --yesno \ exceptions "$INSTALL_KERNEL"
"\nSwitching to \Z1linux-image${TARGET_BRANCH}-${TARGET_FAMILY}\Z0 \n\nWarning: another kernel might not provide\ dialog --title " Install and reboot " --colors --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" --yesno \
the same functionality or can be broken!\n\nBoard config will be reverted to defaults." 12 50 "\nSwitching to \Z1linux-image${TARGET_BRANCH}-${TARGET_FAMILY}\Z0 \n\nWarning: another kernel might not provide\
if [[ $? = 0 ]]; then the same functionality or can be broken!\n\nBoard config will be reverted to defaults." 12 50
# remove old
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel." 5 28
apt-get -s -y -qq --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 > /dev/null 2>&1
# if test download is ok, remove old kernel
if [[ $? = 0 ]]; then if [[ $? = 0 ]]; then
aptitude remove ~nlinux-image --quiet=100 -y >> /var/log/upgrade.log # remove old
aptitude remove ~nlinux-dtb --quiet=100 -y >> /var/log/upgrade.log dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nRemoving current kernel." 5 28
aptitude remove ~nlinux-headers --quiet=100 -y >> /var/log/upgrade.log apt-get -s -y -qq --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 > /dev/null 2>&1
# if test download is ok, remove old kernel
if [[ $? = 0 ]]; then
aptitude remove ~nlinux-image --quiet=100 -y >> /var/log/upgrade.log
aptitude remove ~nlinux-dtb --quiet=100 -y >> /var/log/upgrade.log
aptitude remove ~nlinux-headers --quiet=100 -y >> /var/log/upgrade.log
fi
# install new packages
INSTALL_DTB=""
[[ -n $(apt-cache search --names-only "^linux-dtb$TARGET_BRANCH-$TARGET_FAMILY") ]] && \
INSTALL_DTB="linux-dtb$TARGET_BRANCH-$TARGET_FAMILY"
debconf-apt-progress -- apt-get --reinstall -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y -qq --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 $INSTALL_DTB
# install new boot script
[[ -f /usr/share/armbian/boot.cmd ]] && cp /usr/share/armbian/boot.cmd /boot/boot.cmd && mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
[[ -f /usr/share/armbian/boot.ini ]] && cp /usr/share/armbian/boot.ini /boot/boot.ini
# create armbianEnv.txt
[[ ! -f /boot/armbianEnv.txt ]] && printf "verbosity=1\nrootdev=$(sed -e 's/^.*root=//' -e 's/ .*$//' < /proc/cmdline)" > /boot/armbianEnv.txt
dialog --title "Kernel switch" --backtitle "$BACKTITLE" --yes-label "Yes" --no-label "Cancel" \
--yesno "\nNew kernel was installed. Reboot?" 7 64
exitstatus=$?;
[[ $exitstatus = 0 ]] && reboot
fi fi
# install new packages else
INSTALL_DTB="" dialog --backtitle "$BACKTITLE" --title " Info " --msgbox "\nNo alternative kernels available!" 7 38
[[ -n $(apt-cache search --names-only "^linux-dtb$TARGET_BRANCH-$TARGET_FAMILY") ]] && \
INSTALL_DTB="linux-dtb$TARGET_BRANCH-$TARGET_FAMILY"
debconf-apt-progress -- apt-get --reinstall -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y -qq --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 $INSTALL_DTB
# install new boot script
[[ -f /usr/share/armbian/boot.cmd ]] && cp /usr/share/armbian/boot.cmd /boot/boot.cmd && mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr
[[ -f /usr/share/armbian/boot.ini ]] && cp /usr/share/armbian/boot.ini /boot/boot.ini
# create armbianEnv.txt
[[ ! -f /boot/armbianEnv.txt ]] && printf "verbosity=1\nrootdev=$(sed -e 's/^.*root=//' -e 's/ .*$//' < /proc/cmdline)" > /boot/armbianEnv.txt
dialog --title "Kernel switch" --backtitle "$BACKTITLE" --yes-label "Yes" --no-label "Cancel" \
--yesno "\nNew kernel was installed. Reboot?" 7 64
exitstatus=$?;
[[ $exitstatus = 0 ]] && reboot
fi fi
else
dialog --backtitle "$BACKTITLE" --title " Info " --msgbox "\nNo alternative kernels available!" 7 38
fi fi
;; ;;
...@@ -1116,21 +1147,23 @@ function jobs () ...@@ -1116,21 +1147,23 @@ function jobs ()
# Toggle virtual read-only root filesystem # Toggle virtual read-only root filesystem
# #
"Overlayroot" ) "Overlayroot" )
if [[ -n $(mount | grep -w overlay) ]]; then if ! is_package_manager_running; then
dialog --title " Root overlay " --backtitle "$BACKTITLE" --yes-label "Disable" \ if [[ -n $(mount | grep -w overlay) ]]; then
--no-label "Cancel" \ dialog --title " Root overlay " --backtitle "$BACKTITLE" --yes-label "Disable" \
--yesno "\nYour system is already virtual read-only.\n\nDo you want to disable this feature and reboot?" 9 60 --no-label "Cancel" \
[[ $? = 0 ]] && overlayroot-chroot sed -i "s/^overlayroot=.*/overlayroot=\"\"/" /etc/overlayroot.conf && \ --yesno "\nYour system is already virtual read-only.\n\nDo you want to disable this feature and reboot?" 9 60
overlayroot-chroot rm /etc/update-motd.d/97-overlayroot && reboot [[ $? = 0 ]] && overlayroot-chroot sed -i "s/^overlayroot=.*/overlayroot=\"\"/" /etc/overlayroot.conf && \
else overlayroot-chroot rm /etc/update-motd.d/97-overlayroot && reboot
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confnew" -y --no-install-recommends install overlayroot else
echo '#!/bin/bash' > /etc/update-motd.d/97-overlayroot debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confnew" -y --no-install-recommends install overlayroot
echo 'if [ -n "$(mount | grep -w tmpfs-root)" ]; then \ echo '#!/bin/bash' > /etc/update-motd.d/97-overlayroot
echo -e "\n[\e[0m \e[1mremember: your system is in virtual read only mode\e[0m ]";fi' >> /etc/update-motd.d/97-overlayroot echo 'if [ -n "$(mount | grep -w tmpfs-root)" ]; then \
chmod +x /etc/update-motd.d/97-overlayroot echo -e "\n[\e[0m \e[1mremember: your system is in virtual read only mode\e[0m ]";fi' >> /etc/update-motd.d/97-overlayroot
dialog --title "Root overlay" --backtitle "$BACKTITLE" --yes-label "Reboot" \ chmod +x /etc/update-motd.d/97-overlayroot
--no-label "Cancel" --yesno "\nEnable virtual read-only root and reboot." 7 45 dialog --title "Root overlay" --backtitle "$BACKTITLE" --yes-label "Reboot" \
[[ $? = 0 ]] && sed -i "s/^overlayroot=.*/overlayroot=\"tmpfs\"/" /etc/overlayroot.conf && reboot --no-label "Cancel" --yesno "\nEnable virtual read-only root and reboot." 7 45
[[ $? = 0 ]] && sed -i "s/^overlayroot=.*/overlayroot=\"tmpfs\"/" /etc/overlayroot.conf && reboot
fi
fi fi
;; ;;
......
...@@ -993,27 +993,4 @@ while true; do ...@@ -993,27 +993,4 @@ while true; do
jobs "$selection" jobs "$selection"
done done
} }
\ No newline at end of file
DIALOG_CANCEL=1
DIALOG_ESC=255
#-----------------------------------------------------------------------------------------------------------------------------------------#
# gather info about the board and start with loading menu
#
[[ -f /etc/armbian-release ]] && source /etc/armbian-release && ARMBIAN="Armbian $VERSION $IMAGE_TYPE";
DISTRO=$(lsb_release -is)
DISTROID=$(lsb_release -sc)
KERNELID=$(uname -r)
[[ -z "${ARMBIAN// }" ]] && ARMBIAN=$KERNELID
BACKTITLE="Configuration utility, $ARMBIAN, https://www.armbian.com"
TITLE="$BOARD_NAME "
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')
[[ -z "${DEFAULT_ADAPTER// }" ]] && DEFAULT_ADAPTER="lo"
OVERLAYDIR="/boot/dtb/overlay";
[[ "$LINUXFAMILY" == "sunxi64" ]] && OVERLAYDIR="/boot/dtb/allwinner/overlay";
dialog --backtitle "$BACKTITLE" --title "Please wait" --infobox "\nLoading Armbian configuration utility ... " 5 45
sleep 1
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