From 2a915fec69a3a15d80cc75b8f1750f15e4168b96 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Tue, 14 Oct 2025 13:06:21 -0700 Subject: [PATCH] Fancify script. --- cronjob.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cronjob.sh b/cronjob.sh index e1b2c9e..d94fbad 100755 --- a/cronjob.sh +++ b/cronjob.sh @@ -4,26 +4,37 @@ # project so that docker container can do periodic git pulls rather than having # to reload /rebuild the container each time a release is pushed out. +## Setup ## + DIR="$(dirname -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")" +cd $DIR +DIR="`pwd`" +NAME="'$PROG'" + +function log { + echo -e "`date` : $NAME - $1" +} function reload-project { ## Kill node.js which will complete run.sh and restart any Docker containers. #pkill node # Do not kill program, just use the new files and if run.sh or main.js were # changed then they can get reloaded manually or by the nightly backup. - echo "Project reloaded successfully!" + log "Project reloaded successfully!" } -echo "*** Running '$DIR/$PROG' @ `date` ***" +## Main ## + +log "Checking for updates..." cd $DIR # Pull any updates, and if the project is already up to date, exit successfully. git pull | grep -v "up to date" status="$?" -echo "* Pull status is '$status'." +log "Pull status is '$status'." if [[ $status != 0 ]]; then - echo "* Site is already up to date, exiting." + log "Site is already up to date, exiting." exit 0 else reload-project