Use a task which is started on change of runlevel to start a job for each IAXModem
you want to start. Then use a task to start a faxgetty
for each started iaxmodem
job.
IE:
init 3 -> start-iaxmodem ---> iaxmodem(ttyIAX0) -> start-faxgetty(ttyIAX0) -> faxgetty(ttyIAX0)
\-> iaxmodem(ttyIAX1) -> start-faxgetty(ttyIAX1) -> faxgetty(ttyIAX1)
/etc/init/start-iaxmodems.conf
:
# This service starts the configured number of gettys.
start on stopped rc RUNLEVEL=[2345]
task
script
for ttyIAX in /etc/iaxmodem/* ; do
start iaxmodem TTY=`basename $ttyIAX`
done
end script
/etc/init/iaxmodem.conf
:
# This service maintains an iaxmodem on the sepcified device.
stop on runlevel [016]
respawn
instance $TTY
exec /usr/sbin/iaxmodem $TTY
/etc/init/start-faxgettys.conf
:
# This service starts the configured number of faxgettys.
start on started iaxmodem
# this will run once per triggering iaxmodem instance
instance $INSTANCE
task
script
# give it time to at least create the device
/bin/sleep 1s
start faxgetty TTY=$INSTANCE
end script
/etc/init/faxgetty.conf
:
# This service maintains a faxgetty on the sepcified device.
# only stop when the stopping iaxmodem is this TTY
stop on stopping iaxmodem INSTANCE=$TTY
respawn
instance $TTY
exec /usr/sbin/faxgetty $TTY