cosmetics; change ToC timing base
[ambros.git] / src / planner
blobf6e7e3af611a20777784cd6b0802c4c9e5e36350
1 #!/bin/sh
2 # planner:
3 # assemble transmission texts from clean texts
4 # arg1=channel
5 # environment variables ROOTDIR and SCRIPTDIR must be defined by caller,
6 # and script must be called from channel directory as working directory
8 . $SCRIPTDIR/constants.sh
10 # save channel name for reference - but we should already be in that directory
11 chan=$1
13 myself=planner-$chan
14 logf=`logfile $myself`
15 statf=$STATUSDIR/$myself
17 statrep $statf STATUS initializing
19 # check if config file present, if not, sleep to reduce load
20 if ! -r $CHANNELCONFIG
21 then
22 logit $logf FAIL missing config file $CHANNELCONFIG
23 statrep $statf STATUS FAIL missing config file $CHANNELCONFIG
24 sleep 10
25 return 1
28 # check if prefix defined -- we cannot define it here by ourselves!
29 if ! prefix=`configread $CHANNELCONFIG PREFIX`
30 then
31 logit $logf FAIL missing PREFIX definition in $CHANNELCONFIG
32 statrep $statf STATUS FAIL missing PREFIX definition in $CHANNELCONFIG
33 sleep 10
34 return 1
37 # handler for restarting/reloading
38 restart () {
39 logit $logf signal reloading configuration files and restarting
40 RESTARTPLANNER=1
42 # flag initially _set_ to force initializing during launch
43 # will be reset after initialization routine
44 RESTARTPLANNER=1
45 trap restart $SIGDAEMONRESTART
47 # handler for stopping
48 finish () {
49 logit $logf signal finishing
50 ABORTPLANNER=1
52 ABORTPLANNER=0
53 trap finish $SIGDAEMONTERMINATE
55 while test ABORTPLANNER -eq 0
56 # reduce load in case of severe bugs/problems
57 do sleep 3
58 if test $RESTARTPLANNER -eq 1
59 then
60 sources=`configread $CHANNELCONFIG SOURCES ',:;'`
61 logit $logf config sources: $sources"
62 # last resource default: no postprocessor, i.e `cat`
63 postprocessor=`configread $CHANNELCONFIG POSTPROCESSOR`
64 postprocessor=${postprocessor:-/bin/cat}
65 logit $logf config postprocessor: $postprocessor
66 # last resource defaults: ToC length 2min, ToC retransmission period 3 slices
67 toclength=`configread $CHANNELCONFIG TOCLENGTH`
68 toclength=${toclength:-120}
69 tocslices=`configread $CHANNELCONFIG TOCSLICES`
70 tocslices=${tocslices:-3}
71 # do not restart until signal received again
72 RESTARTPLANNER=0
75 done