3 # control script for one channel
9 start AMBROS control instance configured by <configfile>
14 # save directories of scripts and instance ("root", configuration file)
15 # is somewhat complicated to correctly handle relative paths
16 # (not using $OLDPWD etc to keep better portability)
20 echo SCRIPTDIR
: $SCRIPTDIR
24 echo ROOTDIR
: $ROOTDIR
25 AMBROSCONFIG
=`basename $1`
27 cd $SCRIPTDIR ||
{ echo "cannot access scripts in $SCRIPTDIR" ; exit 3 ; }
28 # read global settings
30 # (re)generate morse code table
31 cd morse
&& .
/chargen.sh
33 if test ! -d "$ROOTDIR" -o ! -x "$ROOTDIR" -o ! -r "$ROOTDIR" -o ! -w "$ROOTDIR"
34 then echo "base directory ($ROOTDIR) is not usable, aborting!"
42 echo working
in channel
$ROOTDIR
43 lchannels
=`configread $AMBROSCONFIG CHANNELS '.,:;/'`
44 echo listed channels
: $lchannels
46 # collect channel directory names
50 if test -d $ch -a -x $ch -a -r $ch -a -w $ch
51 then channels
="$ch $channels"
52 else echo "channel $ch is not read/write/accessible directory, ignoring!"
58 GLOBALSPEED
=`configread $AMBROSCONFIG WPM`
59 GLOBALSPEED
=${GLOBALSPEED:-12}
60 echo global speed
$GLOBALSPEED Words
/min
63 if test ! -d "$SOURCEDIR" -o ! -x "$SOURCEDIR" -o ! -r "$SOURCEDIR" -o ! -w "$SOURCEDIR"
64 then echo "source directory ($ROOTDIR/$SOURCEDIR) is unusable, aborting!"
68 # handler for aborting
71 echo received abort signal
: stopping all subprocesses
72 # if no PID is set, use 1 (init) as a dummy argument
73 /bin
/kill -TERM ${pidassembler:-1} $pidchannelchief
74 echo and ending main control loop
80 trap finish INT TERM STOP
82 echo entering main control loop with PID $$
84 tmpf
=${TMP:-/tmp}/ambros$$.tmp
86 while test $AMBROSABORT -eq 0
87 do : # main control loop
89 echo passing main control loop
92 # collect source names
95 csources
=`configread "$ch/$CHANNELCONFIG" SOURCES '.,:;/'`
96 lsources
="$csources $lsources"
98 #echo listed sources: $lsources
99 cd $ROOTDIR/$SOURCEDIR
104 } |
sort -r |
uniq |
{
107 if test -d "$sc" -a -x "$sc" -a -r "$sc" -a -w "$sc"
113 echo currently valid sources
: $sources
115 # fetch and process sources
116 $SCRIPTDIR/extractor
$sources
118 # start&control `assembler`
119 # start&control `channelchief`