~andrewjbeach/juju-ci-tools/make-local-patcher

« back to all changes in this revision

Viewing changes to remove-manual-juju.bash

  • Committer: Curtis Hovey
  • Date: 2016-09-21 17:54:26 UTC
  • mto: This revision was merged to the branch mainline in revision 1612.
  • Revision ID: curtis@canonical.com-20160921175426-hmk3wlxrl1vpfuwr
Poll for the token, whcih might be None.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
 
3
EXITCODE=0
 
4
 
3
5
ips="$@"
4
6
for ip in $ips; do
5
7
    ssh -i $JUJU_HOME/staging-juju-rsa ubuntu@$ip <<"EOT"
6
8
#!/bin/bash
7
9
set -ux
8
10
 
9
 
echo "Cleaning manual machine"
10
 
 
 
11
DIRTY=0
11
12
JUJU_DIR="/var/lib/juju"
12
13
DUMMY_DIR="/var/run/dummy-sink"
 
14
 
 
15
echo "Cleaning manual machine"
 
16
 
 
17
# This is left by the test.
 
18
if [[ -d $DUMMY_DIR ]]; then
 
19
    sudo rm -r $DUMMY_DIR
 
20
fi
 
21
 
 
22
# Juju always leaves logs behind for debuging, and they are already collected.
 
23
sudo rm /var/log/juju/*.log || true
 
24
 
 
25
# Juju must cleanup these procs.
13
26
if ps -f -C jujud; then
 
27
    DIRTY=1
 
28
    echo "ERROR manual-provider: jujud left running."
14
29
    sudo touch $JUJU_DIR/uninstall-agent
15
30
    sudo killall -SIGABRT jujud
16
31
fi
17
 
sudo killall -9 mongod || true
 
32
if ps -f -C mongod; then
 
33
    DIRTY=1
 
34
    echo "ERROR manual-provider: mongod left running."
 
35
    sudo killall -9 mongod || true
 
36
fi
 
37
if [[ -d /etc/systemd/system ]]; then
 
38
    found=$(ls /etc/systemd/system/juju*)
 
39
    if [[ -n $found ]]; then
 
40
        DIRTY=1
 
41
        echo "ERROR manual-provider: systemd services left behind."
 
42
        for service_path in $found; do
 
43
            service=$(basename $service_path)
 
44
            sudo systemctl stop --force $service || true
 
45
            sudo systemctl disable $service || true
 
46
            sudo rm $service_path || true
 
47
        done
 
48
    fi
 
49
fi
 
50
if [[ -d /etc/init ]]; then
 
51
    found=$(find /etc/init -name 'juju*' -print)
 
52
    if [[ -n $found ]]; then
 
53
        DIRTY=1
 
54
        echo "ERROR manual-provider: upstart services left behind."
 
55
        sudo find /etc/init -name 'juju*' -delete || true
 
56
    fi
 
57
fi
18
58
if [[ -d $JUJU_DIR ]]; then
 
59
    DIRTY=1
 
60
    echo "ERROR manual-provider: $JUJU_DIR left behind."
19
61
    sudo rm -r $JUJU_DIR
20
62
fi
21
 
if [[ -d $DUMMY_DIR ]]; then
22
 
    sudo rm -r $DUMMY_DIR
23
 
fi
24
 
sudo find /etc/init -name 'juju*' -delete || true
25
63
echo "Cleaning completed"
26
 
exit 0
 
64
exit $DIRTY
27
65
EOT
 
66
    if [[ $? != 0 ]];then
 
67
        EXITCODE=1
 
68
    fi
28
69
done
 
70
 
 
71
exit $EXITCODE