1
0
mirror of synced 2025-02-16 20:13:19 +03:00

Improve check for apt/dpkg lock

This commit is contained in:
hwdsl2 2018-05-13 00:56:29 -05:00
parent 73a97f2ba4
commit 738f5d4764

View File

@ -134,17 +134,19 @@ bigecho "VPN setup in progress... Please be patient."
mkdir -p /opt/src
cd /opt/src || exiterr "Cannot enter /opt/src."
bigecho "Populating apt-get cache..."
# Wait up to 60s for apt/dpkg lock
count=0
while fuser /var/lib/apt/lists/lock /var/lib/dpkg/lock >/dev/null 2>&1; do
[ "$count" -ge "20" ] && exiterr "Cannot get apt/dpkg lock."
while fuser /var/lib/apt/lists/lock /var/lib/dpkg/lock >/dev/null 2>&1 \
|| lsof /var/lib/apt/lists/lock >/dev/null 2>&1 \
|| lsof /var/lib/dpkg/lock >/dev/null 2>&1; do
[ "$count" = "0" ] && bigecho "Waiting for apt to be available..."
[ "$count" -ge "60" ] && exiterr "Could not get apt/dpkg lock."
count=$((count+1))
printf '%s' '.'
sleep 3
done
bigecho "Populating apt-get cache..."
export DEBIAN_FRONTEND=noninteractive
apt-get -yq update || exiterr "'apt-get update' failed."