-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.sh
executable file
·49 lines (41 loc) · 1.44 KB
/
run.sh
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
47
48
49
#!/bin/bash
source ./tools/processes_descendents_kill.sh
source ./tools/terminal_format.sh
# Trap the script exit signal and send SIGINT to the server process
trap 'processes_descendents_kill $$' EXIT SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL
echo "${bold}Welcome to the Tigerlings exercises!${normal}"
echo ""
echo "This script will run each exercise and stop when it gets to a broken one."
echo "Once you've fixed that exercise, run this script again to continue."
echo ""
# Run each exercise
for file in $(ls exercises/[0-9][0-9][0-9]*.sh | sort -n); do
echo "${bold}Running exercise: ./$file${normal}"
if [ "$file" = "exercises/000_download.sh" ]; then
# Only download/build TigerBeetle if it's not already available
if ./tigerbeetle version >/dev/null 2>&1; then
echo "TigerBeetle is already available. Skipping exercise."
else
"$file"
fi
elif [ "$file" = "exercises/002_server.sh" ]; then
# Execute the file in the background and store its process ID
"$file" 2>&1 | sed "s/^/${bold}[Server]${normal} /" &
server_pid=$!
sleep 1
if ! kill -0 $server_pid 2>/dev/null; then
exit 1
fi
else
# Execute the file normally
"$file"
fi
# Check the exit status
if [ $? -ne 0 ]; then
echo ""
echo "Uh oh, there is a problem in ./$file!"
exit 1
fi
echo ""
done
processes_descendents_kill $$