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

Improve detecting when package manager is running, cleanup freeze and defreeze

parent d75d9088
...@@ -70,8 +70,14 @@ done ...@@ -70,8 +70,14 @@ done
if [[ $1 == "--help" ]]; then if [[ $1 == "--help" ]]; then
echo "Armbian config options:" echo "Armbian config options:"
echo "" echo ""
echo "Example to install headers:" echo "Examples:"
echo "${BASH_SOURCE[0]} main=Software selection=Headers" echo ""
echo "Install headers: ${BASH_SOURCE[0]} main=Software selection=Headers"
echo "Update, upgrade and reboot: ${BASH_SOURCE[0]} main=Software selection=Firmware"
echo "Change to ZSH: ${BASH_SOURCE[0]} main=Software selection=ZSH"
echo "Change to BASH: ${BASH_SOURCE[0]} main=Software selection=BASH"
echo "Install headers: ${BASH_SOURCE[0]} main=Software selection=Headers"
echo "Install Avahi mDNS/DNS-SD daemon: ${BASH_SOURCE[0]} main=Software selection=Avahi"
exit exit
fi fi
......
...@@ -198,16 +198,13 @@ check_if_installed (){ ...@@ -198,16 +198,13 @@ check_if_installed (){
# #
function is_package_manager_running() { function is_package_manager_running() {
fuser -s /var/lib/dpkg/lock if ps -C apt-get,apt,dpkg >/dev/null ; then
if [[ $? = 0 ]]; then [[ -z $scripted ]] && dialog --colors --title " \Z1Error\Z0 " --backtitle "$BACKTITLE" --no-collapse --msgbox \
# 0 = true "\n\Z0Package manager is running in the background. \n\nCan't install dependencies. Try again later." 9 53
dialog --colors --title " \Z1Error\Z0 " --backtitle "$BACKTITLE" --no-collapse --msgbox \ return 0
"\n\Z0Package manager is running in the background. \n\nCan't install dependencies. Try again later." 9 53 else
return 0 return 1
else fi
# 1 = false
return 1
fi
} }
...@@ -365,7 +362,7 @@ function reload_bsp(){ ...@@ -365,7 +362,7 @@ function reload_bsp(){
debconf-apt-progress -- apt-get update debconf-apt-progress -- apt-get update
PACKAGE_LIST="linux-${DISTROID}-root-${BRANCH}-${BOARD} linux-u-boot-${BOARD}-${BRANCH}" PACKAGE_LIST="linux-${DISTROID}-root-${BRANCH}-${BOARD} linux-u-boot-${BOARD}-${BRANCH}"
check_if_installed armbian-${DISTROID}-desktop && PACKAGE_LIST+=" armbian-${DISTROID}-desktop" check_if_installed armbian-${DISTROID}-desktop && PACKAGE_LIST+=" armbian-${DISTROID}-desktop"
check_if_installed linux-headers${BRANCH}-${FAMILY} && PACKAGE_LIST+=" linux-headers-${BRANCH}-${FAMILY}" check_if_installed linux-headers-${BRANCH}-${FAMILY} && PACKAGE_LIST+=" linux-headers-${BRANCH}-${FAMILY}"
[[ -n $(apt-cache search --names-only "^linux-dtb-${BRANCH}-${LINUXFAMILY}") ]] && \ [[ -n $(apt-cache search --names-only "^linux-dtb-${BRANCH}-${LINUXFAMILY}") ]] && \
PACKAGE_LIST+=" linux-dtb-${BRANCH}-${LINUXFAMILY}" PACKAGE_LIST+=" linux-dtb-${BRANCH}-${LINUXFAMILY}"
......
...@@ -183,13 +183,15 @@ unset selection ...@@ -183,13 +183,15 @@ unset selection
# #
"Source" ) "Source" )
if ! is_package_manager_running; then if ! is_package_manager_running; then
PACKAGE=$(echo "$SOURCE_PKG" | sed "s/-next//" | sed "s/-dev//" | sed "s/-default//") PACKAGE=$(echo "$SOURCE_PKG" | sed "s/-current//" | sed "s/-dev//" | sed "s/-legacy//")
if ls /usr/src/linux-source* 1> /dev/null 2>&1; then if [[ -n $PACKAGE ]]; then
if ls /usr/src/linux-source* 1> /dev/null 2>&1; then
debconf-apt-progress -- apt-get -y purge linux-source* debconf-apt-progress -- apt-get -y purge linux-source*
debconf-apt-progress -- apt -y autoremove debconf-apt-progress -- apt -y autoremove
apt clean apt clean
rm -r /usr/src/linux-source* rm -r /usr/src/linux-source*
else else
debconf-apt-progress -- apt-get -y install ${SOURCE_PKG} debconf-apt-progress -- apt-get -y install ${SOURCE_PKG}
mkdir -p /usr/src/$PACKAGE mkdir -p /usr/src/$PACKAGE
(pv -n /usr/src/$PACKAGE".tar.xz" | xz -d -T0 - | tar xf - -C /usr/src/$PACKAGE ) 2>&1 | dialog --colors --backtitle "$BACKTITLE" --title " Please wait! " --gauge "\nDecompressing kernel sources to /usr/src/$PACKAGE" 8 80 (pv -n /usr/src/$PACKAGE".tar.xz" | xz -d -T0 - | tar xf - -C /usr/src/$PACKAGE ) 2>&1 | dialog --colors --backtitle "$BACKTITLE" --title " Please wait! " --gauge "\nDecompressing kernel sources to /usr/src/$PACKAGE" 8 80
...@@ -198,9 +200,12 @@ unset selection ...@@ -198,9 +200,12 @@ unset selection
apt clean apt clean
debconf-apt-progress -- apt-get -y purge linux-source* debconf-apt-progress -- apt-get -y purge linux-source*
debconf-apt-progress -- apt -y autoremove debconf-apt-progress -- apt -y autoremove
if [[ -z $scripted ]]; then
dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Kernel source " --clear --msgbox "\nYou will find pre-configured kernel sources in /usr/src/$PACKAGE" 7 72 dialog --colors --backtitle "$BACKTITLE" --no-collapse --title " Kernel source " --clear --msgbox "\nYou will find pre-configured kernel sources in /usr/src/$PACKAGE" 7 72
fi fi
fi fi
fi
fi
;; ;;
...@@ -804,7 +809,7 @@ unset selection ...@@ -804,7 +809,7 @@ unset selection
fi fi
;; ;;
# ZSH # Bash
# #
"BASH" ) "BASH" )
# change shell for root # change shell for root
...@@ -825,7 +830,9 @@ unset selection ...@@ -825,7 +830,9 @@ unset selection
sed -i "s/^SHELL=.*/SHELL=\/bin\/bash/" /etc/default/useradd sed -i "s/^SHELL=.*/SHELL=\/bin\/bash/" /etc/default/useradd
# remove crontab # remove crontab
crontab -l | grep -v oh-my | crontab - crontab -l | grep -v oh-my | crontab -
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1BASH\Z0\n\nPlease logout & login from this session!" 9 47 if [[ -z $scripted ]]; then
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1BASH\Z0\n\nPlease logout & login from this session!" 9 47
fi
;; ;;
...@@ -867,7 +874,9 @@ unset selection ...@@ -867,7 +874,9 @@ unset selection
fi fi
# add a cronjob to update oh-my-zsh once per month # add a cronjob to update oh-my-zsh once per month
(crontab -l 2>/dev/null; echo "0 0 1 * * cd /etc/oh-my-zsh ; git pull origin master >/dev/null 2>/dev/null") | crontab - (crontab -l 2>/dev/null; echo "0 0 1 * * cd /etc/oh-my-zsh ; git pull origin master >/dev/null 2>/dev/null") | crontab -
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1ZSH\Z0\n\nPlease logout & login from this session!" 9 47 if [[ -z $scripted ]]; then
dialog --backtitle "$BACKTITLE" --title "Info" --colors --msgbox "\nYour default shell was switched to: \Z1ZSH\Z0\n\nPlease logout & login from this session!" 9 47
fi
fi fi
;; ;;
...@@ -882,13 +891,15 @@ unset selection ...@@ -882,13 +891,15 @@ unset selection
exec 3>&- exec 3>&-
mon_x=$(echo $monitor | awk '{print $2}' | sed 's/,//');mon_x=$(( $mon_x / 2 )) mon_x=$(echo $monitor | awk '{print $2}' | sed 's/,//');mon_x=$(( $mon_x / 2 ))
mon_y=$(echo $monitor | awk '{print $3}' | sed 's/,//'); mon_y=$(echo $monitor | awk '{print $3}' | sed 's/,//');
if [[ -z $scripted ]]; then
dialog --title " Update " --backtitle "$BACKTITLE" --no-label "No" --yesno "\nDo you want to update board firmware?" 7 41 dialog --title " Update " --backtitle "$BACKTITLE" --no-label "No" --yesno "\nDo you want to update board firmware?" 7 41
if [[ $? = 0 ]]; then fi
if [[ $? -eq 0 ]]; then
debconf-apt-progress -- apt-get update debconf-apt-progress -- apt-get update
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y upgrade debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y upgrade
dialog --title " Firmware update " --colors --no-label "No" --backtitle "$BACKTITLE" --yesno \ dialog --title " Firmware update " --colors --no-label "No" --backtitle "$BACKTITLE" --yesno \
"\nFirmware has been updated. Reboot? " 7 39 "\nFirmware has been updated. Reboot? " 7 39
if [[ $? = 0 ]]; then reboot; fi if [[ $? -eq 0 && -z $scripted ]]; then reboot; fi
fi fi
fi fi
;; ;;
...@@ -905,30 +916,27 @@ unset selection ...@@ -905,30 +916,27 @@ unset selection
# #
"Freeze" | "Defreeze" ) "Freeze" | "Defreeze" )
if ! is_package_manager_running; then if ! is_package_manager_running; then
dialog --title " Updating " --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" --yesno \ if [[ -z $scripted ]]; then dialog --title " Updating " --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" --yesno \
"\nDo you want to ${1,,} Armbian firmware updates?" 7 54 "\nDo you want to ${1,,} Armbian firmware updates?" 7 54
if [[ $? = 0 ]]; then fi
TARGET_BRANCH=$BRANCH if [[ $? -eq 0 ]]; then
exceptions "$BRANCH"
unset PACKAGE_LIST unset PACKAGE_LIST
# basic packages # basic packages
check_if_installed linux-u-boot-${BOARD}-${UBOOT_BRANCH} && PACKAGE_LIST=$PACKAGE_LIST" linux-u-boot-${BOARD}-${UBOOT_BRANCH}"
check_if_installed linux-image${TARGET_BRANCH}-${TARGET_FAMILY} && PACKAGE_LIST=$PACKAGE_LIST" linux-image${TARGET_BRANCH}-${TARGET_FAMILY}"
check_if_installed linux-dtb$TARGET_BRANCH-$TARGET_FAMILY && PACKAGE_LIST=$PACKAGE_LIST" linux-dtb$TARGET_BRANCH-$TARGET_FAMILY"
# old BSP check_if_installed linux-u-boot-${BOARD}-${BRANCH} && PACKAGE_LIST+=" linux-u-boot-${BOARD}-${BRANCH}"
check_if_installed linux-$(lsb_release -cs)-root$TARGET_BRANCH-$BOARD && PACKAGE_LIST=$PACKAGE_LIST" linux-$(lsb_release -cs)-root$TARGET_BRANCH-$BOARD" check_if_installed linux-image-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-image-${BRANCH}-${LINUXFAMILY}"
check_if_installed linux-headers${TARGET_BRANCH}-${TARGET_FAMILY} && PACKAGE_LIST=$PACKAGE_LIST" linux-headers${TARGET_BRANCH}-${TARGET_FAMILY}" check_if_installed linux-dtb-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-dtb-${BRANCH}-${LINUXFAMILY}"
check_if_installed linux-headers-${BRANCH}-${LINUXFAMILY} && PACKAGE_LIST+=" linux-headers-${BRANCH}-${LINUXFAMILY}"
# new BSP # new BSP
check_if_installed armbian-${LINUXFAMILY} && PACKAGE_LIST=$PACKAGE_LIST" armbian-${LINUXFAMILY}" check_if_installed armbian-${LINUXFAMILY} && PACKAGE_LIST+=" armbian-${LINUXFAMILY}"
check_if_installed armbian-${BOARD} && PACKAGE_LIST=$PACKAGE_LIST" armbian-${BOARD}" check_if_installed armbian-${BOARD} && PACKAGE_LIST+=" armbian-${BOARD}"
check_if_installed armbian-$(lsb_release -cs) && PACKAGE_LIST=$PACKAGE_LIST" armbian-$(lsb_release -cs)" check_if_installed armbian-${DISTROID} && PACKAGE_LIST+=" armbian-${DISTROID}"
check_if_installed armbian-$(lsb_release -cs)-desktop-xfce && PACKAGE_LIST=$PACKAGE_LIST" armbian-$(lsb_release -cs)-desktop-xfce" check_if_installed armbian-${DISTROID}-desktop-xfce && PACKAGE_LIST+=" armbian-${DISTROID}-desktop-xfce"
check_if_installed armbian-firmware && PACKAGE_LIST=$PACKAGE_LIST" armbian-firmware" check_if_installed armbian-firmware && PACKAGE_LIST+=" armbian-firmware"
check_if_installed armbian-firmware-full && PACKAGE_LIST=$PACKAGE_LIST" armbian-firmware-full" check_if_installed armbian-firmware-full && PACKAGE_LIST+=" armbian-firmware-full"
local words=( $PACKAGE_LIST ) local words=( $PACKAGE_LIST )
local command="unhold" local command="unhold"
......
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