How to launch a daemon conditionally?

upstart at eehouse.org upstart at eehouse.org
Thu Feb 7 21:02:06 GMT 2008


I want to modify /etc/event.d/ttyS2 to not launch getty when
/dev/ttyS2 is not present.  The naive fix, adding a test to the main
script stanza, means the stanza is respawned 10 times.  The fix that
works is to use two files, one started automatically to check but not
respawn, and one to launch and respawn but that has no 'start on'
stanza, like this:

ttyS2_check:
   start on runlevel 2
   script
       if [ -e /dev/ttyS2 ]; then
           start -n ttyS2
       fi
   end script

ttyS2:
   stop on runlevel [!2]
   exec /sbin/getty -L ttyS2 115200 vt100
   respawn

Is there a better way?  I've tried having a pre-start script 'exit 1'
but that has no effect, nor does the code suggest it would.

Thanks,

--Eric
-- 
******************************************************************************
* From the desktop of: Eric House, xwords at eehouse.org                        *
*    Crosswords with Bluetooth on PalmOS now in beta: xwords.sourceforge.net *
******************************************************************************



More information about the upstart-devel mailing list