diff --git a/Config/HugoExample/files/cronjob.sh b/Config/HugoExample/files/cronjob.sh index 1560710..e132641 100644 --- a/Config/HugoExample/files/cronjob.sh +++ b/Config/HugoExample/files/cronjob.sh @@ -3,11 +3,18 @@ cd /var/www/hugo/site FORCE="$1" -BASEURL="$2" + +# Pull URL from env if it exists, otherwise var2. +BASEURL="${BASEURL:-$2}" +declare baseurl +if [[ -n "$BASEURL" ]]; then + baseurl="-b $BASEURL" +fi echo "*** Running cronjob @ `date` ***" echo "FORCE=$FORCE" echo "BASEURL=$BASEURL" +echo "baseurl=$baseurl" # Pull any updates, and if the project is already up to date, exit successfully. git pull | grep -v "up to date" @@ -20,7 +27,7 @@ fi # If the project was not already up to date, build the new files for NGINX. set -x -/usr/local/bin/hugo $BASEURL --gc --minify +/usr/local/bin/hugo $baseurl --gc --minify set +x status="$?" echo "* Hugo status is '$status', FORCE is '$FORCE'." diff --git a/Config/HugoExample/files/main.sh b/Config/HugoExample/files/main.sh index 61988f0..e3ad615 100644 --- a/Config/HugoExample/files/main.sh +++ b/Config/HugoExample/files/main.sh @@ -1,23 +1,23 @@ #!/usr/bin/env bash -REPO="$1" +export REPO="$1" echo "REPO='$REPO'" -BRANCH="$2" +export BRANCH="$2" if [[ -n $BRANCH ]]; then BRANCH="--branch $BRANCH" fi echo "BRANCH='$BRANCH'" -PROD="$3" +export PROD="$3" typeset -u PROD echo "PROD='$PROD'" -DEV="$4" +export DEV="$4" typeset -u DEV echo "DEV='$DEV'" -BASEURL="$5" +export BASEURL="$5" echo "BASEURL='$BASEURL'" baseurl="" if [[ -n "$BASEURL" ]]; then @@ -47,7 +47,7 @@ mv -v $CLONE $SITE echo "*** Copying Static Files to NGINX ***" rm -rfv /var/www/html/* -sudo -u www-data /var/www/hugo/cronjob.sh "" "$baseurl" +sudo -u www-data /var/www/hugo/cronjob.sh " " "$BASEURL" echo "*** Starting Cron ***" service cron start