This commit is contained in:
Lucio Lelii 2017-03-28 15:05:50 +00:00
parent 05ebda1c21
commit 8c543f3916
1 changed files with 18 additions and 11 deletions

View File

@ -1,9 +1,9 @@
#!/bin/bashin #!/bin/bash
function showhelp { function showhelp {
echo -e "\nusage: clean-container-state [-g <ghn_home>] [-s <fileName>] [-h] \n" echo -e "\nusage: clean-container-state [-g <ghn_home>] [-s <fileName>] [-h] \n"
echo " ghn_home = the gHN directory.\n" echo " ghn_home = the gHN directory.\n"
echo " fileName = the filename for volatile state.\n" echo " fileName = the filename for volatile state.\n"
echo -e " h = shows this help.\n" echo -e " h = shows this help.\n"
} }
@ -40,20 +40,27 @@ echo -e "\nRemoving resource profiles from the Information System\n"
source "$ghnhome"/scripts/load-env source "$ghnhome"/scripts/load-env
RETVAL=
if [ -z "$filename" ]; then if [ -z "$filename" ]; then
java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient 1>/dev/null java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient 1>/dev/null
RETVAL=$?
else else
java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient $filename 1>/dev/null java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient $filename 1>/dev/null
echo -e "\nvolatile state saved in $ghnhome/$filename" RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo -e "\nvolatile state saved in $ghnhome/$filename"
fi
fi fi
if [ "$?" != "0" ]; then if [ $RETVAL -ne 0 ]; then
echo -e "\nCould no correctly sweep the profiles from the Information System" echo -e "\nCould no correctly sweep the profiles from the Information System"
echo -e "\nIn case of production deployment please contact the production admin" echo -e "\nIn case of production deployment please contact the production admin"
echo -e "\nIn case of dev deployment you can remove the state by hand by removing the $GHN_HOME/state folder" echo -e "\nIn case of dev deployment you can remove the state by hand by removing the $GHN_HOME/state folder"
exit 1 else
echo "Removing container state $ghnhome"
# removing folder
rm -rf $ghnhome/state
fi fi
echo "Removing container state $ghnhome" exit $RETVAL
#removing folder
rm -rf $ghnhome/state