-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_script.sh
More file actions
executable file
·46 lines (36 loc) · 807 Bytes
/
run_script.sh
File metadata and controls
executable file
·46 lines (36 loc) · 807 Bytes
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
37
38
39
40
41
42
43
44
45
46
#!/bin/zsh
cd "$(dirname "$0")"
source ./util/echo_colors.sh
source ./util/timeout.sh
source "$1"
script_name=$(basename "$1")
if ! dependencies_met; then
echo_danger "Dependencies not met, skipping."
exit 1
fi
if ! needs_run; then
echo_primary "Doesn't need to run."
exit 0
fi
_perform() (
set -Ee
if [[ -v TIMEOUT_SECONDS ]]; then
timeout $TIMEOUT_SECONDS run < /dev/null
else
run < /dev/null
fi
echo_primary "Run completed successfully."
)
echo_primary "Running script..."
_perform
if [ "$?" = '0' ]; then; exit 0; fi
echo_warning "Failed, trying again..."
sleep 5
_perform
if [ "$?" = '0' ]; then; exit 0; fi
echo_warning "There was another failure, trying once more..."
sleep 10
_perform
if [ "$?" = '0' ]; then; exit 0; fi
echo_danger "Final retry failed."
exit 1