about summary refs log tree commit diff stats
path: root/dscip
diff options
context:
space:
mode:
Diffstat (limited to 'dscip')
-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
 }
id='n179' href='#n179'>179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284