Debian init script...

The IRTrans FAQ list

Moderator: marcus

Debian init script...

Postby Pariah_Zero » 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:
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...
Pariah_Zero
 
Posts: 3
Joined: Fri 12. Mar 2010, 02:18

Re: Debian init script...

Postby IRTrans » Sat 13. Mar 2010, 01:24

Thank you !

We are sure a lot of people will be happy about that.

IRTrans
IRTrans
Administrator
 
Posts: 2115
Joined: Mon 21. Apr 2008, 23:32

Re: Debian init script...

Postby Tozz » Thu 21. Oct 2010, 15:38

Works like a charm, thanks!
Tozz
 
Posts: 3
Joined: Thu 21. Oct 2010, 15:21


Return to FAQs

Who is online

Users browsing this forum: No registered users and 1 guest