#! /bin/sh ### BEGIN INIT INFO # Provides: irserver # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts the irserver. # Description: Starts the irserver (IRTrans Infrared Control Server). ### END INIT INFO # # Author: Helmar Gerloni # Version: 2009-01-11 # PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="IRTrans Infrared Control Server" NAME=irserver PIDFILE=/tmp/.irserver.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 echo "Error starting irserver." echo "If you just stopped irserver before please wait for a few seconds and try again." exit $? fi } # # 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