4
# DANGEROUS!! delete juju environment jenv files from master and all slaves!
5
# Manually delete the .juju/environments/*jenv files for sticky situations
8
jenv_dir="/var/lib/jenkins/.juju/environments"
12
if [ -z "$param" ]; then
13
echo "Manually deletes juju environment files!"
14
echo "Potentially dangerous, so you must confirm with YES."
15
echo "Usage: (this script).sh YES"
18
if [ "$param" == "YES" ]; then
20
units=$(juju status --format=yaml | egrep "osci[-]?(slave|lab|task)?/[0-9]{1,10}:" \
21
| cut -d ":" -f 1 | sed 's/^ *//')
23
if [ -z "$units" ]; then
24
echo "No units found. Check default juju environment?"
28
for unit in $units; do
29
jenv_files=$(juju ssh $unit "sudo ls ${jenv_dir}")
30
if [ -n "$jenv_files" ]; then
31
echo "Found files in ${jenv_dir}, deleting them!"
32
for this_file in $jenv_files; do
33
fn=$(echo "${jenv_dir}/${this_file}" | tr -d '\r')
34
echo "Deleting ${fn} on ${unit}!"
35
juju ssh $unit "sudo ls ${jenv_dir} -alh && sudo rm -v ${fn} && uname -a"
38
echo "${unit} juju environment appears to be all clear, deleting nothing."