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

« back to all changes in this revision

Viewing changes to remove-manual-juju.bash

  • Committer: Martin Packman
  • Date: 2015-12-16 03:59:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1200.
  • Revision ID: martin.packman@canonical.com-20151216035938-881wbry7ezh8he5m
Add missing template test file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
3
 
EXITCODE=0
4
 
 
5
3
ips="$@"
6
4
for ip in $ips; do
7
5
    ssh -i $JUJU_HOME/staging-juju-rsa ubuntu@$ip <<"EOT"
8
6
#!/bin/bash
9
7
set -ux
10
 
 
11
 
DIRTY=0
12
8
JUJU_DIR="/var/lib/juju"
13
9
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.
26
10
if ps -f -C jujud; then
27
 
    DIRTY=1
28
 
    echo "ERROR manual-provider: jujud left running."
29
11
    sudo touch $JUJU_DIR/uninstall-agent
30
12
    sudo killall -SIGABRT jujud
31
13
fi
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
 
14
sudo killall -9 mongod || true
58
15
if [[ -d $JUJU_DIR ]]; then
59
 
    DIRTY=1
60
 
    echo "ERROR manual-provider: $JUJU_DIR left behind."
61
16
    sudo rm -r $JUJU_DIR
62
17
fi
63
 
echo "Cleaning completed"
64
 
exit $DIRTY
 
18
if [[ -d $DUMMY_DIR ]]; then
 
19
    sudo rm -r $DUMMY_DIR
 
20
fi
 
21
sudo find /etc/init -name 'juju*' -delete
65
22
EOT
66
 
    if [[ $? != 0 ]];then
67
 
        EXITCODE=1
68
 
    fi
69
23
done
70
 
 
71
 
exit $EXITCODE