From cd3c97f11326fda89fdc0d617aaf115160f6be61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 4 Apr 2022 16:38:30 +0200 Subject: [PATCH 1/4] Exit installer if dpkg lock is held for more then 30 seconds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 37 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a9235394..9d1eaccd 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -259,6 +259,27 @@ os_check() { fi } +# This function waits for dpkg to unlock, which signals that the previous apt-get command has finished. +test_dpkg_lock() { + i=0 + # fuser is a program to show which processes use the named files, sockets, or filesystems + # So while the lock is held, + while fuser /var/lib/dpkg/lock >/dev/null 2>&1 + do + # we wait half a second, + sleep 0.5 + # increase the iterator, + ((i=i+1)) + # exit if waiting for more then 30 seconds + if [[ $i -gt 60 ]]; then + echo "*** Error: Could not verify package manager finished and released lock. Attempt to install packages manually and retry."; + exit 1; + fi + done + # and then report success once dpkg is unlocked. + return 0 +} + # Compatibility package_manager_detect() { # First check to see if apt-get is installed. @@ -302,22 +323,6 @@ package_manager_detect() { # and config file LIGHTTPD_CFG="lighttpd.conf.debian" - # This function waits for dpkg to unlock, which signals that the previous apt-get command has finished. - test_dpkg_lock() { - i=0 - # fuser is a program to show which processes use the named files, sockets, or filesystems - # So while the lock is held, - while fuser /var/lib/dpkg/lock >/dev/null 2>&1 - do - # we wait half a second, - sleep 0.5 - # increase the iterator, - ((i=i+1)) - done - # and then report success once dpkg is unlocked. - return 0 - } - # If apt-get is not found, check for rpm. elif is_command rpm ; then # Then check if dnf or yum is the package manager From 30ba79f6a01e331302f753a190b8d187610d374f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 4 Apr 2022 16:48:34 +0200 Subject: [PATCH 2/4] Let users know what's going on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 9d1eaccd..a51362ba 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -262,6 +262,7 @@ os_check() { # This function waits for dpkg to unlock, which signals that the previous apt-get command has finished. test_dpkg_lock() { i=0 + printf " %b Waiting for package manager to finish\\n" "${INFO}" # fuser is a program to show which processes use the named files, sockets, or filesystems # So while the lock is held, while fuser /var/lib/dpkg/lock >/dev/null 2>&1 @@ -272,7 +273,8 @@ test_dpkg_lock() { ((i=i+1)) # exit if waiting for more then 30 seconds if [[ $i -gt 60 ]]; then - echo "*** Error: Could not verify package manager finished and released lock. Attempt to install packages manually and retry."; + printf " %b %bError: Could not verify package manager finished and released lock. %b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}" + printf " Attempt to install packages manually and retry.\\n" exit 1; fi done From c0a2ab7b77feaa64a25415ec674432fa22e423ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 4 Apr 2022 16:59:13 +0200 Subject: [PATCH 3/4] Fix indention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a51362ba..5f2f327d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -262,7 +262,7 @@ os_check() { # This function waits for dpkg to unlock, which signals that the previous apt-get command has finished. test_dpkg_lock() { i=0 - printf " %b Waiting for package manager to finish\\n" "${INFO}" + printf " %b Waiting for package manager to finish\\n" "${INFO}" # fuser is a program to show which processes use the named files, sockets, or filesystems # So while the lock is held, while fuser /var/lib/dpkg/lock >/dev/null 2>&1 From b33434d02a05e2777041ce853b0c09d5f9682bcf Mon Sep 17 00:00:00 2001 From: yubiuser Date: Thu, 7 Apr 2022 09:11:53 +0200 Subject: [PATCH 4/4] Let uses know how long they need to wait (max) Co-authored-by: Adam Warner --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5f2f327d..e1683993 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -262,7 +262,7 @@ os_check() { # This function waits for dpkg to unlock, which signals that the previous apt-get command has finished. test_dpkg_lock() { i=0 - printf " %b Waiting for package manager to finish\\n" "${INFO}" + printf " %b Waiting for package manager to finish (up to 30 seconds)\\n" "${INFO}" # fuser is a program to show which processes use the named files, sockets, or filesystems # So while the lock is held, while fuser /var/lib/dpkg/lock >/dev/null 2>&1