1
0
mirror of synced 2025-01-30 20:11:45 +03:00

Improve startup

- Ubuntu 16.04 (and newer) may run apt tasks automatically on boot
- If used as a startup script, apt-get commands could fail due to this
- Wait for apt/dpkg lock (up to 60s) as a workaround
- Ref: #252
This commit is contained in:
hwdsl2 2017-10-30 01:56:00 -05:00
parent 16e437f58e
commit b7a4bed866

View File

@ -138,6 +138,14 @@ cd /opt/src || exiterr "Cannot enter /opt/src."
bigecho "Populating apt-get cache..."
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."
count=$((count+1))
printf %s .
sleep 3
done
export DEBIAN_FRONTEND=noninteractive
apt-get -yq update || exiterr "'apt-get update' failed."