Debian init script...
Posted: Fri 12. Mar 2010, 22:14
The following is a Debian/Ubuntu compatible init script for irserv(64). It works well enough for me (I have an irtrans ethernet), and I thought I'd share:
And the following is the config file I've used (/etc/default/irserver)
To enable it at boot, run (as root or sudo):
I can probably adapt it for RedHat & openSUSE if anybody asks nicely...
- Code: Select all
#!/bin/sh
### BEGIN INIT INFO
# Provides: irserver
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts irserver64 daemon
# Description: irserver64 provides a lirc-compatible daemon for IRTrans modules.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/irtrans
DAEMON=/usr/local/irtrans/irserver64
CONFIG=/etc/default/irserver
NAME=irserver
DESC="irtrans server"
test -x $DAEMON || exit 0
test -e $CONFIG || exit 0
set -e
. $CONFIG
if [ "x$ISCONFIGURED" != "xyes" ] ;
then
echo "Please check your configuration ISCONFIGURED in /etc/default/irserver"
exit 0
fi
case "$1" in
start)
echo -n "Starting $DESC: "
if [ "`pidof ${DAEMON}`" = "" ]
then
start-stop-daemon --start --quiet --exec $DAEMON -- $OPTIONS
echo "$NAME."
else
echo ""
echo "A copy of the daemon is still running. If you just stopped it,"
echo "please wait about 5 seconds for it to shut down."
exit 0
fi
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --oknodo --pidfile /var/run/irserver64.pid || echo "Not Running."
rm -f /var/run/irserver64.pid
echo "$NAME."
;;
restart|force-reload)
$0 stop
sleep 10
$0 start
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
And the following is the config file I've used (/etc/default/irserver)
- Code: Select all
DEFAULT_OPTIONS="-timestamp -learned_only"
LOGFILE="-logfile /var/log/irtrans.log"
LOGLEVEL="-loglevel 4"
#DEVICE="/dev/usb/ttyUSB0"
DEVICE="lan"
#DEVICE="192.168.1.2"
export OPTIONS="${DEFAULT_OPTIONS} ${LOGFILE} ${LOGLEVEL} -pidfile /var/run/irserver64.pid -daemon ${DEVICE}"
export ISCONFIGURED="yes"
To enable it at boot, run (as root or sudo):
- Code: Select all
update-rc.d irserver defaults
I can probably adapt it for RedHat & openSUSE if anybody asks nicely...