From b2b39b77bbbeedea6944e92b5e02d0524ca116f8 Mon Sep 17 00:00:00 2001 From: Andrea Manzi Date: Mon, 7 Oct 2013 10:30:08 +0000 Subject: [PATCH] adding clean scripts, fixed download script git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/distributions/smartgears-distribution@82546 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.core.resources.prefs | 2 + distro/MAINTAINERS | 3 +- distro/README | 1 + distro/contents/scripts/clean-app-state | 44 +++++++++++++++++++ distro/contents/scripts/clean-container-state | 37 ++++++++++++++++ distro/contents/scripts/download | 12 ++--- 6 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 distro/contents/scripts/clean-app-state create mode 100644 distro/contents/scripts/clean-container-state diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/distro/MAINTAINERS b/distro/MAINTAINERS index 5e8aa8f..3458e3a 100644 --- a/distro/MAINTAINERS +++ b/distro/MAINTAINERS @@ -1 +1,2 @@ -* Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy \ No newline at end of file +* Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy +* Andrea Manzi (andrea.manzi@cern.ch), CERN, Switzerland \ No newline at end of file diff --git a/distro/README b/distro/README index b73e693..38210c2 100644 --- a/distro/README +++ b/distro/README @@ -8,6 +8,7 @@ Authors ------- * Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy. +* Andrea Manzi (andrea.manzi@cern.ch), CERN, Switzerland Version and Release Date ------------------------ diff --git a/distro/contents/scripts/clean-app-state b/distro/contents/scripts/clean-app-state new file mode 100644 index 0000000..ab2b6c0 --- /dev/null +++ b/distro/contents/scripts/clean-app-state @@ -0,0 +1,44 @@ +function showhelp { + echo -e "\nusage: clean-app-state -a [-g] [-h] \n" + echo " a = the application name whose state has to be cleaned" + echo " g = the gHN directory." + echo -e " h = shows this help.\n" +} + +while getopts ":a:g:xh" opt; do + case $opt in + g) ghnhome=$OPTARG;; + a) apps=$OPTARG;; + h) showhelp +exit 0 ;; + :) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ; + showhelp; + echo -e "\naborting.\n" + exit 1;; + \?) echo -e "\nERROR:invalid option: -$OPTARG"; + showhelp; + echo -e "\naborting.\n" + exit 1 >&2 ;; + esac +done + +if [ -z "$ghnhome" ]; then + if [ -z "$GHN_HOME" ]; then + echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2 + showhelp + echo -e "\naborting.\n" + exit 1 + else + ghnhome=$GHN_HOME + fi +fi + + +if [ ! -d "$ghnhome/$apps" ]; then + echo -e "\nERROR: apps folder does not exist or is not a directory, aborting." >&2 + exit 1; +fi + +echo "Removing application state $ghnhome/$apps" +#removing folder +rm -rf $ghnhome/$apps \ No newline at end of file diff --git a/distro/contents/scripts/clean-container-state b/distro/contents/scripts/clean-container-state new file mode 100644 index 0000000..d050846 --- /dev/null +++ b/distro/contents/scripts/clean-container-state @@ -0,0 +1,37 @@ +function showhelp { + echo -e "\nusage: clean-container-state [-g] [-h] \n" + echo " a = the application name whose state has to be cleaned" + echo " g = the gHN directory." + echo -e " h = shows this help.\n" +} + +while getopts "g:h" opt; do + case $opt in + g) ghnhome=$OPTARG;; + h) showhelp +exit 0 ;; + :) echo -e "\nERROR:option -$OPTARG requires an argument." >&2 ; + showhelp; + echo -e "\naborting.\n" + exit 1;; + \?) echo -e "\nERROR:invalid option: -$OPTARG"; + showhelp; + echo -e "\naborting.\n" + exit 1 >&2 ;; + esac +done + +if [ -z "$ghnhome" ]; then + if [ -z "$GHN_HOME" ]; then + echo -e "\nERROR:please specify the gHN directory (-g) or define the GHN_HOME env var." >&2 + showhelp + echo -e "\naborting.\n" + exit 1 + else + ghnhome=$GHN_HOME + fi +fi + +echo "Removing container state $ghnhome" +#removing folder +rm -rf $ghnhome \ No newline at end of file diff --git a/distro/contents/scripts/download b/distro/contents/scripts/download index a2bd011..2a37d4c 100644 --- a/distro/contents/scripts/download +++ b/distro/contents/scripts/download @@ -1,6 +1,6 @@ -group=org.gcube.core -artifact=common-smartgears +group=org.gcube.distribution +artifact=smartgears-distribution repo=gcube-releases function showhelp { @@ -36,7 +36,7 @@ version_regexp=".*\(.*\).*" if [ -z "$version" ]; then - version=`curl -silent -L "maven.research-infrastructures.eu/nexus/service/local/artifact/maven/resolve?r=$repo&g=$group&a=$artifact&v=LATEST&e=tar.gz&c=distro" \ + version=`curl -silent -L "maven.research-infrastructures.eu/nexus/service/local/artifact/maven/resolve?r=$repo&g=$group&a=$artifact&v=LATEST&e=tar.gz" \ | grep "$version_regexp" | sed "s|$version_regexp|\1|"` #(first extract matching line, then extract matching group) if [ -z "$version" ]; then @@ -48,15 +48,15 @@ fi -echo -e "\ndownloading common-smartgears-$version.tar.gz...\c" +echo -e "\ndownloading smartgears-distribution-$version.tar.gz...\c" -http_code=`curl -s -o "common-smartgears-$version.tar.gz" -w "%{http_code}" -L "maven.research-infrastructures.eu/nexus/service/local/artifact/maven/redirect?r=$repo&g=$group&a=$artifact&v=$version&e=tar.gz&c=distro"` +http_code=`curl -s -o "smartgears-distribution-$version.tar.gz" -w "%{http_code}" -L "maven.research-infrastructures.eu/nexus/service/local/artifact/maven/redirect?r=$repo&g=$group&a=$artifact&v=$version&e=tar.gz"` if [ ! "$http_code" = "200" ]; then echo -e "\n\nERROR: cannot download version $version from $repo." >&2 echo -e "\naborting.\n" - rm "common-smartgears-$version.tar.gz" + rm "smartgears-distribution-$version.tar.gz" exit 1 fi