Ok, so here's a xeno_dropbear initscript that's generic enough to be used a template for other daemons. You can change the xeno_ prefix to irixce_ or anything else that makes sense. But I do recommend a prefix of some sort, not just to separate your stuff from IRIX-native, but also because killing the daemon with 'killall' could also kill the script itself without a prefix in its name. (Learned that the hard way!)
Code:
#!/bin/sh
##
## Start or stop the dropbear daemon
##
## Set custom options in /etc/config/xeno_dropbear.options to override
## default configuration
##
## Script heavily based on SGI's fw_sshd initscript
NAME=dropbear
DESCRIPTION="Dropbear SSH Daemon"
DAEMON=/opt/xeno/sbin/$NAME
CONFIG=/etc/config/xeno_$NAME.options
/sbin/chkconfig xeno_$NAME
IS_ON=$?
if `/sbin/chkconfig verbose`; then
ECHO=echo
else
ECHO=:
fi
LD_LIBRARYN32_PATH=/opt/xeno/lib32
export LD_LIBRARYN32_PATH
function start_daemon {
if test "$IS_ON" -eq 0 && test -x "$DAEMON"; then
$ECHO -n "Starting $DESCRIPTION ... "
if [ -r "$CONFIG" ]; then
$DAEMON `cat "$CONFIG"`
else
$DAEMON
fi
$ECHO "done"
else
$ECHO "$NAME disabled by chkconfig"
fi;
}
function stop_daemon {
$ECHO -n "Stopping $DESCRIPTION ... "
/sbin/killall -TERM "$NAME"
$ECHO "done";
}
case "$1" in
start)
start_daemon
;;
restart)
stop_daemon
start_daemon
;;
stop)
stop_daemon
;;
*)
echo "usage: $0 {start|stop|restart}"
;;
esac
You should only need to change the $NAME and $DESCRIPTION variables for most other daemons.
It obeys the chkconfig verbose setting and will output what it is doing or not accordingly.
To properly integrate with IRIX, the xeno_dropbear script needs to be placed in /etc/init.d and suitable Kxx and Sxx symlinks created in rc0.d and rc2.d respectively. You also need to create /etc/config/xeno_dropbear containing either "on" or "off" (without quotes) depending on whether you want it to default to being enabled or disabled. Users can then toggle it on/off and check its status with chkconfig as with any other daemon. You can optionally create /etc/config/xeno_dropbear.options with the command line options needed. It will be used automatically if present. (Just like real IRIX initscripts do.)
Possible future enhancements would include using a PID file. (Dropbear creates one by default by not everything does.) That would allow checking to see if it's already running and giving a graceful exit in that case and allow more fine-tuned use of 'kill $PID' rather than the coarse-grained 'killall' approach in this script. But that's "left as an exercise for the reader" as the saying goes. This isn't meant to be the Holy Grail of initscripts. It's a basic starting point.
If you have questions about what I did or why, feel free to ask. I'm sure there are more quirks I should have mentioned but I'm not thinking of them now.