Files
staticzolaserver-docker/git2zola.sh
T

66 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# bash deamon to check git for new content
# make a pull from repository
# - with ssh keys ( problem with private key in this repository )
# - with https user login ( problrm with TLS error with own gogs
# - with auth token (not implemented in gogs yet)
#default sws docker path
OUTPUT_DIR='/public'
BASE_URL='docker.local'
GITPROJECTNAME=serinty-website
GITPROJECTUSER=Serinty
GITSERVER=gogs.serinty.net
GITSERVERPORT=22104
GITUSER=gogs
GITPASSWD=gogspw
SERVICEENAME="static-web-server"
if [ -z $IDLE_TIME ]
then
# one day
IDLE_TIME=86400
fi
if [ -z ${SWSPORT} ]
then
# port over 1024 for normal user
SWSPORT=8970
fi
trap "exit" EXIT
startSWSifNotRunning()
while true
do
git status --porcelain
gitstatus=$?
echo ${gitstatus}
if [ ${gitstatus} -eq 128 ]
then
git clone ${GITCLONEURL}
elif [ ${gitstatus} -eq 0 ]
then
gitpull=$(git pull --dry-run --ff-only)
if [ ! -z ${gitpull} ]
then
git pull --ff-only
zola build --base-url $BASE_URL --output-dir $OUTPUT_DIR
fi
fi
sleep ${IDLE_TIME}
done
func startSWSifNotRunning () {
#static-web-server is /usr/local/bin/static-web-server and in path
if pgrep -x "$SERVICENAME" >/dev/null
then
static-web-server --port ${SWSPORT} --log-level warn --root ~/public &
fi
}