-
-
Save mlesaout/3cd98d87c27c1d6e4e4ffa3ee9ac2f7d to your computer and use it in GitHub Desktop.
`vagrant` on `ubuntu-16.04` can get in conflict with *unattended-upgrade* running and locking the `dpkg` subsystem. this script waits gracefully
This file contains hidden or 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
#!/usr/bin/env bash | |
# https://gist.github.com/gretel/34008d667a8a243a9682e5207619ad95 | |
# 2016 tom hensel <[email protected]> | |
# `vagrant` on `ubuntu-16.04` can get in conflict with *unattended-upgrade* running and locking the `dpkg` subsystem. this script waits gracefully | |
# in `Vagrantfile`: | |
# config.vm.provision 'Wait for unattended-upgrades', type: 'shell', path: './provisioning/wait_unattended_upgrades.sh', args: %w( dpkg apt unattended-upgrade ) | |
# | |
function wait_procnames { | |
while true; do | |
alive_pids=() | |
for pname in "$@"; do | |
if [ "$(pgrep "$pname")" ]; then | |
alive_pids+=("$pname ") | |
fi | |
done | |
if [ "${#alive_pids[@]}" -eq 0 ]; then | |
break | |
else | |
printf "waiting for: %s\n" "${alive_pids[@]}" | |
fi | |
sleep 1 | |
done | |
} | |
wait_procnames "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment