[Skip-CI] WIP check file before building

merge-requests/4/head
erik 1 year ago
parent 37170ee982
commit e6c51ed479

@ -13,38 +13,39 @@ source /usr/local/bin/functions.sh
filename="website.zip" filename="website.zip"
hashfilename="hashfile" hashfilename="hashfile"
touch $HASHFILEDIR/$hashfilename
# create empty hashfile
# download website data # download website data
# check if hashfile exists # compare current hash to hashfile
# if yes # same?
# hash the current file # do nothing
# compare current hash to hashfile # not same?
# same? # overwrite hashfile with new hash
# do nothing # unzip website
# not same? # execute scripts (if applicable)
# overwrite hashfile with new hash # build website
# start the website build # move files
# if not
# hash the current file
# write the hashfile
# start the build
echo "Downloading website data" echo "Downloading website data"
get-website-data $filename get-website-data $filename
echo "Check for new content" echo "Check for new content"
if [[ -f $hashfile ]] currentHash=$( print-hash-from-file $filename )
if [[ $currentHash == $(cat $HASHFILEDIR/$hashfilename) ]]
then then
currentHash=$(print-hash-from-file $filename ) echo "Nothing to do"
else 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 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

@ -5,18 +5,13 @@ function get-website-data() {
} }
function write-hashfile() { function write-hashfile() {
(cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1 > $HASHFILEDIR/$2;) echo $1 > $HASHFILEDIR/$2
} }
function print-hash-from-file() { function print-hash-from-file() {
(cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1;) (cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1;)
} }
function compare-website-data() {
oldHash="$( cat ~/hashfile )"
}
function unzip-website-data() { function unzip-website-data() {
unzip $SOURCEDIR/$1 -d $BUILDDIR unzip $SOURCEDIR/$1 -d $BUILDDIR
} }
@ -41,7 +36,7 @@ function execute-scripts-when-existing {
fi fi
} }
function build-and-extract-website() { function build-website() {
(cd $BUILDDIR; dir=$(ls); cd $dir; lein run;) (cd $BUILDDIR; dir=$(ls); cd $dir; lein run;)
} }

Loading…
Cancel
Save