2022-09-23 13:39:17 +00:00
|
|
|
#!/bin/bash
|
2022-12-08 17:39:33 +00:00
|
|
|
# curl -s -H "Authorization: token xxxx" https://repo.prod.meissa.de/api/v1/repos/meissa-intern/meissa-io/git/commits/HEAD | jq '.sha'
|
2022-09-23 13:39:17 +00:00
|
|
|
|
2022-12-02 08:37:03 +00:00
|
|
|
function get-website-data() {
|
2022-12-02 09:04:09 +00:00
|
|
|
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL
|
2022-12-02 08:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function write-hashfile() {
|
2022-12-02 09:36:44 +00:00
|
|
|
echo $1 > $HASHFILEDIR/$2
|
2022-12-02 09:04:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function print-hash-from-file() {
|
|
|
|
(cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1;)
|
2022-12-02 08:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function unzip-website-data() {
|
2022-12-02 09:04:09 +00:00
|
|
|
unzip $SOURCEDIR/$1 -d $BUILDDIR
|
2022-09-23 13:39:17 +00:00
|
|
|
}
|
|
|
|
|
2022-11-11 12:08:55 +00:00
|
|
|
function execute-scripts-when-existing {
|
2022-11-11 13:01:08 +00:00
|
|
|
websitedir=$(ls $BUILDDIR)
|
2022-11-11 14:10:47 +00:00
|
|
|
if [[ -f $BUILDDIR/$websitedir/$SCRIPTFILE ]]
|
2022-11-11 12:08:55 +00:00
|
|
|
then
|
2022-11-11 14:46:02 +00:00
|
|
|
checksum="$(sha256sum $BUILDDIR/$websitedir/$SCRIPTFILE | grep -oE "^[a-z0-9]+")"
|
2022-11-11 12:08:55 +00:00
|
|
|
if [[ "$SHA256SUM" == "$checksum" ]]
|
|
|
|
then
|
2022-11-11 13:01:08 +00:00
|
|
|
chmod +x $BUILDDIR/$websitedir/$SCRIPTFILE
|
|
|
|
(cd $BUILDDIR; dir=$(ls); cd $dir; ./$SCRIPTFILE) #make sure paths defined in scriptfile are relative to $dir
|
2022-11-11 12:08:55 +00:00
|
|
|
else
|
|
|
|
printf "Provided SHA256 Sum does not match calculated sum. Exiting."
|
|
|
|
printf "Calculated SHA256: $checksum"
|
|
|
|
printf "Given SHA256: $SHA256SUM"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
2022-11-11 14:46:02 +00:00
|
|
|
printf "No script file provided."
|
2022-11-11 12:08:55 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-12-02 09:36:44 +00:00
|
|
|
function build-website() {
|
2022-09-30 15:54:26 +00:00
|
|
|
(cd $BUILDDIR; dir=$(ls); cd $dir; lein run;)
|
2022-09-23 13:39:17 +00:00
|
|
|
}
|
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;)
|
|
|
|
}
|