Created
April 8, 2017 00:33
-
-
Save tamsky/52e400d909dc2d57eeedf536eca47845 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# File: packer-provisioners/wait-for-package-manager.sh | |
set -x | |
# http://unix.stackexchange.com/questions/315502/how-to-disable-apt-daily-service-on-ubuntu-cloud-vm-image | |
sudo systemctl stop apt-daily.service | |
sudo systemctl kill --kill-who=all apt-daily.service | |
# wait until 'apt-get updated' has been killed | |
while ! (sudo systemctl list-units --all apt-daily.service | fgrep -q dead) | |
do | |
sleep 1; | |
done | |
if sudo pkill -0 cloud-init; then | |
printf 'Waiting for cloud-init to finish' | |
while sudo pkill -0 cloud-init; do | |
printf . | |
sleep 2s | |
done | |
printf '\n' | |
fi ; | |
while sudo pkill -0 unattended-upgrade; do | |
echo waiting for unattended-upgrade to complete | |
sleep 2 | |
done | |
while sudo lsof /var/lib/dpkg/lock ; do | |
echo waiting for lock to release on /var/lib/dpkg/lock | |
sleep 2 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment