diff --git a/infrastructure/c4k-website-build/image/Dockerfile b/infrastructure/c4k-website-build/image/Dockerfile index 270be95..b24df8e 100644 --- a/infrastructure/c4k-website-build/image/Dockerfile +++ b/infrastructure/c4k-website-build/image/Dockerfile @@ -6,5 +6,6 @@ ADD resources /tmp ENV SOURCEDIR="/etc/websitesource" ENV BUILDDIR="/etc/website" ENV WEBSITEROOT="/var/www/html/website/" +ENV HASHFILEDIR="/data/hasfiles/" RUN /tmp/install.sh diff --git a/infrastructure/c4k-website-build/image/resources/entrypoint.sh b/infrastructure/c4k-website-build/image/resources/entrypoint.sh index 4a8d3ac..1b693be 100755 --- a/infrastructure/c4k-website-build/image/resources/entrypoint.sh +++ b/infrastructure/c4k-website-build/image/resources/entrypoint.sh @@ -2,6 +2,7 @@ mkdir $BUILDDIR mkdir $SOURCEDIR +mkdir -p $HASHFILEDIR set -o nounset set -o xtrace @@ -29,12 +30,11 @@ hashfilename="hashfile" # start the build echo "Downloading website data" -get-website-data filename +get-website-data $filename echo "Check for new content" if [[ -f $hashfile ]] then - currentHash=$( sha256sum $SOURCEDIR/$filename | cut -d " " -f 1 > ~/$2 ) #ToDo: output of sh256sum without path to file? - + currentHash=$(print-hash-from-file $filename ) else write-hashfile $filename $hashfilename diff --git a/infrastructure/c4k-website-build/image/resources/functions.sh b/infrastructure/c4k-website-build/image/resources/functions.sh index 821a59f..ec8897f 100644 --- a/infrastructure/c4k-website-build/image/resources/functions.sh +++ b/infrastructure/c4k-website-build/image/resources/functions.sh @@ -1,11 +1,15 @@ #!/bin/bash function get-website-data() { - curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$filename $GITREPOURL + curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL } function write-hashfile() { - (cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1 > ~/$2;) + (cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1 > $HASHFILEDIR/$2;) +} + +function print-hash-from-file() { + (cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1;) } function compare-website-data() { @@ -14,7 +18,7 @@ function compare-website-data() { } function unzip-website-data() { - unzip $SOURCEDIR/$filename -d $BUILDDIR + unzip $SOURCEDIR/$1 -d $BUILDDIR } function execute-scripts-when-existing {