c4k-website/infrastructure/c4k-website-build/image/resources/functions.sh

37 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
function get-and-unzip-website-data() {
filename="website.zip"
2022-09-29 14:22:08 +00:00
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$filename $GITREPOURL
unzip $SOURCEDIR/$filename -d $BUILDDIR
}
function execute-scripts-when-existing {
websitedir=$(ls $BUILDDIR)
if [[ -e $BUILDDIR/$websitedir/$SCRIPTFILE ]]
then
checksum="$(sha256sum $BUILDDIR/$websitedir/$SCRIPTFILE)"
if [[ "$SHA256SUM" == "$checksum" ]]
then
chmod +x $BUILDDIR/$websitedir/$SCRIPTFILE
(cd $BUILDDIR; dir=$(ls); cd $dir; ./$SCRIPTFILE) #make sure paths defined in scriptfile are relative to $dir
else
printf "Provided SHA256 Sum does not match calculated sum. Exiting."
printf "Calculated SHA256: $checksum"
printf "Given SHA256: $SHA256SUM"
exit 1
fi
else
prinf "No script file provided, exiting."
exit 0
fi
}
function build-and-extract-website() {
2022-09-30 15:54:26 +00:00
(cd $BUILDDIR; dir=$(ls); cd $dir; lein run;)
}
2022-09-30 15:54:26 +00:00
function move-website-files-to-target() {
(cd $BUILDDIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete resources/public/* $WEBSITEROOT;)
}