1#! @runtimeShell@ -e
2
3# skip this if there are no modems at all
4if ! stat -t "@spoolAreaPath@"/etc/config.* >/dev/null 2>&1
5then
6 exit 0
7fi
8
9echo "faxq started, waiting for modem(s) to initialize..."
10
11for i in `seq @timeoutSec@0 -1 0` # gracefully timeout
12do
13 sleep 0.1
14 # done if status files exist, but don't mention initialization
15 if \
16 stat -t "@spoolAreaPath@"/status/* >/dev/null 2>&1 \
17 && \
18 ! grep --silent --ignore-case 'initializing server' \
19 "@spoolAreaPath@"/status/*
20 then
21 echo "modem(s) apparently ready"
22 exit 0
23 fi
24 # if i reached 0, modems probably failed to initialize
25 if test $i -eq 0
26 then
27 echo "warning: modem initialization timed out"
28 fi
29done