First we need /etc/init/dgrp.conf.
# Digi EtherLite # Starts a agetty for each serial port # Normally run from the start-dgrp.conf task stop on runlevel [S016] env TERM=vt100 env BAUD=19200 respawn instance $ID exec /sbin/agetty -L tty$ID ${BAUD:-19200} ${TERM:-vt100} usage 'dgrp ID=XX [BAUD=YYYYY] [TERM=ZZZZ] - where XX is terminal id (A10) and YYYYY is baud (12900) and ZZZZ is the termcap entry (vt100)'
You can test this by starting an agetty on ttyA01 with:
initctl start dgrp ID=A01
Stop it with:
initctl stop dgrp ID=A01
Now create /etc/sysconfig/dgrp. Each line is the ID with an optional baud rate (default 19200) and TERM (default vt100) setting:
A01 A02 9600 vt100 A10 19200 wy60
Now we create the controlling task. This gets run after rc?.d is finished. It reads /etc/sysconfig/dgrp and runs dgrp.conf where needed.
# Digi Etherlite # This task will read /etc/sysconfig/dgrp and will run dgrp.conf for each line in it # It is run after all rc?.d the scripts are run start on stopped rc RUNLEVEL=[2345] env CONFIG=/etc/sysconfig/dgrp task script test -f $CONFIG || ( logger -t start-dgrp.conf "$CONFIG doesn't exist"; exit 0 ) test -d /proc && test -d /proc/dgrp || ( logger -t start-dgrp.conf "drpd daemon is not running" ; exit 3 ) temp=$(mktemp --tmpdir) grep -v '#' $CONFIG >$temp while read ID BAUD TERM ; do ID=$(basename $ID) initctl start dgrp ID=${ID/tty} BAUD=$BAUD TERM=$TERM done < $temp end script
We use a temporary file so that we can ignore comments in the dgrp config file.