From a2d64114f59eb08c5a49ef1f33427953992d9230 Mon Sep 17 00:00:00 2001 From: Nick Bargnesi Date: Tue, 5 Jan 2016 17:52:40 -0500 Subject: [PATCH] add create-webroot.sh script Quick hack to mirror resource.belframework.org and overlay custom namespace, equivalence, and annotation resources. --- java/scripts/create-webroot.sh | 101 +++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100755 java/scripts/create-webroot.sh diff --git a/java/scripts/create-webroot.sh b/java/scripts/create-webroot.sh new file mode 100755 index 0000000..f2dc261 --- /dev/null +++ b/java/scripts/create-webroot.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/../../ +. "$DIR"/env.sh || exit 1 + +if [ $# -ne 2 ]; then + echo "Usage: $0 [PATH] [WEB ROOT]" + echo "E.g. '$0 $(date +%Y-%m-%d) \"http://localhost:8000\"'" + exit 1 +fi + +assert-env-or-die RG_NS_OUTPUT +assert-env-or-die RG_EQ_OUTPUT +assert-env-or-die RG_ANNO_OUTPUT + +output_dir="$1" +if [ -d "$output_dir" ]; then + echo "Output directory \"$output_dir\" already exists." >&2 + exit 1 +fi +webroot="$2" + +mkdir "$output_dir" && cd "$output_dir" + +echo -en "Mirroring latest BEL framework resources... " +wget --quiet --mirror --no-parent --cut-dirs=2 "http://resource.belframework.org/belframework/latest-release/" +mv resource.belframework.org/* . +rmdir resource.belframework.org +echo "done" + +rm -fr namespace annotation equivalence index.xml* + +cp -a "$RG_NS_OUTPUT" . +cp -a "$RG_EQ_OUTPUT" . +cp -a "$RG_ANNO_OUTPUT" . + +echo ' + + ' > index.xml + +find -name "*.belanno" | while read belanno; do + belanno=annotation/$(basename $belanno) + echo " " >> index.xml +done + +echo ' + + ' >> index.xml + +find -name "*.belns" | while read belns; do + belns=namespace/$(basename $belns) + echo " " >> index.xml +done + +echo ' + + ' >> index.xml + +find -name "*.beleq" | while read beleq; do + beleq=equivalence/$(basename $beleq) + belns=namespace/$(basename $beleq | sed 's/beleq/belns/') + echo " " >> index.xml + echo " " >> index.xml + echo " " >> index.xml +done + +echo " + + + + + + + + + +" >> index.xml + +sha256sum index.xml > index.xml.sha256 + +base=$(pwd) +# create sha256 hashes for each namespace +cd namespace || exit 1 +for x in *.belns; do sha256sum "$x" > "$x.sha256"; done +cd "$base" + +# create sha256 hashes for each equivalence +cd equivalence || exit 1 +for x in *.beleq; do sha256sum "$x" > "$x.sha256"; done +cd "$base" + +# create sha256 hashes for each annotation +cd annotation || exit 1 +for x in *.belanno; do sha256sum "$x" > "$x.sha256"; done +cd "$base" + +echo "Done!" +