SKIP-CI // Started with hash check

This commit is contained in:
Clemens 2022-12-02 10:04:09 +01:00
parent a844a9e947
commit 37170ee982
3 changed files with 11 additions and 6 deletions

View file

@ -6,5 +6,6 @@ ADD resources /tmp
ENV SOURCEDIR="/etc/websitesource" ENV SOURCEDIR="/etc/websitesource"
ENV BUILDDIR="/etc/website" ENV BUILDDIR="/etc/website"
ENV WEBSITEROOT="/var/www/html/website/" ENV WEBSITEROOT="/var/www/html/website/"
ENV HASHFILEDIR="/data/hasfiles/"
RUN /tmp/install.sh RUN /tmp/install.sh

View file

@ -2,6 +2,7 @@
mkdir $BUILDDIR mkdir $BUILDDIR
mkdir $SOURCEDIR mkdir $SOURCEDIR
mkdir -p $HASHFILEDIR
set -o nounset set -o nounset
set -o xtrace set -o xtrace
@ -29,12 +30,11 @@ hashfilename="hashfile"
# start the build # 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 ]] if [[ -f $hashfile ]]
then 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 else
write-hashfile $filename $hashfilename write-hashfile $filename $hashfilename

View file

@ -1,11 +1,15 @@
#!/bin/bash #!/bin/bash
function get-website-data() { 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() { 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() { function compare-website-data() {
@ -14,7 +18,7 @@ function compare-website-data() {
} }
function unzip-website-data() { function unzip-website-data() {
unzip $SOURCEDIR/$filename -d $BUILDDIR unzip $SOURCEDIR/$1 -d $BUILDDIR
} }
function execute-scripts-when-existing { function execute-scripts-when-existing {