diff --git a/run b/run new file mode 100755 index 0000000..e9262de --- /dev/null +++ b/run @@ -0,0 +1,36 @@ +#!/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} +HUGO=${HUGO:-$(command -v hugo)} +PORT=${PORT:-8096} +echo site files in $DATA_DIR/$1 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 +CMD="$HUGO server +$([[ $BASE_URL = "https://"* ]] && echo " --liveReloadPort 443") +--bind 0.0.0.0 +--themesDir $RDIR/themes +--source $DATA_DIR/$1 +--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 diff --git a/sites/example.off b/sites/example.off new file mode 100644 index 0000000..7f45367 --- /dev/null +++ b/sites/example.off @@ -0,0 +1,9 @@ +# defaults shown. uncomment and edit for your site +#PORT="8096" +# parent directory of where site files should be stored. +#DATA_DIR="${HOME}/.local/hugo" +# if using reverse proxy port will not be appended to base url +#REVERSE_PROXY=false +# be sure to use https if site is being served such, e.g. using Caddy. +# example: BASE_URL="https://site.domain.net" +#BASE_URL="localhost" diff --git a/systemd/hugo@.service b/systemd/hugo@.service new file mode 100644 index 0000000..dd1081d --- /dev/null +++ b/systemd/hugo@.service @@ -0,0 +1,18 @@ +[Unit] +Description=Live Hugo Server for a Site +After=network-online.target +Requires=opt.mount +After=opt.mount +Requires=mnt-data.mount +After=mnt-data.mount + +[Service] +# User=sysadmin +Group=sysadmin +Type=simple +ExecStart=/bin/bash /opt/hugo/run %i +# Restart=on-failure +# RestartSec=3 + +[Install] +WantedBy=default.target diff --git a/systemd/install b/systemd/install new file mode 100755 index 0000000..a8fe292 --- /dev/null +++ b/systemd/install @@ -0,0 +1,6 @@ +#!/bin/bash +# install template system space +DIR="$(dirname "$(readlink -f "$0")")" +sudo \cp -f $DIR/hugo@.service /etc/systemd/system +echo "hugo service template copied to systemd" +cat /etc/systemd/system/hugo@.service