#!/bin/sh ### BEGIN INIT INFO # Provides: gom-sensor-ports # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # X-Start-Before: kdm gdm xdm # X-Stop-After: kdm gdm xdm # Default-Start: 2 3 4 5 # Default-Stop: 1 # Short-Description: Start the gom-sensor-ports daemon # Description: running a gateway daemon to map simple TCP/UDP sensor values to GOM HTTP updates ### END INIT INFO set -e NAME=gom-sensor-ports DESC="t-gallery gom-sensor-ports daemon" GOM_NODE="http://gom.bonn.t-gallery/sensors/colours-and-materials/conducting-lacquer/" LOGFILE="/var/log/colours-and-materials.log" DAEMON_USER="webs" DAEMON=$(which ${NAME}) VERBOSITY="--verbose" PIDDIR=/var/run/colours-and-materials-gom-daemon PIDFILE=$PIDDIR/pid #VERBOSITY="--quiet" PARAMS="--logfile=${LOGFILE} ${GOM_NODE}" test -x $DAEMON || exit 0 # Get lsb functions . /lib/lsb/init-functions . /etc/default/rcS start_it_up() { if [ ! -d $PIDDIR ]; then mkdir -p $PIDDIR chown $DAEMON_USER $PIDDIR #chgrp $DAEMON_USER $PIDDIR fi touch $LOGFILE chown $DAEMON_USER $LOGFILE if [ -e $PIDFILE ]; then PIDDIR=/proc/$(cat $PIDFILE) if [ -d ${PIDDIR} -a "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then log_success_msg "$DESC already started; not starting." return else log_success_msg "Removing stale PID file $PIDFILE." rm -f $PIDFILE fi fi log_daemon_msg "Starting $DESC" "$NAME" /sbin/start-stop-daemon --start --background $VERBOSITY \ --make-pidfile --pidfile $PIDFILE \ -c $DAEMON_USER --exec $DAEMON -- $PARAMS log_end_msg $? } shut_it_down() { log_daemon_msg "Stopping $DESC" "$NAME" /sbin/start-stop-daemon $VERBOSITY --stop --retry 5 --oknodo \ --pidfile $PIDFILE --user $DAEMON_USER # We no longer include these arguments so that start-stop-daemon # can do its job even given that we may have been upgraded. # We rely on the pidfile being sanely managed log_end_msg $? rm -f $PIDFILE } case "$1" in start) start_it_up ;; stop) shut_it_down ;; restart) shut_it_down start_it_up ;; status) status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $? ;; *) log_success_msg "Usage: /etc/init.d/${NAME} {start|stop|restart|status}" exit 2 esac