#! /bin/sh ### BEGIN INIT INFO # Provides: irserver # Required-Start: # Default-Start: 2 # Default-Stop: # Short-Description: IRTrans Infrared Control # Description: Starts the IRTrans Infrared Control Server. ### END INIT INFO # # Author: Helmar Gerloni # Version: 2006-03-17 # PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="IRTrans Infrared Control Server" NAME=irserver PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # # Function that starts irserver. # d_start() { start-stop-daemon --start --chdir /usr/local/irtrans/ --exec /usr/local/irtrans/irserver -- -no_web -daemon -logfile /var/log/irserver.log /dev/ttyUSB0 if [ $? -gt 0 ]; then # After stopping irserver with the "irclient -shutdown" command the server-port 21000/tcp # is not closed properly. The port stays in status TIME_WAIT and is released only after the tcp-timeout. # After this timeout the server can be started again. echo "Error starting irserver." echo "If you just stopped irserver before please wait for a few seconds and try again." exit $? fi expr $$ + 2 > $PIDFILE } # # Function that stops irserver. # d_stop() { # Stopping the daemon with start-stop-daemon does not turn off the VFD display # start-stop-daemon --stop --quiet --pidfile $PIDFILE # A single shutdown might not be enough /usr/local/irtrans/irclient 127.0.0.1 -shutdown & /usr/local/irtrans/irclient 127.0.0.1 -shutdown if [ $? -gt 0 ]; then echo "Error stopping irserver on localhost. Probably irserver is not running." fi } case "$1" in start) echo -n "Starting $DESC: $NAME" d_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" d_stop echo "." ;; restart|force-reload) echo -n "Restarting $DESC: $NAME. Waiting for 60 seconds before starting again..." d_stop sleep 61 d_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0