summaryrefslogtreecommitdiff
path: root/tools/uninstall-heat
blob: 6f07349f1f25e012a0005bff5972c0f7b42af343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash

TOOLS_DIR=`dirname $0`
if [ "$1" = "-y" ] || [ "$1" = "--yes" ]; then
    SKIP_ASK=y
    shift
fi

user_wants() {
    if [ "$SKIP_ASK" = "y" ]; then return 0; fi

    while true; do
        read -n 1 -p "$1 " cont
        echo 1>&2
        case $cont in
            y|Y)
                return 0
                ;;
            n|N)
                return 1
                ;;
            *)
                ;;
        esac
    done
}

HEAT_PIDS=`pgrep '^heat-(api|api-cfn|engine|metadata)$'`
if [ -n "$HEAT_PIDS" ]; then
    echo 'The following Heat processes are running:' 1>&2
    ps $HEAT_PIDS 1>&2
    if user_wants 'Kill them?'; then
        sudo kill $HEAT_PIDS
    fi
    echo 1>&2
fi

if user_wants 'Drop Heat database tables?'; then
    $TOOLS_DIR/heat-db-drop $*
    echo 1>&2
fi

if user_wants 'Erase OpenStack installation?'; then
    $TOOLS_DIR/openstack erase $*
    echo 1>&2
fi

HEAT_EGGS=`python -c 'import sys; print "\n".join(sys.path)' | grep '/heat-[^/]*\.egg$'`
if [ -n "$HEAT_EGGS" ]; then
    echo 'The following Heat installations were found:' 1>&2
    echo "$HEAT_EGGS" 1>&2
    if user_wants 'Delete them?'; then
        sudo rm -rf $HEAT_EGGS
    fi
    echo 1>&2
fi

if user_wants 'Delete Heat binaries?'; then
    BIN_PATH=/usr/bin
    sudo rm -f $BIN_PATH/heat-db-setup
    sudo rm -f $BIN_PATH/heat-metadata
    sudo rm -f $BIN_PATH/heat-api
    sudo rm -f $BIN_PATH/heat-api-cfn
    sudo rm -f $BIN_PATH/heat-engine

    echo 1>&2
fi

if user_wants 'Delete Heat configuration?'; then
    sudo rm -rf /etc/heat
    echo 1>&2
fi

if user_wants 'Delete Heat logs?'; then
    sudo rm -rf /var/log/heat
    echo 1>&2
fi

echo 'Warning: You shall explicitly remove related tenants, role, and users from keystone' 1>&2