forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-manual-juju.bash
executable file
·71 lines (63 loc) · 1.67 KB
/
remove-manual-juju.bash
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
#!/bin/bash
EXITCODE=0
ips="$@"
for ip in $ips; do
ssh -i $JUJU_HOME/staging-juju-rsa ubuntu@$ip <<"EOT"
#!/bin/bash
set -ux
DIRTY=0
JUJU_DIR="/var/lib/juju"
DUMMY_DIR="/var/run/dummy-sink"
echo "Cleaning manual machine"
# This is left by the test.
if [[ -d $DUMMY_DIR ]]; then
sudo rm -r $DUMMY_DIR
fi
# Juju always leaves logs behind for debuging, and they are already collected.
sudo rm /var/log/juju/*.log || true
# Juju must cleanup these procs.
if ps -f -C jujud; then
DIRTY=1
echo "ERROR manual-provider: jujud left running."
sudo touch $JUJU_DIR/uninstall-agent
sudo killall -SIGABRT jujud
fi
if ps -f -C mongod; then
DIRTY=1
echo "ERROR manual-provider: mongod left running."
sudo killall -9 mongod || true
fi
if [[ -d /etc/systemd/system ]]; then
found=$(ls /etc/systemd/system/juju*)
if [[ -n $found ]]; then
DIRTY=1
echo "ERROR manual-provider: systemd services left behind."
for service_path in $found; do
service=$(basename $service_path)
sudo systemctl stop --force $service || true
sudo systemctl disable $service || true
sudo rm $service_path || true
done
fi
fi
if [[ -d /etc/init ]]; then
found=$(find /etc/init -name 'juju*' -print)
if [[ -n $found ]]; then
DIRTY=1
echo "ERROR manual-provider: upstart services left behind."
sudo find /etc/init -name 'juju*' -delete || true
fi
fi
if [[ -d $JUJU_DIR ]]; then
DIRTY=1
echo "ERROR manual-provider: $JUJU_DIR left behind."
sudo rm -r $JUJU_DIR
fi
echo "Cleaning completed"
exit $DIRTY
EOT
if [[ $? != 0 ]];then
EXITCODE=1
fi
done
exit $EXITCODE