From 71e7432979ff32478f942b153cfe75a31a2dd838 Mon Sep 17 00:00:00 2001 From: Charadon Date: Mon, 8 Aug 2022 21:46:40 -0400 Subject: Added auto update feature, by default it's off. --- config.sh | 5 ++++- dscip | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config.sh b/config.sh index 342ff83..683a67f 100755 --- a/config.sh +++ b/config.sh @@ -28,4 +28,7 @@ export DSCIP_SLEEP="60" # How many seconds before the daemon re-runs itself. # # etc # export DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild even # # if upstream has not updated. # -export DSCIP_OUTPUT_TO="$WORKING_DIRECTORY/output.txt" # Output to file, default is stdout. +export DSCIP_OUTPUT_TO="$WORKING_DIRECTORY/output.txt" # Output to file, default is output.txt +# Automatically update DSCIP? +export DSCIP_AUTO_UPDATE="true" + diff --git a/dscip b/dscip index d27c9cc..99915ee 100755 --- a/dscip +++ b/dscip @@ -15,11 +15,30 @@ # See the License for the specific language governing permissions and # # limitations under the License. # ################################################################################ - set -eu + +# Grab checksum of DSCIP for use with updating. +DSCIP_CKSUM="$(cksum "$0")" + cd "$(dirname "$0")" . "$(pwd -P)/config.sh" +# Checking updates +if [ "$DSCIP_AUTO_UPDATE" = "true" ]; then + . "$WORKING_DIRECTORY/update.sh" + DSCIP_NEW_CKSUM="$(cksum "$0")" + # Rerun dscip if update was found. + if [ ! "$DSCIP_CKSUM" = "$DSCIP_NEW_CKSUM" ]; then + echo "Update found. Rerunning DSCIP..." + "$SHELL" "$0" "$@" + exit 0 + else + echo "No updates found. Continuing..." + fi +else + echo "Auto updates turned off. Continuing..." +fi + ################################################################################ # Move script to background if DSCIP_DAEMON_FORK is set to true # -- cgit 1.4.1-2-gfad0