blob: 0457ef239325a2d444d67277534ac6f9089492ad [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
Dean Troyer23f69d82013-10-04 12:35:24 -050027if [[ $EUID -eq 0 ]]; then
28 echo "You are running this script as root."
29 echo "It might work but you will have a better day running it as $STACK_USER"
30 exit 1
31fi
32
Brant Knudson0049c0c2014-01-16 18:16:48 -060033
34# Configure Projects
35# ==================
36
zhang-hared98a5d02013-06-21 18:18:02 +080037# Import apache functions
38source $TOP_DIR/lib/apache
39
Brant Knudson0049c0c2014-01-16 18:16:48 -060040# Import TLS functions
41source $TOP_DIR/lib/tls
42
43# Source project function libraries
44source $TOP_DIR/lib/infra
45source $TOP_DIR/lib/oslo
46source $TOP_DIR/lib/stackforge
47source $TOP_DIR/lib/horizon
Dean Troyer9fc87922013-05-22 17:19:06 -050048source $TOP_DIR/lib/keystone
49source $TOP_DIR/lib/glance
50source $TOP_DIR/lib/nova
Brant Knudson0049c0c2014-01-16 18:16:48 -060051source $TOP_DIR/lib/cinder
Attila Fazekasece6a332012-11-29 14:19:41 +010052source $TOP_DIR/lib/swift
Brant Knudson0049c0c2014-01-16 18:16:48 -060053source $TOP_DIR/lib/ceilometer
54source $TOP_DIR/lib/heat
Mark McClainb05c8762013-07-06 23:29:39 -040055source $TOP_DIR/lib/neutron
Brant Knudson0049c0c2014-01-16 18:16:48 -060056source $TOP_DIR/lib/baremetal
57source $TOP_DIR/lib/ldap
John Griffithd53bedc2012-09-11 14:15:54 -060058
Dean Troyercdf3d762013-10-15 09:42:43 -050059# Extras Source
60# --------------
61
62# Phase: source
63if [[ -d $TOP_DIR/extras.d ]]; then
64 for i in $TOP_DIR/extras.d/*.sh; do
65 [[ -r $i ]] && source $i source
66 done
67fi
68
Dean Troyerf4d23952012-03-28 11:19:24 -050069# Determine what system we are running on. This provides ``os_VENDOR``,
70# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
71GetOSVersion
72
73if [[ "$1" == "--all" ]]; then
74 UNSTACK_ALL=${UNSTACK_ALL:-1}
75fi
76
Dean Troyer768295e2013-01-09 13:42:03 -060077# Run extras
78# ==========
79
Dean Troyercdf3d762013-10-15 09:42:43 -050080# Phase: unstack
Dean Troyer768295e2013-01-09 13:42:03 -060081if [[ -d $TOP_DIR/extras.d ]]; then
82 for i in $TOP_DIR/extras.d/*.sh; do
83 [[ -r $i ]] && source $i unstack
84 done
85fi
86
Nachi Ueno8bc21f62012-11-19 22:04:28 -080087if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
88 source $TOP_DIR/openrc
Mark McClainb05c8762013-07-06 23:29:39 -040089 teardown_neutron_debug
Nachi Ueno8bc21f62012-11-19 22:04:28 -080090fi
91
Dean Troyer9fc87922013-05-22 17:19:06 -050092# Call service stop
Dean Troyerf4d23952012-03-28 11:19:24 -050093
Dean Troyer9fc87922013-05-22 17:19:06 -050094if is_service_enabled heat; then
95 stop_heat
96fi
97
98if is_service_enabled ceilometer; then
99 stop_ceilometer
100fi
101
102if is_service_enabled nova; then
103 stop_nova
104fi
105
Dean Troyere4fa7212014-01-15 15:04:49 -0600106if is_service_enabled glance; then
Dean Troyer9fc87922013-05-22 17:19:06 -0500107 stop_glance
108fi
109
110if is_service_enabled key; then
111 stop_keystone
Dean Troyer2aa2a892013-08-04 19:53:19 -0500112fi
113
Dean Troyerf4d23952012-03-28 11:19:24 -0500114# Swift runs daemons
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100115if is_service_enabled s-proxy; then
Attila Fazekasece6a332012-11-29 14:19:41 +0100116 stop_swift
Chmouel Boudjnah43eb0b32013-01-12 20:10:34 +0000117 cleanup_swift
Dean Troyerf4d23952012-03-28 11:19:24 -0500118fi
119
120# Apache has the WSGI processes
121if is_service_enabled horizon; then
Sean Dagueb562e6a2012-11-19 16:00:01 -0500122 stop_horizon
Dean Troyerf4d23952012-03-28 11:19:24 -0500123fi
124
Stanislaw Pituchabd5dae02014-06-25 15:29:43 +0100125# Kill TLS proxies and cleanup certificates
Dean Troyerc83a7e12012-11-29 11:47:58 -0600126if is_service_enabled tls-proxy; then
Stanislaw Pituchabd5dae02014-06-25 15:29:43 +0100127 stop_tls_proxy
128 cleanup_CA
Dean Troyerc83a7e12012-11-29 11:47:58 -0600129fi
130
John Griffithd53bedc2012-09-11 14:15:54 -0600131SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
132
Dean Troyerf4d23952012-03-28 11:19:24 -0500133# Get the iSCSI volumes
Joe Gordon6fd28112012-11-13 16:55:41 -0800134if is_service_enabled cinder; then
Dean Troyer9fc87922013-05-22 17:19:06 -0500135 stop_cinder
Sean Dague252f2f52012-12-20 16:41:57 -0500136 cleanup_cinder
Dean Troyerf4d23952012-03-28 11:19:24 -0500137fi
138
139if [[ -n "$UNSTACK_ALL" ]]; then
140 # Stop MySQL server
141 if is_service_enabled mysql; then
142 stop_service mysql
143 fi
Josh Kearney659eabf2012-09-06 13:47:06 -0500144
Terry Wilson428af5a2012-11-01 16:12:39 -0400145 if is_service_enabled postgresql; then
146 stop_service postgresql
147 fi
148
Josh Kearney659eabf2012-09-06 13:47:06 -0500149 # Stop rabbitmq-server
150 if is_service_enabled rabbit; then
151 stop_service rabbitmq-server
152 fi
Dean Troyerf4d23952012-03-28 11:19:24 -0500153fi
Gary Kotton722fe672012-07-18 07:43:01 -0400154
Mark McClainb05c8762013-07-06 23:29:39 -0400155if is_service_enabled neutron; then
156 stop_neutron
157 stop_neutron_third_party
158 cleanup_neutron
Gary Kotton722fe672012-07-18 07:43:01 -0400159fi
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000160
Nikhil Manchanda0cccad42012-12-03 18:15:09 -0700161if is_service_enabled trove; then
162 cleanup_trove
163fi
164
Joe Gordone0b08d02014-08-20 00:34:55 -0700165stop_dstat
166
Dean Troyer9fc87922013-05-22 17:19:06 -0500167# Clean up the remainder of the screen processes
168SCREEN=$(which screen)
169if [[ -n "$SCREEN" ]]; then
170 SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
171 if [[ -n "$SESSION" ]]; then
172 screen -X -S $SESSION quit
173 fi
174fi
175
Ian Wienand31dcd3e2013-07-16 13:36:34 +1000176cleanup_tmp