| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 1 | #!/usr/bin/env 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 | # | 
| Dean Troyer | 4a43b7b | 2012-08-28 17:43:40 -0500 | [diff] [blame] | 9 | # Stop all processes by setting ``UNSTACK_ALL`` or specifying ``--all`` | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 10 | # on the command line | 
|  | 11 |  | 
|  | 12 | # Keep track of the current devstack directory. | 
|  | 13 | TOP_DIR=$(cd $(dirname "$0") && pwd) | 
|  | 14 |  | 
|  | 15 | # Import common functions | 
|  | 16 | source $TOP_DIR/functions | 
|  | 17 |  | 
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 18 | # Import database library | 
|  | 19 | source $TOP_DIR/lib/database | 
|  | 20 |  | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 21 | # Load local configuration | 
|  | 22 | source $TOP_DIR/stackrc | 
|  | 23 |  | 
| John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 24 | # Destination path for service data | 
|  | 25 | DATA_DIR=${DATA_DIR:-${DEST}/data} | 
|  | 26 |  | 
| Dean Troyer | 23f69d8 | 2013-10-04 12:35:24 -0500 | [diff] [blame] | 27 | if [[ $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 | 
|  | 31 | fi | 
|  | 32 |  | 
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 33 |  | 
|  | 34 | # Configure Projects | 
|  | 35 | # ================== | 
|  | 36 |  | 
| zhang-hare | d98a5d0 | 2013-06-21 18:18:02 +0800 | [diff] [blame] | 37 | # Import apache functions | 
|  | 38 | source $TOP_DIR/lib/apache | 
|  | 39 |  | 
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 40 | # Import TLS functions | 
|  | 41 | source $TOP_DIR/lib/tls | 
|  | 42 |  | 
|  | 43 | # Source project function libraries | 
|  | 44 | source $TOP_DIR/lib/infra | 
|  | 45 | source $TOP_DIR/lib/oslo | 
|  | 46 | source $TOP_DIR/lib/stackforge | 
|  | 47 | source $TOP_DIR/lib/horizon | 
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 48 | source $TOP_DIR/lib/keystone | 
|  | 49 | source $TOP_DIR/lib/glance | 
|  | 50 | source $TOP_DIR/lib/nova | 
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 51 | source $TOP_DIR/lib/cinder | 
| Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 52 | source $TOP_DIR/lib/swift | 
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 53 | source $TOP_DIR/lib/ceilometer | 
|  | 54 | source $TOP_DIR/lib/heat | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 55 | source $TOP_DIR/lib/neutron | 
| Brant Knudson | 0049c0c | 2014-01-16 18:16:48 -0600 | [diff] [blame] | 56 | source $TOP_DIR/lib/baremetal | 
|  | 57 | source $TOP_DIR/lib/ldap | 
| Roman Prykhodchenko | ce696b6 | 2013-08-09 10:40:45 +0300 | [diff] [blame] | 58 | source $TOP_DIR/lib/ironic | 
| Nikhil Manchanda | 0cccad4 | 2012-12-03 18:15:09 -0700 | [diff] [blame] | 59 | source $TOP_DIR/lib/trove | 
| John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 60 |  | 
| Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 61 | # Extras Source | 
|  | 62 | # -------------- | 
|  | 63 |  | 
|  | 64 | # Phase: source | 
|  | 65 | if [[ -d $TOP_DIR/extras.d ]]; then | 
|  | 66 | for i in $TOP_DIR/extras.d/*.sh; do | 
|  | 67 | [[ -r $i ]] && source $i source | 
|  | 68 | done | 
|  | 69 | fi | 
|  | 70 |  | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 71 | # Determine what system we are running on.  This provides ``os_VENDOR``, | 
|  | 72 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` | 
|  | 73 | GetOSVersion | 
|  | 74 |  | 
|  | 75 | if [[ "$1" == "--all" ]]; then | 
|  | 76 | UNSTACK_ALL=${UNSTACK_ALL:-1} | 
|  | 77 | fi | 
|  | 78 |  | 
| Dean Troyer | 768295e | 2013-01-09 13:42:03 -0600 | [diff] [blame] | 79 | # Run extras | 
|  | 80 | # ========== | 
|  | 81 |  | 
| Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 82 | # Phase: unstack | 
| Dean Troyer | 768295e | 2013-01-09 13:42:03 -0600 | [diff] [blame] | 83 | if [[ -d $TOP_DIR/extras.d ]]; then | 
|  | 84 | for i in $TOP_DIR/extras.d/*.sh; do | 
|  | 85 | [[ -r $i ]] && source $i unstack | 
|  | 86 | done | 
|  | 87 | fi | 
|  | 88 |  | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 89 | if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then | 
|  | 90 | source $TOP_DIR/openrc | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 91 | teardown_neutron_debug | 
| Nachi Ueno | 8bc21f6 | 2012-11-19 22:04:28 -0800 | [diff] [blame] | 92 | fi | 
|  | 93 |  | 
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 94 | # Call service stop | 
|  | 95 | if is_service_enabled trove; then | 
|  | 96 | stop_trove | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 97 | fi | 
|  | 98 |  | 
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 99 | if is_service_enabled heat; then | 
|  | 100 | stop_heat | 
|  | 101 | fi | 
|  | 102 |  | 
|  | 103 | if is_service_enabled ceilometer; then | 
|  | 104 | stop_ceilometer | 
|  | 105 | fi | 
|  | 106 |  | 
|  | 107 | if is_service_enabled nova; then | 
|  | 108 | stop_nova | 
|  | 109 | fi | 
|  | 110 |  | 
|  | 111 | if is_service_enabled g-api g-reg; then | 
|  | 112 | stop_glance | 
|  | 113 | fi | 
|  | 114 |  | 
|  | 115 | if is_service_enabled key; then | 
|  | 116 | stop_keystone | 
| Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 117 | fi | 
|  | 118 |  | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 119 | # Swift runs daemons | 
| Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 120 | if is_service_enabled s-proxy; then | 
| Attila Fazekas | ece6a33 | 2012-11-29 14:19:41 +0100 | [diff] [blame] | 121 | stop_swift | 
| Chmouel Boudjnah | 43eb0b3 | 2013-01-12 20:10:34 +0000 | [diff] [blame] | 122 | cleanup_swift | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 123 | fi | 
|  | 124 |  | 
| Roman Prykhodchenko | ce696b6 | 2013-08-09 10:40:45 +0300 | [diff] [blame] | 125 | # Ironic runs daemons | 
|  | 126 | if is_service_enabled ir-api ir-cond; then | 
|  | 127 | stop_ironic | 
|  | 128 | cleanup_ironic | 
|  | 129 | fi | 
|  | 130 |  | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 131 | # Apache has the WSGI processes | 
|  | 132 | if is_service_enabled horizon; then | 
| Sean Dague | b562e6a | 2012-11-19 16:00:01 -0500 | [diff] [blame] | 133 | stop_horizon | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 134 | fi | 
|  | 135 |  | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 136 | # Kill TLS proxies | 
|  | 137 | if is_service_enabled tls-proxy; then | 
|  | 138 | killall stud | 
|  | 139 | fi | 
|  | 140 |  | 
| Devananda van der Veen | 7611c89 | 2012-11-23 10:54:54 -0800 | [diff] [blame] | 141 | # baremetal might have created a fake environment | 
|  | 142 | if is_service_enabled baremetal && [[ "$BM_USE_FAKE_ENV" = "True" ]]; then | 
|  | 143 | cleanup_fake_baremetal_env | 
|  | 144 | fi | 
|  | 145 |  | 
| John Griffith | d53bedc | 2012-09-11 14:15:54 -0600 | [diff] [blame] | 146 | SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/* | 
|  | 147 |  | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 148 | # Get the iSCSI volumes | 
| Joe Gordon | 6fd2811 | 2012-11-13 16:55:41 -0800 | [diff] [blame] | 149 | if is_service_enabled cinder; then | 
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 150 | stop_cinder | 
| Sean Dague | 252f2f5 | 2012-12-20 16:41:57 -0500 | [diff] [blame] | 151 | cleanup_cinder | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 152 | fi | 
|  | 153 |  | 
|  | 154 | if [[ -n "$UNSTACK_ALL" ]]; then | 
|  | 155 | # Stop MySQL server | 
|  | 156 | if is_service_enabled mysql; then | 
|  | 157 | stop_service mysql | 
|  | 158 | fi | 
| Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 159 |  | 
| Terry Wilson | 428af5a | 2012-11-01 16:12:39 -0400 | [diff] [blame] | 160 | if is_service_enabled postgresql; then | 
|  | 161 | stop_service postgresql | 
|  | 162 | fi | 
|  | 163 |  | 
| Josh Kearney | 659eabf | 2012-09-06 13:47:06 -0500 | [diff] [blame] | 164 | # Stop rabbitmq-server | 
|  | 165 | if is_service_enabled rabbit; then | 
|  | 166 | stop_service rabbitmq-server | 
|  | 167 | fi | 
| Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 168 | fi | 
| Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 169 |  | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 170 | if is_service_enabled neutron; then | 
|  | 171 | stop_neutron | 
|  | 172 | stop_neutron_third_party | 
|  | 173 | cleanup_neutron | 
| Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 174 | fi | 
| Ian Wienand | 31dcd3e | 2013-07-16 13:36:34 +1000 | [diff] [blame] | 175 |  | 
| Nikhil Manchanda | 0cccad4 | 2012-12-03 18:15:09 -0700 | [diff] [blame] | 176 | if is_service_enabled trove; then | 
|  | 177 | cleanup_trove | 
|  | 178 | fi | 
|  | 179 |  | 
| Dean Troyer | 9fc8792 | 2013-05-22 17:19:06 -0500 | [diff] [blame] | 180 | # Clean up the remainder of the screen processes | 
|  | 181 | SCREEN=$(which screen) | 
|  | 182 | if [[ -n "$SCREEN" ]]; then | 
|  | 183 | SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }') | 
|  | 184 | if [[ -n "$SESSION" ]]; then | 
|  | 185 | screen -X -S $SESSION quit | 
|  | 186 | fi | 
|  | 187 | fi | 
|  | 188 |  | 
| Ian Wienand | 31dcd3e | 2013-07-16 13:36:34 +1000 | [diff] [blame] | 189 | cleanup_tmp |