GEODE-FIX: Make sure the dpkg lock file is not used by other apt process 40/2140/3
authorrobert.tomczyk <robert.tomczyk@est.tech>
Wed, 4 Sep 2019 11:13:50 +0000 (12:13 +0100)
committerrobert.tomczyk <robert.tomczyk@est.tech>
Wed, 4 Sep 2019 11:18:43 +0000 (12:18 +0100)
Change-Id: If93b30f7dc0a0e8f8a1a8b69b5c06282e09e4cd1

jjb/geode/apache-geode-slave/slave_setup.sh

index ef32cd12dbce4dc89b92957a141f6e424398e16e..91615e08a21a345069d0d903c5c4c5a4df473bc2 100755 (executable)
@@ -19,6 +19,20 @@ set -o nounset
 set -o errexit
 set -o pipefail
 set -o xtrace
+DPKG_LOCK="/var/lib/dpkg/lock-frontend"
+
+# Wait for other apt process to finish by checking the dpkg lock file.
+try=0
+while sudo lsof ${DPKG_LOCK}  > /dev/null 2>&1 ; do
+  echo "DPKG file locked: ${DPKG_LOCK}."
+  echo "   Waiting for another pkg instalaltion process to finish ..."
+  sleep 10
+  if [[ ${try} -gt 30 ]] ; then
+    echo "ERROR: Max number of re-tries reached, exiting..."
+    exit 1
+  fi
+  let "try++"
+done
 
 sudo apt-get update
 sudo apt-get install -y --no-install-recommends \