File irda-0.9.18.init of Package irda

#!/bin/sh
# Copyright (c) 2002,2006 SuSE Linux AG, Nuernberg, Germany.
#
# Author: Christian Zoz <zoz@suse.de>
#
# chkconfig: 2345 45 96
#
# /etc/init.d/irda
#
#   and it's symbolic link
#
# /usr/sbin/rcirda
#
### BEGIN INIT INFO
# Provides:        irda
# Required-Start:  $remote_fs $syslog
# Should-Start:	   setserial
# Required-Stop:   $remote_fs $syslog
# Default-Start:   3 5
# Default-Stop:    0 1 2 6
# Short-Description: Prepare for IrDA use
# Description:     attaches /dev/ircomm to the IrDA port and starts detection
### END INIT INFO

. /etc/rc.status
. /etc/sysconfig/irda

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status

# First reset status of this service
rc_reset
case "$1" in
    start)
	ARGS="$IRDA_PORT"
	if [ $IRDA_DONGLE ]; then
		ARGS="$ARGS -d $IRDA_DONGLE"
	fi
	if [ "$IRDA_DISCOVERY" != "no" ];then
		ARGS="$ARGS -s"
	fi
	echo -n "Starting service IrDA"
	modprobe ircomm-tty
	# Set the maximum baud rate if requested
	if [ -n "$IRDA_MAX_BAUD_RATE" -a "$IRDA_MAX_BAUD_RATE" -ne "0" ] ; then
	    echo $IRDA_MAX_BAUD_RATE >/proc/sys/net/irda/max_baud_rate
	fi
	## Start daemon with startproc(8). If this fails
	## the echo return value is set appropriate.
	startproc /usr/sbin/irattach ${ARGS} >/dev/null
	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down service IrDA"
	## Stop daemon with killproc(8) and if this fails
	## set echo the echo return value.
	killproc -TERM /usr/sbin/irattach
	# Remember status and be verbose
	rc_status -v
	;;
    try-restart)
	$0 status >/dev/null && $0 restart
	;;
    restart|force-reload)
	## If first returns OK call the second, if first or
	## second command fails, set echo return value.
	$0 stop
	$0 start
	# Remember status and be quiet
	rc_status
	;;
    reload)
	;;
    status)
	echo -n "Checking for service IrDA: "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.
	checkproc /usr/sbin/irattach
	# Remember status and be verbose
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|[try-]restart|[force-]reload}"
	exit 1
	;;
esac
rc_exit