Wait for apt before upgrade

This commit is contained in:
Maniack Crudelis 2020-03-13 18:53:08 +01:00 committed by GitHub
parent 7f1b64d8f2
commit 54da503c12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -70,6 +70,17 @@ sudo lxc-ls -f
echo -e "\e[1m> Update\e[0m" echo -e "\e[1m> Update\e[0m"
update_apt=0 update_apt=0
sudo lxc-attach -n $LXC_NAME -- apt-get update sudo lxc-attach -n $LXC_NAME -- apt-get update
# Wait for apt to be available before the upgrade.
for try in `seq 1 17`
do
# Check if /var/lib/dpkg/lock is used by another process
if sudo lxc-attach -n $LXC_NAME -- lsof /var/lib/dpkg/lock > /dev/null
then
echo "apt is already in use..."
# Sleep an exponential time at each round
sleep $(( try * try ))
fi
done
sudo lxc-attach -n $LXC_NAME -- apt-get dist-upgrade --dry-run | grep -q "^Inst " # Vérifie si il y aura des mises à jour. sudo lxc-attach -n $LXC_NAME -- apt-get dist-upgrade --dry-run | grep -q "^Inst " # Vérifie si il y aura des mises à jour.
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then