blob: fd70916d91ff8eed824b493341858b8ab7839812 [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
Terry Wilson428af5a2012-11-01 16:12:39 -040018# Import database library
19source $TOP_DIR/lib/database
20
Dean Troyerf4d23952012-03-28 11:19:24 -050021# Load local configuration
22source $TOP_DIR/stackrc
23
John Griffithd53bedc2012-09-11 14:15:54 -060024# Destination path for service data
25DATA_DIR=${DATA_DIR:-${DEST}/data}
26
27# Get project function libraries
Devananda van der Veen7611c892012-11-23 10:54:54 -080028source $TOP_DIR/lib/baremetal
John Griffithd53bedc2012-09-11 14:15:54 -060029source $TOP_DIR/lib/cinder
Sean Dagueb562e6a2012-11-19 16:00:01 -050030source $TOP_DIR/lib/horizon
Attila Fazekasece6a332012-11-29 14:19:41 +010031source $TOP_DIR/lib/swift
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090032source $TOP_DIR/lib/quantum
John Griffithd53bedc2012-09-11 14:15:54 -060033
Dean Troyerf4d23952012-03-28 11:19:24 -050034# Determine what system we are running on. This provides ``os_VENDOR``,
35# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
36GetOSVersion
37
38if [[ "$1" == "--all" ]]; then
39 UNSTACK_ALL=${UNSTACK_ALL:-1}
40fi
41
Nachi Ueno8bc21f62012-11-19 22:04:28 -080042if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
43 source $TOP_DIR/openrc
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090044 teardown_quantum_debug
Nachi Ueno8bc21f62012-11-19 22:04:28 -080045fi
46
Dean Troyerf4d23952012-03-28 11:19:24 -050047# Shut down devstack's screen to get the bulk of OpenStack services in one shot
Dean Troyereeaf2662012-06-14 09:11:38 -050048SCREEN=$(which screen)
49if [[ -n "$SCREEN" ]]; then
50 SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
51 if [[ -n "$SESSION" ]]; then
52 screen -X -S $SESSION quit
53 fi
Dean Troyerf4d23952012-03-28 11:19:24 -050054fi
55
56# Swift runs daemons
57if is_service_enabled swift; then
Attila Fazekasece6a332012-11-29 14:19:41 +010058 stop_swift
Dean Troyerf4d23952012-03-28 11:19:24 -050059fi
60
61# Apache has the WSGI processes
62if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -050063 stop_horizon
Dean Troyerf4d23952012-03-28 11:19:24 -050064fi
65
Dean Troyerc83a7e12012-11-29 11:47:58 -060066# Kill TLS proxies
67if is_service_enabled tls-proxy; then
68 killall stud
69fi
70
Devananda van der Veen7611c892012-11-23 10:54:54 -080071# baremetal might have created a fake environment
72if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then
73 cleanup_fake_baremetal_env
74fi
75
John Griffithd53bedc2012-09-11 14:15:54 -060076SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
77
Dean Troyerf4d23952012-03-28 11:19:24 -050078# Get the iSCSI volumes
Joe Gordon6fd28112012-11-13 16:55:41 -080079if is_service_enabled cinder; then
Sean Dague252f2f52012-12-20 16:41:57 -050080 cleanup_cinder
Dean Troyerf4d23952012-03-28 11:19:24 -050081fi
82
83if [[ -n "$UNSTACK_ALL" ]]; then
84 # Stop MySQL server
85 if is_service_enabled mysql; then
86 stop_service mysql
87 fi
Josh Kearney659eabf2012-09-06 13:47:06 -050088
Terry Wilson428af5a2012-11-01 16:12:39 -040089 if is_service_enabled postgresql; then
90 stop_service postgresql
91 fi
92
Josh Kearney659eabf2012-09-06 13:47:06 -050093 # Stop rabbitmq-server
94 if is_service_enabled rabbit; then
95 stop_service rabbitmq-server
96 fi
Dean Troyerf4d23952012-03-28 11:19:24 -050097fi
Gary Kotton722fe672012-07-18 07:43:01 -040098
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090099if is_service_enabled quantum; then
100 stop_quantum
101 stop_quantum_third_party
Gary Kotton722fe672012-07-18 07:43:01 -0400102fi