2017-03-24 01:20:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-09-07 17:43:54 +02:00
|
|
|
# Put all available languages here, except "en". Separated by spaces
|
2018-05-30 15:41:58 +02:00
|
|
|
TRANSLATIONS="ca da de el eo es fr hu it nb nl pt ru sq sv tr zh_tw"
|
2017-09-07 17:30:43 +02:00
|
|
|
|
2018-03-24 17:30:32 +01:00
|
|
|
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
|
2017-09-07 16:59:01 +02:00
|
|
|
cd "$basedir"
|
|
|
|
mode=$1
|
2017-03-24 01:20:54 +01:00
|
|
|
|
2017-09-07 16:59:01 +02:00
|
|
|
# Unite static and language-specific config files to a single file
|
2017-09-07 17:43:54 +02:00
|
|
|
for language in $TRANSLATIONS; do
|
|
|
|
languagefiles="$languagefiles languages/strings.$language.toml"
|
|
|
|
done
|
|
|
|
cat config-static.toml languages/strings.en.toml ${languagefiles} > config.toml
|
2017-03-24 01:20:54 +01:00
|
|
|
|
|
|
|
# Execute hugo buildrun
|
2017-09-07 16:59:01 +02:00
|
|
|
if [ "$mode" == "server" ]; then
|
|
|
|
hugo server
|
2017-09-12 09:59:04 +02:00
|
|
|
elif [ "$mode" == "syntax" ]; then
|
|
|
|
hugo
|
2017-09-07 16:59:01 +02:00
|
|
|
else
|
2017-09-20 00:20:46 +02:00
|
|
|
status=1
|
|
|
|
tries=0
|
|
|
|
while [[ $status -ne 0 ]]; do
|
2017-09-12 09:56:30 +02:00
|
|
|
|
2017-09-20 00:20:46 +02:00
|
|
|
hugo
|
|
|
|
status=$?
|
2017-09-22 20:24:00 +02:00
|
|
|
|
2017-09-20 00:20:46 +02:00
|
|
|
(( tries++ ))
|
2017-09-22 20:24:00 +02:00
|
|
|
|
2017-09-20 00:20:46 +02:00
|
|
|
if [[ $status != 0 && $tries -le 2 ]]; then
|
|
|
|
echo "Build error with exit status $status on try $tries. Try again now"
|
|
|
|
elif [[ $status != 0 && $tries -gt 2 ]]; then
|
|
|
|
echo "Build failed 3 times in a row. Don't try again."
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-09-22 20:24:00 +02:00
|
|
|
|
2017-09-20 00:20:46 +02:00
|
|
|
done
|
2017-09-22 20:24:00 +02:00
|
|
|
|
2018-03-24 23:44:12 +01:00
|
|
|
## After successfully building the website, we set the AWS credentials and upload
|
2017-09-14 21:13:44 +02:00
|
|
|
## everything to our AWS s3 bucket.
|
|
|
|
##
|
2017-09-19 17:46:29 +02:00
|
|
|
#if [ -f /srv/cred/aws.sh ]; then
|
|
|
|
# . /srv/cred/aws.sh
|
|
|
|
# /usr/local/bin/aws configure set default.s3.max_concurrent_requests 2
|
|
|
|
# /usr/local/bin/aws s3 cp /usr/share/blog/public/ s3://aws-website-pmpc-soegm/ --recursive
|
|
|
|
#fi
|
2017-09-07 16:59:01 +02:00
|
|
|
fi
|