From f4d2395e76a9b64176e301fbfd8c7a08c96f1c3a Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Wed, 28 Mar 2012 11:19:24 -0500 Subject: [PATCH] Add unstack.sh unstack.sh is a simple clean-up script to kill known running OpenStack processes: * quit devstack's screen session * stop swift daemons * stop apache * remove volumes Change-Id: I41b33817c4436e644c336e4e0673144ac0844c26 --- unstack.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 unstack.sh diff --git a/unstack.sh b/unstack.sh new file mode 100755 index 0000000000..cfe2de6db4 --- /dev/null +++ b/unstack.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# +# Stops that which is started by ``stack.sh`` (mostly) +# mysql and rabbit are left running as OpenStack code refreshes +# do not require them to be restarted. +# +# Stop all processes by setting UNSTACK_ALL or specifying ``--all`` +# on the command line + +# Keep track of the current devstack directory. +TOP_DIR=$(cd $(dirname "$0") && pwd) + +# Import common functions +source $TOP_DIR/functions + +# Load local configuration +source $TOP_DIR/stackrc + +# Determine what system we are running on. This provides ``os_VENDOR``, +# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` +GetOSVersion + +if [[ "$1" == "--all" ]]; then + UNSTACK_ALL=${UNSTACK_ALL:-1} +fi + +# Shut down devstack's screen to get the bulk of OpenStack services in one shot +SESSION=$(screen -ls | grep "[0-9].stack" | awk '{ print $1 }') +if [[ -n "$SESSION" ]]; then + screen -X -S $SESSION quit +fi + +# Swift runs daemons +if is_service_enabled swift; then + swift-init all stop +fi + +# Apache has the WSGI processes +if is_service_enabled horizon; then + stop_service apache2 +fi + +# Get the iSCSI volumes +if is_service_enabled n-vol; then + TARGETS=$(sudo tgtadm --op show --mode target) + if [[ -n "$TARGETS" ]]; then + # FIXME(dtroyer): this could very well require more here to + # clean up left-over volumes + echo "iSCSI target cleanup needed:" + echo "$TARGETS" + fi + sudo stop tgt +fi + +if [[ -n "$UNSTACK_ALL" ]]; then + # Stop MySQL server + if is_service_enabled mysql; then + stop_service mysql + fi +fi