configure the VIP accordingly and also change the sequence.
[joid.git] / ci / clean.sh
1 #!/bin/bash
2
3 set -ex
4
5 jujuver=`juju --version`
6
7 if [[ "$jujuver" > "2" ]]; then
8     if [ ! -d labconfig.yaml ]; then
9         cp ~/joid_config/labconfig.yaml ./labconfig.yaml || true
10         if [ -d $HOME/joid_config/deployconfig.yaml ]; then
11             cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml || true
12         else
13             python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
14         fi
15     fi
16 else
17     if [ ! -d environments.yaml ]; then
18         cp ~/joid_config/environments.yaml ./environments.yaml || true
19         cp ~/.juju/environments.yaml ./environments.yaml || true
20     fi
21 fi
22
23
24 if [[ "$jujuver" > "2" ]]; then
25     controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
26     cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
27     juju kill-controller $controllername --timeout 10s -y || true
28     rm -rf precise
29     rm -rf trusty
30     rm -rf xenial
31     rm -rf ~/joid_config/admin-openrc
32     sleep 30
33     sudo sysctl -w vm.drop_caches=3
34 elif [ -d $HOME/.juju/environments ]; then
35     echo " " > status.txt
36     juju status  &>>status.txt || true
37     if [ "$(grep -c "environment is not bootstrapped" status.txt )" -ge 1 ]; then
38         echo " environment is not bootstrapped ..."
39     else
40         echo " environment is bootstrapped ..."
41         jujuenv=`juju status | grep environment | cut -d ":" -f 2`
42         juju destroy-environment $jujuenv  -y || true
43     fi
44     rm -rf precise
45     rm -rf trusty
46     rm -rf xenial
47     rm -rf $HOME/.juju/j*
48     rm -rf $HOME/.juju/.deployer-store-cache
49     rm -rf $HOME/.juju/environments
50     rm -rf $HOME/.juju/ssh
51     sudo sysctl -w vm.drop_caches=3
52 fi