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 | |
| 18 | # Load local configuration |
| 19 | source $TOP_DIR/stackrc |
| 20 | |
| 21 | # Determine what system we are running on. This provides ``os_VENDOR``, |
| 22 | # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME`` |
| 23 | GetOSVersion |
| 24 | |
| 25 | if [[ "$1" == "--all" ]]; then |
| 26 | UNSTACK_ALL=${UNSTACK_ALL:-1} |
| 27 | fi |
| 28 | |
| 29 | # Shut down devstack's screen to get the bulk of OpenStack services in one shot |
Dean Troyer | eeaf266 | 2012-06-14 09:11:38 -0500 | [diff] [blame] | 30 | SCREEN=$(which screen) |
| 31 | if [[ -n "$SCREEN" ]]; then |
| 32 | SESSION=$(screen -ls | awk '/[0-9].stack/ { print $1 }') |
| 33 | if [[ -n "$SESSION" ]]; then |
| 34 | screen -X -S $SESSION quit |
| 35 | fi |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 36 | fi |
| 37 | |
| 38 | # Swift runs daemons |
| 39 | if is_service_enabled swift; then |
Chmouel Boudjnah | 84394b9 | 2012-08-06 10:07:43 +0000 | [diff] [blame] | 40 | swift-init all stop 2>/dev/null || true |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 41 | fi |
| 42 | |
| 43 | # Apache has the WSGI processes |
| 44 | if is_service_enabled horizon; then |
| 45 | stop_service apache2 |
| 46 | fi |
| 47 | |
| 48 | # Get the iSCSI volumes |
Dean Troyer | 67787e6 | 2012-05-02 11:48:15 -0500 | [diff] [blame] | 49 | if is_service_enabled cinder n-vol; then |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 50 | TARGETS=$(sudo tgtadm --op show --mode target) |
| 51 | if [[ -n "$TARGETS" ]]; then |
| 52 | # FIXME(dtroyer): this could very well require more here to |
| 53 | # clean up left-over volumes |
| 54 | echo "iSCSI target cleanup needed:" |
| 55 | echo "$TARGETS" |
| 56 | fi |
Sascha Peilicke | 5da67fe | 2012-07-18 13:27:32 +0200 | [diff] [blame] | 57 | |
| 58 | if [[ "$os_PACKAGE" = "deb" ]]; then |
| 59 | stop_service tgt |
| 60 | else |
| 61 | stop_service tgtd |
| 62 | fi |
Dean Troyer | f4d2395 | 2012-03-28 11:19:24 -0500 | [diff] [blame] | 63 | fi |
| 64 | |
| 65 | if [[ -n "$UNSTACK_ALL" ]]; then |
| 66 | # Stop MySQL server |
| 67 | if is_service_enabled mysql; then |
| 68 | stop_service mysql |
| 69 | fi |
| 70 | fi |
Gary Kotton | 722fe67 | 2012-07-18 07:43:01 -0400 | [diff] [blame] | 71 | |
| 72 | # Quantum dhcp agent runs dnsmasq |
| 73 | if is_service_enabled q-dhcp; then |
| 74 | sudo kill -9 $(ps aux | awk '/[d]nsmasq.+interface=tap/ { print $2 }') |
| 75 | fi |