#! /bin/sh # # nagixsc_http2nagios - start and stop the Nag(ix)SC HTTP server # http://oss.teamix.org/projects/nagixsc # # Copyright (C) 2010 Sven Velt # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ### BEGIN INIT INFO # Provides: nagixsc_conf2http # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: Nag(IX)SC HTTP Pull Server # Description: Nag(IX)SC HTTP Pull Server ### END INIT INFO # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/usr/sbin:/usr/bin:/sbin:/bin DESC="Nag(IX)SC Conf2HTTP" NAME=nagixsc_conf2http DAEMONPATH=/usr/local/nagixsc DAEMON=$DAEMONPATH/$NAME.py CFGFILE=$DAEMONPATH/etc/conf2http.cfg DAEMON_ARGS="-c $CFGFILE" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Look for daemon and config file if [ ! -r $DAEMON ] then echo "Daemon not found, exiting..." exit 1 fi if [ ! -r $CFGFILE ] then echo "Config file not found, exiting..." exit 1 fi is_running() { [ -f "$PIDFILE" ] || return 1 ps ax | grep "`cat $PIDFILE`" | grep $NAME | grep -qv grep return $? } do_start() { is_running && return 1 $DAEMON -d $DAEMON_ARGS || return 2 } do_stop() { is_running || return 1 kill -TERM "`cat $PIDFILE`" 2>/dev/null sleep 1 is_running || kill -KILL "`cat $PIDFILE`" 2>/dev/null if is_running then return 1 fi rm -f $PIDFILE } case "$1" in start) echo -n "Starting $DESC ... " do_start case "$?" in 0|1) echo $NAME ;; 2) echo "$NAME did not start" ;; esac ;; stop) echo -n "Stopping $DESC ... " do_stop if [ $? -eq 0 ] then echo "stopped" else echo "could NOT stop process!" fi ;; restart|force-reload) echo -n "Restarting $DESC ... " do_stop sleep 1 do_start echo "done" ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac