about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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
 }