summaryrefslogtreecommitdiff
path: root/job.common
blob: a27ce127da38c3f6c6e132f98033c7bc7748980a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# vim: ft=sh
set -e
# Ensure niceness at least 10
if [ "$(nice)" -lt 10 ]; then
	exec nice "$0" "$@"
fi

# Use fake laminar in case of external execution
if [ -z "$WORKSPACE" ]; then
	. "$(dirname "$(readlink -f "$0")")/../fakelaminar"
fi

# Subprocess inclusion guard
if [ -z "$LAMINAR_COMMON" ]; then
	export LAMINAR_COMMON=y

	# Job and template id
	JOBID="$(basename "$0" | sed 's/\.run$//')"
	TEMPLATEID="$(basename "$(readlink -f "$0")" | sed 's/\.run$//')"
	export JOBID TEMPLATEID

	# Template workspace
	TWORKSPACE="$HOME/workspace/$TEMPLATEID"
	if [ "$JOBID" = "$TEMPLATEID" ]; then
		TWORKSPACE="$HOME/workspace/notemplate"
	fi
	export TWORKSPACE

	# Files directory
	FILES="$(readlink -f "$(dirname "$(readlink -f "$0")")/../files")"
	export FILES

fi

# Include utils
. utils