Skip to content

Instantly share code, notes, and snippets.

@tamsky
Created April 8, 2017 00:33
Show Gist options
  • Save tamsky/52e400d909dc2d57eeedf536eca47845 to your computer and use it in GitHub Desktop.
Save tamsky/52e400d909dc2d57eeedf536eca47845 to your computer and use it in GitHub Desktop.
#!/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