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