uci-hugo/run

42 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
[[ ! $1 ]] && echo must specify a site name to run && exit
RDIR=$(cd $(dirname $(readlink -f "$0")) >/dev/null 2>&1 ; pwd -P)
# source any environment for particular site
shopt -s extglob
ENV_FILE=$(ls $RDIR/sites/${1}* 2> /dev/null | grep -v '.off$\|.tmpl$\|.template$')
if [[ $ENV_FILE ]]; then
source $ENV_FILE
echo '***********************'
echo "sourcing $ENV_FILE environment file for hugo run"
cat $ENV_FILE
echo '************************'
else
echo warning no environoment file set for $1 in $RDIR/sites
fi
DATA_DIR=${DATA_DIR:-${HOME}/.local/hugo}
DATA_DIR=${DATA_DIR}/${1}$([[ $DATA_SUB_DIR ]] && echo "/$DATA_SUB_DIR")
HUGO=${HUGO:-$(command -v hugo)}
PORT=${PORT:-8096}
echo site files in $DATA_DIR listening on port $PORT
# [[ $(netstat -tulpn | grep LISTEN | grep 0.0.0.0:$PORT) ]] && echo tcp port $PORT is busy can not start hugo server && exit
mkdir -p $DATA_DIR
# start hugo in the data directory (needed for git module)
cd $DATA_DIR
ls -la
CMD="$HUGO server
$([[ $BASE_URL = "https://"* ]] && echo " --liveReloadPort 443")
--bind 0.0.0.0
--themesDir $RDIR/themes
--source $DATA_DIR
--port $PORT
--appendPort=$([[ $REVERSE_PROXY = true ]] && echo false || echo true)
--baseURL ${BASE_URL:-localhost}
"
# --config /mnt/data/$SRC/config.yaml
# --logFile /opt/docs-kebler-net/server.log
echo '*********** running command **********'
echo $CMD
echo '**************************************'
eval $CMD