unstack.sh
f4d2395e
 #!/usr/bin/env bash
7d28a0e1
 
 # **unstack.sh**
 
f4d2395e
 # Stops that which is started by ``stack.sh`` (mostly)
 # mysql and rabbit are left running as OpenStack code refreshes
 # do not require them to be restarted.
 #
4a43b7bd
 # Stop all processes by setting ``UNSTACK_ALL`` or specifying ``--all``
f4d2395e
 # on the command line
 
 # Keep track of the current devstack directory.
 TOP_DIR=$(cd $(dirname "$0") && pwd)
 
 # Import common functions
 source $TOP_DIR/functions
 
428af5a2
 # Import database library
 source $TOP_DIR/lib/database
 
f4d2395e
 # Load local configuration
 source $TOP_DIR/stackrc
 
d53bedc6
 # Destination path for service data
 DATA_DIR=${DATA_DIR:-${DEST}/data}
 
23f69d83
 if [[ $EUID -eq 0 ]]; then
     echo "You are running this script as root."
     echo "It might work but you will have a better day running it as $STACK_USER"
     exit 1
 fi
 
0049c0c4
 
 # Configure Projects
 # ==================
 
d98a5d0a
 # Import apache functions
 source $TOP_DIR/lib/apache
 
0049c0c4
 # Import TLS functions
 source $TOP_DIR/lib/tls
 
 # Source project function libraries
 source $TOP_DIR/lib/infra
 source $TOP_DIR/lib/oslo
 source $TOP_DIR/lib/stackforge
 source $TOP_DIR/lib/horizon
9fc8792b
 source $TOP_DIR/lib/keystone
 source $TOP_DIR/lib/glance
 source $TOP_DIR/lib/nova
0049c0c4
 source $TOP_DIR/lib/cinder
ece6a332
 source $TOP_DIR/lib/swift
0049c0c4
 source $TOP_DIR/lib/ceilometer
 source $TOP_DIR/lib/heat
b05c8769
 source $TOP_DIR/lib/neutron
0049c0c4
 source $TOP_DIR/lib/baremetal
 source $TOP_DIR/lib/ldap
d53bedc6
 
cdf3d766
 # Extras Source
 # --------------
 
 # Phase: source
 if [[ -d $TOP_DIR/extras.d ]]; then
     for i in $TOP_DIR/extras.d/*.sh; do
         [[ -r $i ]] && source $i source
     done
 fi
 
f4d2395e
 # Determine what system we are running on.  This provides ``os_VENDOR``,
 # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
 GetOSVersion
 
 if [[ "$1" == "--all" ]]; then
     UNSTACK_ALL=${UNSTACK_ALL:-1}
 fi
 
768295e9
 # Run extras
 # ==========
 
cdf3d766
 # Phase: unstack
768295e9
 if [[ -d $TOP_DIR/extras.d ]]; then
     for i in $TOP_DIR/extras.d/*.sh; do
         [[ -r $i ]] && source $i unstack
     done
 fi
 
8bc21f64
 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
     source $TOP_DIR/openrc
b05c8769
     teardown_neutron_debug
8bc21f64
 fi
 
9fc8792b
 # Call service stop
 
 if is_service_enabled heat; then
     stop_heat
f4d2395e
 fi
 
9fc8792b
 if is_service_enabled ceilometer; then
     stop_ceilometer
 fi
 
 if is_service_enabled nova; then
     stop_nova
 fi
 
e4fa7213
 if is_service_enabled glance; then
9fc8792b
     stop_glance
 fi
 
 if is_service_enabled key; then
     stop_keystone
2aa2a89c
 fi
 
f4d2395e
 # Swift runs daemons
0c3a5584
 if is_service_enabled s-proxy; then
ece6a332
     stop_swift
43eb0b31
     cleanup_swift
f4d2395e
 fi
 
 # Apache has the WSGI processes
 if is_service_enabled horizon; then
b562e6a7
     stop_horizon
f4d2395e
 fi
 
c83a7e12
 # Kill TLS proxies
 if is_service_enabled tls-proxy; then
     killall stud
 fi
 
d53bedc6
 SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
 
f4d2395e
 # Get the iSCSI volumes
6fd28117
 if is_service_enabled cinder; then
9fc8792b
     stop_cinder
252f2f53
     cleanup_cinder
f4d2395e
 fi
 
 if [[ -n "$UNSTACK_ALL" ]]; then
     # Stop MySQL server
     if is_service_enabled mysql; then
         stop_service mysql
     fi
659eabfb
 
428af5a2
     if is_service_enabled postgresql; then
         stop_service postgresql
     fi
 
659eabfb
     # Stop rabbitmq-server
     if is_service_enabled rabbit; then
         stop_service rabbitmq-server
     fi
f4d2395e
 fi
722fe673
 
b05c8769
 if is_service_enabled neutron; then
     stop_neutron
     stop_neutron_third_party
     cleanup_neutron
722fe673
 fi
31dcd3e7
 
0cccad43
 if is_service_enabled trove; then
     cleanup_trove
 fi
 
9fc8792b
 # Clean up the remainder of the screen processes
 SCREEN=$(which screen)
 if [[ -n "$SCREEN" ]]; then
     SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }')
     if [[ -n "$SESSION" ]]; then
         screen -X -S $SESSION quit
     fi
 fi
 
31dcd3e7
 cleanup_tmp