unstack.sh
9a413abc
 #!/bin/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.
 #
53753293
 # Stop all processes by setting ``UNSTACK_ALL`` or specifying ``-a``
f4d2395e
 # on the command line
 
8040e69a
 UNSTACK_ALL=${UNSTACK_ALL:-""}
53753293
 
 while getopts ":a" opt; do
     case $opt in
         a)
8040e69a
             UNSTACK_ALL="-1"
53753293
             ;;
     esac
 done
 
dc97cb71
 # Keep track of the current DevStack directory.
f4d2395e
 TOP_DIR=$(cd $(dirname "$0") && pwd)
53753293
 FILES=$TOP_DIR/files
f4d2395e
 
 # Import common functions
 source $TOP_DIR/functions
 
428af5a2
 # Import database library
 source $TOP_DIR/lib/database
 
f4d2395e
 # Load local configuration
53753293
 source $TOP_DIR/openrc
f4d2395e
 
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
 # ==================
 
7b1b6f34
 # Determine what system we are running on.  This provides ``os_VENDOR``,
 # ``os_RELEASE``, ``os_PACKAGE``, ``os_CODENAME`` and ``DISTRO``
 GetDistro
 
be65c6f8
 # Plugin Phase 0: override_defaults - allow plugins to override
6e275e17
 # defaults before other services are run
 run_phase override_defaults
 
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
d470867f
 source $TOP_DIR/lib/lvm
0049c0c4
 source $TOP_DIR/lib/horizon
9fc8792b
 source $TOP_DIR/lib/keystone
 source $TOP_DIR/lib/glance
 source $TOP_DIR/lib/nova
4d601756
 source $TOP_DIR/lib/placement
0049c0c4
 source $TOP_DIR/lib/cinder
ece6a332
 source $TOP_DIR/lib/swift
2a242519
 source $TOP_DIR/lib/neutron
0049c0c4
 source $TOP_DIR/lib/ldap
48a75c14
 source $TOP_DIR/lib/dstat
546656fc
 source $TOP_DIR/lib/etcd3
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
 
2c65e71a
 load_plugin_settings
 
e73f88e7
 set -o xtrace
 
768295e9
 # Run extras
 # ==========
 
cdf3d766
 # Phase: unstack
2c65e71a
 run_phase unstack
768295e9
 
9fc8792b
 # Call service stop
 
 if is_service_enabled nova; then
     stop_nova
85c5ec11
     cleanup_nova
9fc8792b
 fi
 
4d601756
 if is_service_enabled placement; then
     stop_placement
 fi
 
e4fa7213
 if is_service_enabled glance; then
9fc8792b
     stop_glance
 fi
 
5ce44cd6
 if is_service_enabled keystone; then
9fc8792b
     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
 
bd5dae06
 # Kill TLS proxies and cleanup certificates
c83a7e12
 if is_service_enabled tls-proxy; then
bd5dae06
     stop_tls_proxy
     cleanup_CA
c83a7e12
 fi
 
d53bedc6
 SCSI_PERSIST_DIR=$CINDER_STATE_PATH/volumes/*
 
9a413abc
 # BUG: tgt likes to exit 1 on service stop if everything isn't
 # perfect, we should clean up cinder stop paths.
 
f4d2395e
 # Get the iSCSI volumes
6fd28117
 if is_service_enabled cinder; then
9a413abc
     stop_cinder || /bin/true
     cleanup_cinder || /bin/true
f4d2395e
 fi
 
 if [[ -n "$UNSTACK_ALL" ]]; then
     # Stop MySQL server
     if is_service_enabled mysql; then
         stop_service mysql
     fi
659eabfb
 
b14665f0
     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
     cleanup_neutron
722fe673
 fi
31dcd3e7
 
546656fc
 if is_service_enabled etcd3; then
     stop_etcd3
     cleanup_etcd3
 fi
 
a519f429
 if is_service_enabled dstat; then
     stop_dstat
 fi
e0b08d04
 
23bf045c
 # NOTE: Cinder automatically installs the lvm2 package, independently of the
40b433fb
 # enabled backends. So if Cinder is enabled, and installed successfully we are
 # sure lvm2 (lvremove, /etc/lvm/lvm.conf, etc.) is here.
 if is_service_enabled cinder && is_package_installed lvm2; then
     # Using /bin/true here indicates a BUG - maybe the
     # DEFAULT_VOLUME_GROUP_NAME doesn't exist?  We should
     # isolate this further down in lib/cinder cleanup.
23bf045c
     clean_lvm_volume_group $DEFAULT_VOLUME_GROUP_NAME || /bin/true
     clean_lvm_filter
 fi