2021-01-15 12:53:53 -08:00
|
|
|
#!/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$\|.example$\|.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}
|
2021-01-17 16:43:24 -08:00
|
|
|
DATA_DIR=${DATA_DIR}/${1}$([[ $DATA_SUB_DIR ]] && echo "/$DATA_SUB_DIR")
|
2021-01-15 12:53:53 -08:00
|
|
|
HUGO=${HUGO:-$(command -v hugo)}
|
|
|
|
PORT=${PORT:-8096}
|
2021-01-17 16:43:24 -08:00
|
|
|
echo site files in $DATA_DIR listening on port $PORT
|
2021-01-15 12:53:53 -08:00
|
|
|
# [[ $(netstat -tulpn | grep LISTEN | grep 0.0.0.0:$PORT) ]] && echo tcp port $PORT is busy can not start hugo server && exit
|
2022-04-30 12:51:56 -07:00
|
|
|
cd $DATA_DIR
|
|
|
|
ls -la
|
2021-01-15 12:53:53 -08:00
|
|
|
CMD="$HUGO server
|
|
|
|
$([[ $BASE_URL = "https://"* ]] && echo " --liveReloadPort 443")
|
|
|
|
--bind 0.0.0.0
|
|
|
|
--themesDir $RDIR/themes
|
2021-01-17 16:43:24 -08:00
|
|
|
--source $DATA_DIR
|
2021-01-15 12:53:53 -08:00
|
|
|
--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
|