You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
#!/usr/bin/env bash
|
|
# create static files with hugo and upload them with rsync
|
|
# to my webserver
|
|
# created: 2023-03-26T23:27:11+0200
|
|
|
|
clean_up () {
|
|
echo -n ">>> Removing output files..."
|
|
rm -rf public
|
|
if [ "$?" -eq "0" ]; then
|
|
echo " Success!"
|
|
else
|
|
echo " *** FAILED ***"
|
|
echo "Could not delete output files (public). Aborting..."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
echo -n ">>> Creating static files with `hugo version | awk '{ print $1,$2 }'`..."
|
|
|
|
ret="$(hugo --gc --minify --cleanDestinationDir --printPathWarnings --logLevel warn)"
|
|
|
|
# if [ -n "$(echo $ret | grep Total)" ] ; then
|
|
if [ "$?" -eq "0" ] ; then
|
|
echo " Success!"
|
|
else
|
|
echo " *** FAILED ***"
|
|
echo "Could not create static files (hugo). Aborting..."
|
|
clean_up
|
|
# exit with 1, so the update does not proceed, so we will know
|
|
exit 1
|
|
fi
|
|
|
|
echo -n ">>> Pushing files to server..."
|
|
|
|
ret="$(rsync --no-motd -acvhz --stats --del public/ bor:/var/www/sites/oe7drt/ > /dev/null 2>&1)"
|
|
|
|
if [ "$?" -eq "0" ] ; then
|
|
echo " Success!"
|
|
else
|
|
echo " *** FAILED ***"
|
|
echo "Could not sync files to webserver (rsync). Aborting..."
|
|
clean_up
|
|
exit 1
|
|
fi
|
|
|
|
clean_up
|
|
|