home · contact · privacy
Repaired buggy check for out file generation time in init shell script.
[plomrogue] / roguelike
1 #!/bin/sh
2
3 # Abort the script on error.
4 set -e
5
6 # Use the shell script's arguments to the server's arguments.
7 ./roguelike-server $@ &
8
9 # Give server some time to start up and exit on error.
10 sleep 0.01
11
12 # The client should not start if the server is not running. (If the server was
13 # running in the foreround, any error exit of it so far would be caught by "set
14 # -e" above. But "set -e" is blind to error codes generated in the background.)
15 kill -0 $! 2> /dev/null
16
17 # Give server some time (max. 10 seconds) to generate its out file.
18 i=0
19 while [ ! -e server/out ] && [ $i -le 1000 ]
20 do
21     sleep 0.01
22     i=`expr $i + 1`
23 done
24 if [ ! -e server/out ]
25 then
26     echo "Server failed generating outfile within given time limit."
27     false
28 fi
29
30 # Only start the interface when everything else went well.
31 kill -0 $! 2> /dev/null
32 ./roguelike-client