This commit is contained in:
Lucio Lelii 2017-03-23 18:20:33 +00:00
parent d4e3d2fa87
commit 0adf7ea913
1 changed files with 39 additions and 31 deletions

View File

@ -1,48 +1,56 @@
function showhelp { function showhelp {
echo -e "\nusage: clean-container-state [-g <ghn_home>] [-h] \n" echo -e "\nusage: clean-container-state [-g <ghn_home>] [-s <fileName>] [-h] \n"
echo " ghn_home = the gHN directory." echo " ghn_home = the gHN directory.\n"
echo -e " h = shows this help.\n" echo " fileName = the filename for volatile state.\n"
echo -e " h = shows this help.\n"
} }
while getopts "g:h" opt; do while getopts "h:g:s:" opt; do
case $opt in case $opt in
g) ghnhome=$OPTARG;; g) ghnhome=$OPTARG;;
h) showhelp h) showhelp
exit 0 ;; exit 0 ;;
:) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ; s) filename=$OPTARG;;
showhelp;
echo -e "\naborting.\n" :) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ;
exit 1;; showhelp;
\?) echo -e "\nERROR:invalid option: -$OPTARG"; echo -e "\naborting.\n"
showhelp; exit 1;;
echo -e "\naborting.\n" \?) echo -e "\nERROR:invalid option: -$OPTARG";
exit 1 >&2 ;; showhelp;
echo -e "\naborting.\n"
exit 1 >&2 ;;
esac esac
done done
if [ -z "$ghnhome" ]; then if [ -z "$ghnhome" ]; then
if [ -z "$GHN_HOME" ]; then if [ -z "$GHN_HOME" ]; then
echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2 echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2
showhelp showhelp
echo -e "\naborting.\n" echo -e "\naborting.\n"
exit 1 exit 1
else else
ghnhome=$GHN_HOME ghnhome=$GHN_HOME
fi fi
fi fi
echo -e "\nRemoving resource profiles from the Information System\n" echo -e "\nRemoving resource profiles from the Information System\n"
source ./load-env source "$ghnhome"/scripts/load-env
#java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient 1>/dev/null if [ -z "$filename" ]; then
java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient 1>/dev/null
else
java org.gcube.smartgears.utils.sweeper.ContainerSweeperClient $filename 1>/dev/null
echo -e "\nvolatile state saved in $ghnhome/$filename"
fi
#if [ "$?" != "0" ]; then if [ "$?" != "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 exit 1
#fi fi
echo "Removing container state $ghnhome" echo "Removing container state $ghnhome"
#removing folder #removing folder