#!/bin/sh # # Start up the IrDA process and load necessary modules # if [ "`whoami`" != "root" ]; then sudo $0 $1 exit 0 fi function unload_module() { module=$1 if [ "`lsmod | grep ^$module | grep -v grep`" != "" ]; then echo -n " $module" /sbin/rmmod $module fi } MODULES="ircomm_tty irtty_sir sir_dev nsc_ircc ircomm irda" case "$1" in start) PID=`ps ax | grep irattach | grep -v grep | cut -d ' ' -f 1` if [ "$PID" != "" ]; then echo "irattach already running - aborting..." exit 1 fi # Start IRDA echo -n "Starting up the IR daemon and loading modules:" for module in $MODULES; do echo -n " $module" /sbin/modprobe $module done echo -n ", irattach" /usr/sbin/irattach irda0 -s >/dev/null echo . ;; stop) # Kill IRDA echo -n "Stopping IRDA and removing used modules: " # Kill the irattach process and remove the modules echo -n "irattach" while [ `pidof irattach` > 0 ]; do killall -9 -q irattach done echo -n ", modules:" for module in $MODULES; do unload_module $module done echo . ;; restart) $0 stop; $0 start ;; status) PID=`ps ax | grep irattach | grep -v grep | cut -d ' ' -f 1` if [ "$PID" = "" ]; then echo "IR daemon not running" else echo "IR daemon running at PID $PID" fi ;; *) echo "Usage: $0 {start|stop|restart|status}" echo " " exit 1 esac