Sean Dague | 9a413ab | 2015-02-04 12:44:18 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 2 | |
| 3 | # **clean.sh** |
| 4 | |
| 5 | # ``clean.sh`` does its best to eradicate traces of a Grenade |
| 6 | # run except for the following: |
| 7 | # - both base and target code repos are left alone |
| 8 | # - packages (system and pip) are left alone |
| 9 | |
| 10 | # This means that all data files are removed. More?? |
| 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 | |
Dean Troyer | b9e2513 | 2013-10-01 14:45:04 -0500 | [diff] [blame] | 18 | FILES=$TOP_DIR/files |
| 19 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 20 | # Load local configuration |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 21 | source $TOP_DIR/openrc |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 22 | |
| 23 | # Get the variables that are set in stack.sh |
Dean Troyer | 58f9cf7 | 2013-06-04 12:51:54 -0500 | [diff] [blame] | 24 | if [[ -r $TOP_DIR/.stackenv ]]; then |
| 25 | source $TOP_DIR/.stackenv |
| 26 | fi |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 27 | |
| 28 | # Determine what system we are running on. This provides ``os_VENDOR``, |
Ian Wienand | 7710e7f | 2014-08-27 16:15:32 +1000 | [diff] [blame] | 29 | # ``os_RELEASE``, ``os_PACKAGE``, ``os_CODENAME`` |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 30 | # and ``DISTRO`` |
| 31 | GetDistro |
| 32 | |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 33 | # Import apache functions |
| 34 | source $TOP_DIR/lib/apache |
| 35 | source $TOP_DIR/lib/ldap |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 36 | |
| 37 | # Import database library |
| 38 | source $TOP_DIR/lib/database |
| 39 | source $TOP_DIR/lib/rpc_backend |
| 40 | |
| 41 | source $TOP_DIR/lib/tls |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 42 | |
Takashi Kajinami | ef63c69 | 2024-11-24 22:48:08 +0900 | [diff] [blame] | 43 | source $TOP_DIR/lib/libraries |
Mahito | 67168e8 | 2015-08-18 23:59:29 -0700 | [diff] [blame] | 44 | source $TOP_DIR/lib/lvm |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 45 | source $TOP_DIR/lib/horizon |
| 46 | source $TOP_DIR/lib/keystone |
| 47 | source $TOP_DIR/lib/glance |
| 48 | source $TOP_DIR/lib/nova |
Chris Dent | 4d60175 | 2016-07-12 19:34:09 +0000 | [diff] [blame] | 49 | source $TOP_DIR/lib/placement |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 50 | source $TOP_DIR/lib/cinder |
| 51 | source $TOP_DIR/lib/swift |
Sean M. Collins | 2a24251 | 2016-05-03 09:03:09 -0400 | [diff] [blame] | 52 | source $TOP_DIR/lib/neutron |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 53 | |
Sean Dague | e73f88e | 2016-02-03 06:58:39 -0500 | [diff] [blame] | 54 | set -o xtrace |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 55 | |
Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 56 | # Extras Source |
| 57 | # -------------- |
| 58 | |
| 59 | # Phase: source |
| 60 | if [[ -d $TOP_DIR/extras.d ]]; then |
| 61 | for i in $TOP_DIR/extras.d/*.sh; do |
| 62 | [[ -r $i ]] && source $i source |
| 63 | done |
| 64 | fi |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 65 | |
Sean Dague | eaadffe | 2017-05-04 16:05:19 -0400 | [diff] [blame] | 66 | # Let unstack.sh do its thing first |
| 67 | $TOP_DIR/unstack.sh --all |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 68 | |
Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 69 | # Run extras |
| 70 | # ========== |
| 71 | |
| 72 | # Phase: clean |
ajmiller | e6843e5 | 2015-04-11 09:52:48 -0700 | [diff] [blame] | 73 | load_plugin_settings |
Al Miller | a1701fa | 2015-02-20 08:10:41 -0800 | [diff] [blame] | 74 | run_phase clean |
| 75 | |
Dean Troyer | cdf3d76 | 2013-10-15 09:42:43 -0500 | [diff] [blame] | 76 | if [[ -d $TOP_DIR/extras.d ]]; then |
| 77 | for i in $TOP_DIR/extras.d/*.sh; do |
| 78 | [[ -r $i ]] && source $i clean |
| 79 | done |
| 80 | fi |
| 81 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 82 | # Clean projects |
Sean Dague | 9a413ab | 2015-02-04 12:44:18 -0500 | [diff] [blame] | 83 | |
| 84 | # BUG: cinder tgt doesn't exit cleanly if it's not running. |
| 85 | cleanup_cinder || /bin/true |
| 86 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 87 | cleanup_glance |
| 88 | cleanup_keystone |
| 89 | cleanup_nova |
Davanum Srinivas | aa33c87 | 2017-08-16 22:51:07 -0400 | [diff] [blame] | 90 | cleanup_placement |
Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 91 | cleanup_neutron |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 92 | cleanup_swift |
Rob Crittenden | 5631ca5 | 2016-08-02 13:19:14 -0400 | [diff] [blame] | 93 | cleanup_horizon |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 94 | |
Dean Troyer | b9e2513 | 2013-10-01 14:45:04 -0500 | [diff] [blame] | 95 | if is_service_enabled ldap; then |
| 96 | cleanup_ldap |
| 97 | fi |
| 98 | |
Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 99 | # Do the hypervisor cleanup until this can be moved back into lib/nova |
Dean Troyer | e4fa721 | 2014-01-15 15:04:49 -0600 | [diff] [blame] | 100 | if is_service_enabled nova && [[ -r $NOVA_PLUGINS/hypervisor-$VIRT_DRIVER ]]; then |
Dean Troyer | 2aa2a89 | 2013-08-04 19:53:19 -0500 | [diff] [blame] | 101 | cleanup_nova_hypervisor |
| 102 | fi |
| 103 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 104 | # Clean out /etc |
xiaolihope | 8f985b6 | 2016-05-18 00:32:08 +0800 | [diff] [blame] | 105 | sudo rm -rf /etc/keystone /etc/glance /etc/nova /etc/cinder /etc/swift /etc/neutron /etc/openstack/ |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 106 | |
| 107 | # Clean out tgt |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 108 | sudo rm -f /etc/tgt/conf.d/* |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 109 | |
| 110 | # Clean up the message queue |
| 111 | cleanup_rpc_backend |
| 112 | cleanup_database |
| 113 | |
Davanum Srinivas | 93d09c2 | 2015-04-11 18:45:09 -0400 | [diff] [blame] | 114 | # Clean out data and status |
Dan Smith | 30d9bf9 | 2021-01-19 12:10:52 -0800 | [diff] [blame] | 115 | sudo rm -rf $DATA_DIR $DEST/status $DEST/async |
Davanum Srinivas | 93d09c2 | 2015-04-11 18:45:09 -0400 | [diff] [blame] | 116 | |
| 117 | # Clean out the log file and log directories |
| 118 | if [[ -n "$LOGFILE" ]] && [[ -f "$LOGFILE" ]]; then |
| 119 | sudo rm -f $LOGFILE |
| 120 | fi |
| 121 | if [[ -n "$LOGDIR" ]] && [[ -d "$LOGDIR" ]]; then |
| 122 | sudo rm -rf $LOGDIR |
| 123 | fi |
Dean Troyer | 53ffc71 | 2013-12-17 11:13:40 -0600 | [diff] [blame] | 124 | |
Dr. Jens Harbott | 6808a34 | 2020-01-20 15:52:33 +0000 | [diff] [blame] | 125 | # Clean out the systemd unit files. |
| 126 | sudo find $SYSTEMD_DIR -type f -name '*devstack@*service' -delete |
| 127 | # Make systemd aware of the deletion. |
| 128 | $SYSTEMCTL daemon-reload |
Markus Zoeller | 15b0a5f | 2017-05-31 11:21:22 +0200 | [diff] [blame] | 129 | |
Dean Troyer | b1d8e8e | 2015-02-16 13:58:35 -0600 | [diff] [blame] | 130 | # Clean up venvs |
Monty Taylor | 61045ca | 2015-05-14 11:20:39 -0400 | [diff] [blame] | 131 | DIRS_TO_CLEAN="$WHEELHOUSE ${PROJECT_VENV[@]} .config/openstack" |
Dean Troyer | b1d8e8e | 2015-02-16 13:58:35 -0600 | [diff] [blame] | 132 | rm -rf $DIRS_TO_CLEAN |
| 133 | |
Dean Troyer | 995eb92 | 2013-03-07 16:11:40 -0600 | [diff] [blame] | 134 | # Clean up files |
Sean Dague | 2e2b28b | 2014-02-19 09:02:02 -0500 | [diff] [blame] | 135 | |
Ian Wienand | 975f420 | 2015-10-14 15:12:32 +1100 | [diff] [blame] | 136 | FILES_TO_CLEAN=".localrc.auto .localrc.password " |
| 137 | FILES_TO_CLEAN+="docs/files docs/html shocco/ " |
| 138 | FILES_TO_CLEAN+="stack-screenrc test*.conf* test.ini* " |
ZhiQiang Fan | 0b4a009 | 2016-04-12 20:26:33 +0800 | [diff] [blame] | 139 | FILES_TO_CLEAN+=".stackenv .prereqs" |
Sean Dague | 2e2b28b | 2014-02-19 09:02:02 -0500 | [diff] [blame] | 140 | |
Shashank Hegde | cb41569 | 2014-02-27 16:46:43 -0800 | [diff] [blame] | 141 | for file in $FILES_TO_CLEAN; do |
ZhiQiang Fan | ecd0563 | 2014-06-28 16:50:22 +0800 | [diff] [blame] | 142 | rm -rf $TOP_DIR/$file |
Sean Dague | 2e2b28b | 2014-02-19 09:02:02 -0500 | [diff] [blame] | 143 | done |
ZhiQiang Fan | 0b4a009 | 2016-04-12 20:26:33 +0800 | [diff] [blame] | 144 | |
| 145 | rm -rf ~/.config/openstack |
WenyanZhang | 8f0e97c | 2016-07-07 18:57:32 +0800 | [diff] [blame] | 146 | |
Dan Smith | 6766f71 | 2020-07-24 15:44:34 -0700 | [diff] [blame] | 147 | # Clear any fstab entries made |
| 148 | sudo sed -i '/.*comment=devstack-.*/ d' /etc/fstab |