From e6c51ed4798a0fb44affad4add866ec92a1d8834 Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 2 Dec 2022 10:36:44 +0100 Subject: [PATCH] [Skip-CI] WIP check file before building --- .../image/resources/entrypoint.sh | 49 ++++++++++--------- .../image/resources/functions.sh | 9 +--- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/infrastructure/c4k-website-build/image/resources/entrypoint.sh b/infrastructure/c4k-website-build/image/resources/entrypoint.sh index 1b693be..9387560 100755 --- a/infrastructure/c4k-website-build/image/resources/entrypoint.sh +++ b/infrastructure/c4k-website-build/image/resources/entrypoint.sh @@ -13,38 +13,39 @@ source /usr/local/bin/functions.sh filename="website.zip" hashfilename="hashfile" +touch $HASHFILEDIR/$hashfilename +# create empty hashfile # download website data -# check if hashfile exists -# if yes - # hash the current file - # compare current hash to hashfile - # same? - # do nothing - # not same? - # overwrite hashfile with new hash - # start the website build -# if not - # hash the current file - # write the hashfile - # start the build +# compare current hash to hashfile + # same? + # do nothing + # not same? + # overwrite hashfile with new hash + # unzip website + # execute scripts (if applicable) + # build website + # move files echo "Downloading website data" get-website-data $filename + echo "Check for new content" -if [[ -f $hashfile ]] +currentHash=$( print-hash-from-file $filename ) +if [[ $currentHash == $(cat $HASHFILEDIR/$hashfilename) ]] then - currentHash=$(print-hash-from-file $filename ) - + echo "Nothing to do" else - write-hashfile $filename $hashfilename - + write-hashfile $currentHash $hashfilename + unzip-website-data $filename + echo "Executing Custom Scripts, if applicable" + execute-scripts-when-existing + echo "Building website" + build-website + echo "Moving files" + move-website-files-to-target fi -echo "Executing Custom Scripts, if applicable" -execute-scripts-when-existing -echo "Building website" -build-and-extract-website -echo "Moving files" -move-website-files-to-target + + diff --git a/infrastructure/c4k-website-build/image/resources/functions.sh b/infrastructure/c4k-website-build/image/resources/functions.sh index ec8897f..844edc9 100644 --- a/infrastructure/c4k-website-build/image/resources/functions.sh +++ b/infrastructure/c4k-website-build/image/resources/functions.sh @@ -5,18 +5,13 @@ function get-website-data() { } function write-hashfile() { - (cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1 > $HASHFILEDIR/$2;) + echo $1 > $HASHFILEDIR/$2 } function print-hash-from-file() { (cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1;) } -function compare-website-data() { - oldHash="$( cat ~/hashfile )" - -} - function unzip-website-data() { unzip $SOURCEDIR/$1 -d $BUILDDIR } @@ -41,7 +36,7 @@ function execute-scripts-when-existing { fi } -function build-and-extract-website() { +function build-website() { (cd $BUILDDIR; dir=$(ls); cd $dir; lein run;) }