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
# 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/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
DIALOG_ESC=255
TITLELENGHT=${#MENUTITLE}
[[ "$TITLELENGHT" -lt 50 ]] && TITLELENGHT="50"
[[ "$TITLELENGHT" -lt 60 ]] && TITLELENGHT="60"
exec 3>&1
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 ()
# Remove BT
#
"BT remove" )
if ! is_package_manager_running; then
debconf-apt-progress -- apt-get -y remove bluetooth bluez bluez-tools
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
#
"BT install" )
if ! is_package_manager_running; then
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
#
"Remove IR" )
if ! is_package_manager_running; then
debconf-apt-progress -- apt-get -y remove lirc
debconf-apt-progress -- apt -y -qq autoremove
fi
;;
# Enabling IR
#
"IR" )
if ! is_package_manager_running; then
debconf-apt-progress -- apt-get -y --no-install-recommends install lirc
fi
;;
......@@ -129,6 +137,7 @@ function jobs ()
# Install kernel headers
#
"Headers" )
if ! is_package_manager_running; then
TARGET_BRANCH=$BRANCH
exceptions "$BRANCH"
if [[ -n $(dpkg -l | grep linux-headers) ]]; then
......@@ -136,6 +145,7 @@ function jobs ()
else
debconf-apt-progress -- apt-get -y install linux-headers${TARGET_BRANCH}-${TARGET_FAMILY}
fi
fi
;;
......@@ -262,6 +272,7 @@ function jobs ()
# Create WiFi access point
#
"Hotspot" )
if ! is_package_manager_running; then
systemctl daemon-reload
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
......@@ -480,6 +491,7 @@ function jobs ()
reload-nety "reload"
fi
fi
fi
;;
......@@ -654,6 +666,7 @@ function jobs ()
# Firmware update
#
"Firmware" )
if ! is_package_manager_running; then
clear
exec 3>&1
monitor=$(dialog --print-maxsize 2>&1 1>&3)
......@@ -668,6 +681,7 @@ function jobs ()
"\nFirmware has been updated. Reboot? " 7 39
if [[ $? = 0 ]]; then reboot; fi
fi
fi
;;
......@@ -681,6 +695,7 @@ function jobs ()
# Freeze and unfreeze kernel and board support packages
#
"Freeze" | "Defreeze" )
if ! is_package_manager_running; then
dialog --title " Updating " --backtitle "$BACKTITLE" --yes-label "$1" --no-label "Cancel" --yesno \
"\nDo you want to ${1,,} kernel updates?" 7 44
if [[ $? = 0 ]]; then
......@@ -695,6 +710,7 @@ function jobs ()
[[ $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
fi
fi
;;
......@@ -708,6 +724,7 @@ function jobs ()
[[ $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
else
if ! is_package_manager_running; then
if [[ -n $DESKTOP_INSTALLED ]]; then
dialog --colors --title " Choose a display manager " --backtitle "$BACKTITLE" --help-button --help-label "Cancel" --yes-label "Lightdm" \
--no-label "Nodm" --yesno "\n\Z1Lightdm\Z0 = full featured login display manager\n\Z1Nodm\Z0 = autoloading into desktop" 8 70
......@@ -724,6 +741,7 @@ function jobs ()
configure_desktop
fi
fi
fi
;;
......@@ -737,12 +755,14 @@ function jobs ()
"Lightdm" )
if ! is_package_manager_running; then
[[ -f /etc/X11/default-display-manager ]] && echo "/usr/sbin/lightdm" > /etc/X11/default-display-manager
debconf-apt-progress -- apt-get -o Dpkg::Options::="--force-confold" -y --no-install-recommends install lightdm-gtk-greeter lightdm
service nodm stop && sed -i "s/^NODM_ENABLED=.*/NODM_ENABLED=false/" /etc/default/nodm
systemctl enable lightdm.service >/dev/null 2>&1
systemctl start lightdm.service >/dev/null 2>&1
DISPLAY_MANAGER="lightdm"
fi
;;
......@@ -751,11 +771,14 @@ function jobs ()
systemctl stop xrdp.service >/dev/null 2>&1
systemctl disable xrdp.service >/dev/null 2>&1
else
if ! is_package_manager_running; then
debconf-apt-progress -- apt-get -y install xrdp vnc4server
systemctl enable xrdp.service >/dev/null 2>&1
systemctl start xrdp.service >/dev/null 2>&1
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
;;
......@@ -1024,6 +1047,7 @@ function jobs ()
# Switch to daily builds
#
"Nightly" )
if ! is_package_manager_running; then
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
......@@ -1035,12 +1059,14 @@ function jobs ()
--no-label "Cancel" --yesno "\nReboot to apply new settings?" 7 34
if [[ $? = 0 ]]; then reboot; fi
fi
fi
;;
# Switch to stable builds
#
"Stable" )
if ! is_package_manager_running; then
dialog --colors --title " \Z1Warning\Z0 " --backtitle "$BACKTITLE" --yes-label "OK" --no-label "Cancel" \
--yesno "\nYou are switching back to stable respository where you are going to get future updates. Are you fine with that?" 9 44
if [[ $? = 0 ]]; then
......@@ -1051,11 +1077,13 @@ function jobs ()
"\nReboot to apply new settings?" 7 34
if [[ $? = 0 ]]; then reboot; fi
fi
fi
;;
# Switch to alternative kernels
#
"DTB" )
if ! is_package_manager_running; then
aval_cubox
if [[ $exitstatus = 0 ]]; then
BOX_LENGHT=$((${#TARGET_BOARD}+24));
......@@ -1065,11 +1093,13 @@ function jobs ()
reboot;
fi
fi
fi
;;
# Switch to alternative kernels
#
"Switch" )
if ! is_package_manager_running; then
aval_kernel
if [[ -n $TARGET_BRANCH ]]; then
exceptions "$INSTALL_KERNEL"
......@@ -1110,12 +1140,14 @@ function jobs ()
else
dialog --backtitle "$BACKTITLE" --title " Info " --msgbox "\nNo alternative kernels available!" 7 38
fi
fi
;;
# Toggle virtual read-only root filesystem
#
"Overlayroot" )
if ! is_package_manager_running; then
if [[ -n $(mount | grep -w overlay) ]]; then
dialog --title " Root overlay " --backtitle "$BACKTITLE" --yes-label "Disable" \
--no-label "Cancel" \
......@@ -1132,6 +1164,7 @@ function jobs ()
--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
;;
......
......@@ -994,26 +994,3 @@ while true; do
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