about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharadon <charadon@charadon-gmpc.hsd1.ga.comcast.net>2022-07-14 00:16:13 -0400
committerCharadon <charadon@charadon-gmpc.hsd1.ga.comcast.net>2022-07-14 00:16:13 -0400
commitf1d82781ed9ff96fd936921e96792d3826be8931 (patch)
treef3970302bc4420de2f2eccebc2f5341110ee04cd
parenta3264936c80b7e460babb84631402248fcb12056 (diff)
downloaddscip-f1d82781ed9ff96fd936921e96792d3826be8931.tar.gz
Added an option to fork daemon to background, and added an option if it should rebuild the program regardless if the remote git repo hasn't changed.
-rwxr-xr-xdscip24
1 files changed, 20 insertions, 4 deletions
diff --git a/dscip b/dscip
index 4389614..045cd65 100755
--- a/dscip
+++ b/dscip
@@ -35,11 +35,22 @@ DSCIP_BUILD_CMD="$WORKING_DIRECTORY/build.sh"
 # Commands to run after building is done. #
 DSCIP_POST_CMD="$WORKING_DIRECTORY/post.sh"
 # Daemon mode options #
-DSCIP_DAEMON="false"
+DSCIP_DAEMON="false" # If daemon mode should be enabled or not. #
+DSCIP_DAEMON_FORK="true" # If the daemon should run in the background. #
 DSCIP_SLEEP="60" # How many seconds before the daemon re-runs itself. #
+# etc #
+DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild even #
+# if upstream has not updated. #
 
 ################################################################################
 
+if [ "$DSCIP_DAEMON" = "true" ]; then
+	if [ "$DSCIP_DAEMON_FORK" = "true" ] && [ ! "$FORKED" = "true" ]; then
+		FORKED=true nohup "$0" "$@" > /dev/null 2>&1
+		exit 0
+	fi
+fi
+
 build () {
 	if [ "$DSCIP_GITMODE" = "clone" ]; then
 		rm -rf "$WORKING_DIRECTORY/wrkdir" # Clean Up #
@@ -77,9 +88,14 @@ run () {
 	CURRENT_COMMIT=$(git ls-remote $DSCIP_GITREPO | awk "/refs\/(heads|tags)\/$DSCIP_BRANCH/{print \$1}")
 
 	# If LAST_COMMIT doesn't exist, that means it's a first run and we can go ahead and build. #
-	if [ -z "$LAST_COMMIT" ]; then
-		build
-	elif [ ! "$LAST_COMMIT" = "$CURRENT_COMMIT" ]; then # If the last commit and current commit don't match, then we go ahead and build.
+	# Or skip the commit check if DSCIP_DISREGARD_COMMIT_CHECK is set to true.
+	if [ "$DSCIP_DISREGARD_COMMIT_CHECK" = "false" ]; then
+		if [ -z "$LAST_COMMIT" ]; then
+			build
+		elif [ ! "$LAST_COMMIT" = "$CURRENT_COMMIT" ]; then # If the last commit and current commit don't match, then we go ahead and build.
+			build
+		fi
+	else
 		build
 	fi
 }