blob: 879f84246305830e8520b01d1d354e7095e92cdf [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
Dean Troyereeaf2662012-06-14 09:11:38 -050028SCREEN=$(which screen)
29if [[ -n "$SCREEN" ]]; then
30 SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
31 if [[ -n "$SESSION" ]]; then
32 screen -X -S $SESSION quit
33 fi
Dean Troyerf4d23952012-03-28 11:19:24 -050034fi
35
36# Swift runs daemons
37if is_service_enabled swift; then
38 swift-init all stop
39fi
40
41# Apache has the WSGI processes
42if is_service_enabled horizon; then
43 stop_service apache2
44fi
45
46# Get the iSCSI volumes
Dean Troyer67787e62012-05-02 11:48:15 -050047if is_service_enabled cinder n-vol; then
Dean Troyerf4d23952012-03-28 11:19:24 -050048 TARGETS=$(sudo tgtadm --op show --mode target)
49 if [[ -n "$TARGETS" ]]; then
50 # FIXME(dtroyer): this could very well require more here to
51 # clean up left-over volumes
52 echo "iSCSI target cleanup needed:"
53 echo "$TARGETS"
54 fi
Dean Troyer5218d452012-02-04 02:13:23 -060055 stop_service tgt
Dean Troyerf4d23952012-03-28 11:19:24 -050056fi
57
58if [[ -n "$UNSTACK_ALL" ]]; then
59 # Stop MySQL server
60 if is_service_enabled mysql; then
61 stop_service mysql
62 fi
63fi