blob: e73cc2dcfe8297e2e672e8785cbcef122bc113de [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#
Dean Troyer4a43b7b2012-08-28 17:43:40 -05009# Stop all processes by setting ``UNSTACK_ALL`` or specifying ``--all``
Dean Troyerf4d23952012-03-28 11:19:24 -050010# 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
Chmouel Boudjnah84394b92012-08-06 10:07:43 +000040 swift-init all stop 2>/dev/null || true
Dean Troyerf4d23952012-03-28 11:19:24 -050041fi
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
Sascha Peilicke5da67fe2012-07-18 13:27:32 +020057
58 if [[ "$os_PACKAGE" = "deb" ]]; then
59 stop_service tgt
60 else
61 stop_service tgtd
62 fi
Dean Troyerf4d23952012-03-28 11:19:24 -050063fi
64
65if [[ -n "$UNSTACK_ALL" ]]; then
66 # Stop MySQL server
67 if is_service_enabled mysql; then
68 stop_service mysql
69 fi
70fi
Gary Kotton722fe672012-07-18 07:43:01 -040071
72# Quantum dhcp agent runs dnsmasq
73if is_service_enabled q-dhcp; then
74 sudo kill -9 $(ps aux | awk '/[d]nsmasq.+interface=tap/ { print $2 }')
75fi