diff --git a/distro/contents/scripts/clean-container-state b/distro/contents/scripts/clean-container-state index 0410e91..876062f 100644 --- a/distro/contents/scripts/clean-container-state +++ b/distro/contents/scripts/clean-container-state @@ -1,9 +1,9 @@ -#!/bin/bashin +#!/bin/bash function showhelp { echo -e "\nusage: clean-container-state [-g ] [-s ] [-h] \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" } @@ -40,20 +40,27 @@ echo -e "\nRemoving resource profiles from the Information System\n" source "$ghnhome"/scripts/load-env + +RETVAL= if [ -z "$filename" ]; then java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient 1>/dev/null + RETVAL=$? else 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 -if [ "$?" != "0" ]; then - 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 dev deployment you can remove the state by hand by removing the $GHN_HOME/state folder" - exit 1 +if [ $RETVAL -ne 0 ]; then + 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 dev deployment you can remove the state by hand by removing the $GHN_HOME/state folder" +else + echo "Removing container state $ghnhome" + # removing folder + rm -rf $ghnhome/state fi -echo "Removing container state $ghnhome" -#removing folder -rm -rf $ghnhome/state \ No newline at end of file +exit $RETVAL \ No newline at end of file