tildeblack-ops/docsgen.sh

35 lines
867 B
Bash
Executable File

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