summaryrefslogtreecommitdiff
path: root/bin/matter-scheduler-chroot
blob: 356bbb87cec63856221d9ba92a2a96c7dbd67a82 (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
#!/bin/bash

safe_exec() {
	echo "safe_exec: ${*}"
	local tries=5

	for ((i=0; i < ${tries}; i++)); do
		"${@}" && return 0

		if [ "${i}" = "0" ]; then
			sleep 10
			continue
		else
			sleep 60
			continue
		fi
	done
	return 1
}

cd "${PARTICLES_DIR}" || exit 1
safe_exec git pull || exit 1
cd "${BUILD_GIT_DIR}" || exit 1
safe_exec git pull || exit 1

particles=$(find "${PARTICLES_DIR}" -name "*.particle" | sort)
if [ -n "${particles}" ]; then
    /usr/sbin/env-update
    . /etc/profile
    matter ${MATTER_ARGS} ${particles}
    exit ${?}
fi
exit 1