tildeblack-ops/docsgen.sh

35 lines
867 B
Bash
Raw Normal View History

2019-08-01 12:04:13 +00:00
#!/bin/sh
2019-08-06 15:10:11 +00:00
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
2019-08-01 12:04:13 +00:00
set -e
2019-08-06 15:49:26 +00:00
DOC_DIR="/root/docs"
2019-08-01 12:04:13 +00:00
cd "${DOC_DIR}" || exit 1
# fetch the latest remote repo changes
2019-08-06 15:49:26 +00:00
/usr/local/bin/git fetch origin master -q 2> /dev/null
2019-08-01 12:04:13 +00:00
# get shas for our local repo and remote repo
2019-08-06 15:49:26 +00:00
remotesha=$(/usr/local/bin/git rev-parse origin/master)
localsha=$(/usr/local/bin/git rev-parse HEAD)
2019-08-01 12:04:13 +00:00
# if shas are different, we need to update
if [ "$remotesha" != "$localsha" ] || [ "$1" = "force" ]; then
# clear all our local changes
2019-08-06 15:49:26 +00:00
/usr/local/bin/git reset --hard HEAD -q
2019-08-01 12:04:13 +00:00
# pull in the latest updates from remote
2019-08-06 15:49:26 +00:00
/usr/local/bin/git pull -q origin master 2> /dev/null
2019-08-01 12:04:13 +00:00
# build the web version
2019-08-06 15:49:26 +00:00
/usr/local/bin/mkdocs -q build > /dev/null
2019-08-01 12:04:13 +00:00
# clear the gopher version
2019-08-06 15:49:26 +00:00
rm -f /var/gopher/docs/*.md
2019-08-01 12:04:13 +00:00
# copy files to the gopher version
2019-08-01 12:41:01 +00:00
cd "${DOC_DIR}/docs/" || exit 1
2019-08-06 15:49:26 +00:00
cp ./* /var/gopher/docs/
2019-08-01 12:04:13 +00:00
fi