Sean Dague | 9a413ab | 2015-02-04 12:44:18 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Dean Troyer | 7d28a0e | 2012-06-27 17:55:52 -0500 | [diff] [blame] | 2 | |
3 | # **unstack.sh** | ||||
4 | |||||
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 5 | # 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 | # | ||||
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 9 | # Stop all processes by setting ``UNSTACK_ALL`` or specifying ``-a`` |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 10 | # on the command line |
11 | |||||
Mike Chester | 8040e69 | 2016-02-17 10:52:33 -0800 | [diff] [blame] | 12 | UNSTACK_ALL=${UNSTACK_ALL:-""} |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 13 | |
14 | while getopts ":a" opt; do | ||||
15 | case $opt in | ||||
16 | a) | ||||
Mike Chester | 8040e69 | 2016-02-17 10:52:33 -0800 | [diff] [blame] | 17 | UNSTACK_ALL="-1" |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 18 | ;; |
19 | esac | ||||
20 | done | ||||
21 | |||||
Dean Troyer | dc97cb7 | 2015-03-28 08:20:50 -0500 | [diff] [blame] | 22 | # Keep track of the current DevStack directory. |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 23 | TOP_DIR=$(cd $(dirname "$0") && pwd) |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 24 | FILES=$TOP_DIR/files |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 25 | |
26 | # Import common functions | ||||
27 | source $TOP_DIR/functions | ||||
28 | |||||
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 29 | # Import database library |
30 | source $TOP_DIR/lib/database | ||||
31 | |||||
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 32 | # Load local configuration |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 33 | source $TOP_DIR/openrc |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 34 | |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 35 | # Destination path for service data |
36 | DATA_DIR=${DATA_DIR:-${DEST}/data} | ||||
37 | |||||
Dean Troyer | 23f69d8 | 2013-10-04 12:35:24 -0500 | [diff] [blame] | 38 | if [[ $EUID -eq 0 ]]; then |
39 | echo "You are running this script as root." | ||||
40 | echo "It might work but you will have a better day running it as $STACK_USER" | ||||
41 | exit 1 | ||||
42 | fi | ||||
43 | |||||
Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 44 | |
45 | # Configure Projects | ||||
46 | # ================== | ||||
47 | |||||
Wei Jiangang | be65c6f | 2015-09-14 18:52:47 +0800 | [diff] [blame] | 48 | # Plugin Phase 0: override_defaults - allow plugins to override |
Sean Dague | 6e275e1 | 2015-03-26 05:54:28 -0400 | [diff] [blame] | 49 | # defaults before other services are run |
50 | run_phase override_defaults | ||||
51 | |||||
zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 52 | # Import apache functions |
53 | source $TOP_DIR/lib/apache | ||||
54 | |||||
Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 55 | # Import TLS functions |
56 | source $TOP_DIR/lib/tls | ||||
57 | |||||
58 | # Source project function libraries | ||||
59 | source $TOP_DIR/lib/infra | ||||
60 | source $TOP_DIR/lib/oslo | ||||
Daniel Genin | d470867 | 2014-10-31 15:01:29 -0400 | [diff] [blame] | 61 | source $TOP_DIR/lib/lvm |
Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 62 | source $TOP_DIR/lib/horizon |
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 63 | source $TOP_DIR/lib/keystone |
64 | source $TOP_DIR/lib/glance | ||||
65 | source $TOP_DIR/lib/nova | ||||
Chris Dent | 4d60175 | 2016-07-12 19:34:09 +0000 | [diff] [blame^] | 66 | source $TOP_DIR/lib/placement |
Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 67 | source $TOP_DIR/lib/cinder |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 68 | source $TOP_DIR/lib/swift |
Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 69 | source $TOP_DIR/lib/heat |
Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 70 | source $TOP_DIR/lib/neutron |
Dean Troyer | 5a9739a | 2015-03-25 11:33:51 -0500 | [diff] [blame] | 71 | source $TOP_DIR/lib/neutron-legacy |
Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 72 | source $TOP_DIR/lib/ldap |
Martin André | 48a75c1 | 2014-09-08 08:58:58 +0000 | [diff] [blame] | 73 | source $TOP_DIR/lib/dstat |
Sean Dague | 5cad4d3 | 2015-11-10 14:39:07 -0500 | [diff] [blame] | 74 | source $TOP_DIR/lib/dlm |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 75 | |
Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 76 | # Extras Source |
77 | # -------------- | ||||
78 | |||||
79 | # Phase: source | ||||
80 | if [[ -d $TOP_DIR/extras.d ]]; then | ||||
81 | for i in $TOP_DIR/extras.d/*.sh; do | ||||
82 | [[ -r $i ]] && source $i source | ||||
83 | done | ||||
84 | fi | ||||
85 | |||||
Sean Dague | 2c65e71 | 2014-12-18 09:44:56 -0500 | [diff] [blame] | 86 | load_plugin_settings |
87 | |||||
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 88 | # Determine what system we are running on. This provides ``os_VENDOR``, |
Ian Wienand | 7710e7f | 2014-08-27 16:15:32 +1000 | [diff] [blame] | 89 | # ``os_RELEASE``, ``os_PACKAGE``, ``os_CODENAME`` |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 90 | GetOSVersion |
91 | |||||
Sean Dague | e73f88e | 2016-02-03 06:58:39 -0500 | [diff] [blame] | 92 | set -o xtrace |
93 | |||||
Dean Troyer | 768295e | 2013-01-09 13:42:03 -0600 | [diff] [blame] | 94 | # Run extras |
95 | # ========== | ||||
96 | |||||
Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 97 | # Phase: unstack |
Sean Dague | 2c65e71 | 2014-12-18 09:44:56 -0500 | [diff] [blame] | 98 | run_phase unstack |
Dean Troyer | 768295e | 2013-01-09 13:42:03 -0600 | [diff] [blame] | 99 | |
Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 100 | if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then |
101 | source $TOP_DIR/openrc | ||||
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 102 | teardown_neutron_debug |
Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 103 | fi |
104 | |||||
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 105 | # Call service stop |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 106 | |
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 107 | if is_service_enabled heat; then |
108 | stop_heat | ||||
109 | fi | ||||
110 | |||||
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 111 | if is_service_enabled nova; then |
112 | stop_nova | ||||
113 | fi | ||||
114 | |||||
Chris Dent | 4d60175 | 2016-07-12 19:34:09 +0000 | [diff] [blame^] | 115 | if is_service_enabled placement; then |
116 | stop_placement | ||||
117 | fi | ||||
118 | |||||
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 119 | if is_service_enabled glance; then |
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 120 | stop_glance |
121 | fi | ||||
122 | |||||
Dean Troyer | 5ce44cd | 2015-02-12 22:18:33 -0600 | [diff] [blame] | 123 | if is_service_enabled keystone; then |
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 124 | stop_keystone |
Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 125 | fi |
126 | |||||
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 127 | # Swift runs daemons |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 128 | if is_service_enabled s-proxy; then |
Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 129 | stop_swift |
Chmouel Boudjnah | 43eb0b3 | 2013-01-12 20:10:34 +0000 | [diff] [blame] | 130 | cleanup_swift |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 131 | fi |
132 | |||||
133 | # Apache has the WSGI processes | ||||
134 | if is_service_enabled horizon; then | ||||
Sean Dague | b562e6a | 2012-11-19 16:00:01 -0500 | [diff] [blame] | 135 | stop_horizon |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 136 | fi |
137 | |||||
Stanislaw Pitucha | bd5dae0 | 2014-06-25 15:29:43 +0100 | [diff] [blame] | 138 | # Kill TLS proxies and cleanup certificates |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 139 | if is_service_enabled tls-proxy; then |
Stanislaw Pitucha | bd5dae0 | 2014-06-25 15:29:43 +0100 | [diff] [blame] | 140 | stop_tls_proxy |
141 | cleanup_CA | ||||
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 142 | fi |
Rob Crittenden | ebcb849 | 2015-02-10 14:16:56 -0500 | [diff] [blame] | 143 | if [ "$USE_SSL" == "True" ]; then |
144 | cleanup_CA | ||||
145 | fi | ||||
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 146 | |
John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 147 | SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/* |
148 | |||||
Sean Dague | 9a413ab | 2015-02-04 12:44:18 -0500 | [diff] [blame] | 149 | # BUG: tgt likes to exit 1 on service stop if everything isn't |
150 | # perfect, we should clean up cinder stop paths. | ||||
151 | |||||
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 152 | # Get the iSCSI volumes |
Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 153 | if is_service_enabled cinder; then |
Sean Dague | 9a413ab | 2015-02-04 12:44:18 -0500 | [diff] [blame] | 154 | stop_cinder || /bin/true |
155 | cleanup_cinder || /bin/true | ||||
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 156 | fi |
157 | |||||
158 | if [[ -n "$UNSTACK_ALL" ]]; then | ||||
159 | # Stop MySQL server | ||||
160 | if is_service_enabled mysql; then | ||||
161 | stop_service mysql | ||||
162 | fi | ||||
Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 163 | |
Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 164 | if is_service_enabled postgresql; then |
165 | stop_service postgresql | ||||
166 | fi | ||||
167 | |||||
Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 168 | # Stop rabbitmq-server |
169 | if is_service_enabled rabbit; then | ||||
170 | stop_service rabbitmq-server | ||||
171 | fi | ||||
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 172 | fi |
Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 173 | |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 174 | if is_service_enabled neutron; then |
175 | stop_neutron | ||||
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 176 | cleanup_neutron |
Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 177 | fi |
Ian Wienand | 31dcd3e | 2013-07-16 13:36:34 +1000 | [diff] [blame] | 178 | |
Mahito OGURA | a519f42 | 2015-03-23 15:19:57 +0900 | [diff] [blame] | 179 | if is_service_enabled dstat; then |
180 | stop_dstat | ||||
181 | fi | ||||
Joe Gordon | e0b08d0 | 2014-08-20 00:34:55 -0700 | [diff] [blame] | 182 | |
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 183 | # Clean up the remainder of the screen processes |
184 | SCREEN=$(which screen) | ||||
185 | if [[ -n "$SCREEN" ]]; then | ||||
Nikolay Fedotov | 7f66503 | 2016-02-24 16:07:18 +0000 | [diff] [blame] | 186 | SESSION=$(screen -ls | awk "/[0-9]+.${SCREEN_NAME}/"'{ print $1 }') |
Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 187 | if [[ -n "$SESSION" ]]; then |
188 | screen -X -S $SESSION quit | ||||
189 | fi | ||||
190 | fi | ||||
Daniel Genin | d470867 | 2014-10-31 15:01:29 -0400 | [diff] [blame] | 191 | |
Sean Dague | 9a413ab | 2015-02-04 12:44:18 -0500 | [diff] [blame] | 192 | # BUG: maybe it doesn't exist? We should isolate this further down. |
Jordan Pittier | 23bf045 | 2015-05-29 11:38:22 +0200 | [diff] [blame] | 193 | # NOTE: Cinder automatically installs the lvm2 package, independently of the |
194 | # enabled backends. So if Cinder is enabled, we are sure lvm (lvremove, | ||||
195 | # /etc/lvm/lvm.conf, etc.) is here. | ||||
196 | if is_service_enabled cinder; then | ||||
197 | clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME || /bin/true | ||||
198 | clean_lvm_filter | ||||
199 | fi |