diff options
author | Christian König <ckoenig@posteo.de> | 2022-04-04 17:38:30 +0300 |
---|---|---|
committer | Christian König <ckoenig@posteo.de> | 2022-04-04 17:38:30 +0300 |
commit | cd3c97f11326fda89fdc0d617aaf115160f6be61 (patch) | |
tree | ab002f491dbb5cb834b3377ffa4da38bc9a2ef1a /automated install/basic-install.sh | |
parent | 0d74b27101dfc8f73733b8b46c26266f844e08be (diff) |
Exit installer if dpkg lock is held for more then 30 seconds
Signed-off-by: Christian König <ckoenig@posteo.de>
Diffstat (limited to 'automated install/basic-install.sh')
-rwxr-xr-x | automated install/basic-install.sh | 37 |
1 files 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 |