blob: cfe2de6db41ee9f43d1db8a81880611cff8d9603 [file] [log] [blame]
Dean Troyerf4d23952012-03-28 11:19:24 -05001#!/usr/bin/env bash
2#
3# Stops that which is started by ``stack.sh`` (mostly)
4# mysql and rabbit are left running as OpenStack code refreshes
5# do not require them to be restarted.
6#
7# Stop all processes by setting UNSTACK_ALL or specifying ``--all``
8# on the command line
9
10# Keep track of the current devstack directory.
11TOP_DIR=$(cd $(dirname "$0") && pwd)
12
13# Import common functions
14source $TOP_DIR/functions
15
16# Load local configuration
17source $TOP_DIR/stackrc
18
19# Determine what system we are running on. This provides ``os_VENDOR``,
20# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
21GetOSVersion
22
23if [[ "$1" == "--all" ]]; then
24 UNSTACK_ALL=${UNSTACK_ALL:-1}
25fi
26
27# Shut down devstack's screen to get the bulk of OpenStack services in one shot
28SESSION=$(screen -ls | grep "[0-9].stack" | awk '{ print $1 }')
29if [[ -n "$SESSION" ]]; then
30 screen -X -S $SESSION quit
31fi
32
33# Swift runs daemons
34if is_service_enabled swift; then
35 swift-init all stop
36fi
37
38# Apache has the WSGI processes
39if is_service_enabled horizon; then
40 stop_service apache2
41fi
42
43# Get the iSCSI volumes
44if is_service_enabled n-vol; then
45 TARGETS=$(sudo tgtadm --op show --mode target)
46 if [[ -n "$TARGETS" ]]; then
47 # FIXME(dtroyer): this could very well require more here to
48 # clean up left-over volumes
49 echo "iSCSI target cleanup needed:"
50 echo "$TARGETS"
51 fi
52 sudo stop tgt
53fi
54
55if [[ -n "$UNSTACK_ALL" ]]; then
56 # Stop MySQL server
57 if is_service_enabled mysql; then
58 stop_service mysql
59 fi
60fi