added build command for deployment

master
Kebler Network System Administrator 2021-11-24 08:04:04 -08:00
parent 7e44347594
commit 77d388f94c
1 changed files with 32 additions and 0 deletions

32
build Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
[[ ! $1 ]] && echo must specify a site name to build && 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 build"
cat $ENV_FILE
echo '************************'
else
echo warning no environoment file set for $1 in $RDIR/sites
fi
DATA_DIR=${DATA_DIR:-${HOME}/.local/hugo}
SOURCE_DIR=${DATA_DIR}/${1}$([[ $DATA_SUB_DIR ]] && echo "/$DATA_SUB_DIR")
DEPLOY_DIR=${DEPLOY_DIR:-${DATA_DIR}/${1}$([[ $DEPLOY_SUB_DIR ]] && echo "/$DEPLOY_SUB_DIR" || echo "/deploy")}
HUGO=${HUGO:-$(command -v hugo)}
PORT=${PORT:-8096}
echo site files output to ${DEPLOY_DIR}
CMD="$HUGO
--themesDir $RDIR/themes
--source $SOURCE_DIR
--baseURL ${DEPLOY_URL:-localhost}
--destination ${DEPLOY_DIR}
"
echo '*********** building site for deployment **********'
echo $CMD
echo '**************************************'
eval $CMD