2022-09-23 13:39:17 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-03-06 14:35:11 +00:00
|
|
|
function generate-netrc-file() {
|
2024-03-11 13:41:15 +00:00
|
|
|
echo "machine $GITHOST password $AUTHTOKEN" > ~/.netrc
|
2024-03-06 14:35:11 +00:00
|
|
|
}
|
|
|
|
|
2022-12-02 08:37:03 +00:00
|
|
|
function get-website-data() {
|
2024-03-11 13:41:15 +00:00
|
|
|
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL
|
2022-12-02 08:37:03 +00:00
|
|
|
}
|
|
|
|
|
2022-12-09 08:50:13 +00:00
|
|
|
function get-hash-data() {
|
2024-03-11 13:41:15 +00:00
|
|
|
curl -s -H "Authorization: token $AUTHTOKEN" $GITCOMMITURL | jq '.sha'
|
2022-12-02 09:04:09 +00:00
|
|
|
}
|
|
|
|
|
2022-12-09 08:50:13 +00:00
|
|
|
function write-hash-data() {
|
2024-03-11 13:41:15 +00:00
|
|
|
echo $1 > $HASHFILEDIR/$2
|
2022-12-02 08:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function unzip-website-data() {
|
2024-03-11 13:41:15 +00:00
|
|
|
unzip $SOURCEDIR/$1 -d $BUILDDIR
|
2022-09-23 13:39:17 +00:00
|
|
|
}
|
|
|
|
|
2022-12-02 09:36:44 +00:00
|
|
|
function build-website() {
|
2024-03-15 10:01:35 +00:00
|
|
|
(cd $BUILDDIR; dir=$(ls); cd $dir; bash generate.sh;)
|
2022-09-23 13:39:17 +00:00
|
|
|
}
|
2022-09-30 15:54:26 +00:00
|
|
|
|
|
|
|
function move-website-files-to-target() {
|
2024-03-15 09:03:36 +00:00
|
|
|
(cd $BUILDDIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITEROOT;)
|
2022-09-30 15:54:26 +00:00
|
|
|
}
|
2024-05-03 09:21:12 +00:00
|
|
|
|
|
|
|
function install-hugo-from-deb() {
|
|
|
|
curl -L "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb" -o hugo_extended_${HUGO_VERSION}_linux-amd64.deb
|
|
|
|
curl -L "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_checksums.txt" -o checksums.txt
|
|
|
|
EXPECTED_CHECKSUM="$(sha256sum hugo_extended_${HUGO_VERSION}_linux-amd64.deb)"
|
|
|
|
ACTUAL_CHECKSUM="$(grep hugo_extended_${HUGO_VERSION}_linux-amd64.deb checksums.txt)"
|
|
|
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
|
|
|
then
|
|
|
|
>&2 echo 'ERROR: Invalid installer checksum'
|
|
|
|
rm hugo.deb
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Installing hugo"
|
|
|
|
echo
|
|
|
|
dpkg -i hugo_extended_${HUGO_VERSION}_linux-amd64.deb
|
|
|
|
|
|
|
|
echo "Clean up"
|
|
|
|
rm hugo_extended_${HUGO_VERSION}_linux-amd64.deb
|
|
|
|
rm checksums.txt
|
|
|
|
}
|
2024-05-03 10:07:33 +00:00
|
|
|
|
|
|
|
function install-go-from-tar() {
|
|
|
|
curl -L "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -o go_linux-amd64.tar.gz
|
|
|
|
EXPECTED_CHECKSUM="4643d4c29c55f53fa0349367d7f1bb5ca554ea6ef528c146825b0f8464e2e668 go_linux-amd64.tar.gz"
|
|
|
|
ACTUAL_CHECKSUM="$(sha256sum go_linux-amd64.tar.gz)"
|
|
|
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
|
|
|
then
|
|
|
|
>&2 echo 'ERROR: Invalid installer checksum'
|
|
|
|
rm go_linux-amd64.tar.gz
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Installing go"
|
|
|
|
echo
|
|
|
|
tar -C /usr/local -xzf go_linux-amd64.tar.gz
|
|
|
|
|
|
|
|
echo "Clean up"
|
|
|
|
rm go_linux-amd64.tar.gz
|
|
|
|
}
|