From dd7f3f7df7bf73b8c5c451407b1451dd8516848b Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Mon, 4 May 2015 16:11:40 -0700 Subject: [PATCH] Skip SaltStack install if it's already installed Next ContainerVM image will have SaltStack in it. Also be a little less persnickety if it's found running. This isn't the case, but we don't have to be aggressive. --- cluster/gce/configure-vm.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cluster/gce/configure-vm.sh b/cluster/gce/configure-vm.sh index 753cb3de90..c85be1f723 100644 --- a/cluster/gce/configure-vm.sh +++ b/cluster/gce/configure-vm.sh @@ -104,6 +104,11 @@ download-or-bust() { # Install salt from GCS. See README.md for instructions on how to update these # debs. install-salt() { + if dpkg -s salt-minion &>/dev/null; then + echo "== SaltStack already installed, skipping install step ==" + return + fi + echo "== Refreshing package database ==" until apt-get update; do echo "== apt-get update failed, retrying ==" @@ -158,16 +163,22 @@ EOF echo "== Finished installing Salt ==" } -# Ensure salt-minion never runs +# Ensure salt-minion isn't running and never runs stop-salt-minion() { + if [[ -e /etc/init/salt-minion.override ]]; then + # Assume this has already run (upgrade, or baked into containervm) + return + fi + # This ensures it on next reboot echo manual > /etc/init/salt-minion.override update-rc.d salt-minion disable - if service salt-minion status >/dev/null; then - echo "salt-minion started in defiance of runlevel policy, aborting startup." >&2 - return 1 - fi + while service salt-minion status >/dev/null; do + echo "salt-minion found running, stopping" + service salt-minion stop + sleep 1 + done } # Mounts a persistent disk (formatting if needed) to store the persistent data