#!/bin/sh # # xymon init.d script. # #----------------------------------------------------------------------------# # This invokes xymonlaunch, which in turn starts all of the other Xymon # # server programs. # # # # Copyright (C) 2005-2011 Henrik Storner # # # # Integration of xymon.sh and xymon-init.d by Japheth Cleaver 2011 # # Rewrote init script for ALT Linux by Sergey Y. Afonin 2013 # # # # This program is released under the GNU General Public License (GPL), # # version 2. See the file "COPYING" for details. # # # #----------------------------------------------------------------------------# # # chkconfig: - 80 20 # description: Xymon is a network monitoring tool that can monitor hosts \ # and services and shows monitor status via a webpage. # # processname: xymonlaunch # pidfile: @XYMONRUNDIR@/xymonlaunch.pid # config: @XYMONTOPDIR@/client/etc/xymonclient.cfg # config: @XYMONTOPDIR@/server/etc/tasks.cfg autoreload # config: @XYMONTOPDIR@/server/etc/xymonserver.cfg # ### BEGIN INIT INFO # Provides: xymon xymond # Default-Start: # Default-Stop: 0 1 2 3 4 5 6 # Required-Start: $local_fs $network # Required-Stop: $local_fs $network # Short-Description: start and stop xymon # Description: Xymon is a network monitoring tool that can monitor hosts # and services and shows monitor status via a webpage. ### END INIT INFO # Do not load RH compatibility interface. WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions USER=@XYMONUSER@ DAEMON=xymonlaunch RUNPATH=/usr/lib/xymon LOCKFILE=/var/lock/subsys/$DAEMON XYMONHOME="@XYMONTOPDIR@/server" RETVAL=0 # Default settings for this client MACHINEDOTS="`uname -n`" # This system's hostname SERVEROSTYPE="`uname -s | tr '[A-Z/]' '[a-z_]'`" # This system's operating system in lowercase CONFIGCLASS="" # This system's config class # Source config files . /etc/sysconfig/xymon-client . /etc/sysconfig/xymon # Check for overrides from /etc/sysconfig/xymon-config [ -n "$CLIENTHOSTNAME" ] && MACHINEDOTS="$CLIENTHOSTNAME" [ -n "$CLIENTOS" ] && SERVEROSTYPE="$CLIENTOS" [ -n "$CLIENTCLASS" ] && CONFIGCLASS="$CLIENTCLASS" MACHINE="`echo $MACHINEDOTS | sed -e 's/\./,/g'`" XYMONOSSCRIPT="xymonclient-${SERVEROSTYPE}.sh" XYMONLAUNCHOPTS="$XYMONLAUNCHOPTS" export MACHINE MACHINEDOTS SERVEROSTYPE XYMONOSSCRIPT XYMONLAUNCHOPTS XYMONHOME CONFIGCLASS # Values used in the remainder of the initscript envfile="@XYMONTOPDIR@/server/etc/xymonserver.cfg" configfile="@XYMONTOPDIR@/server/etc/tasks.cfg" logfile="@XYMONLOGDIR@/xymonlaunch.log" pidfile="@XYMONRUNDIR@/xymonlaunch.pid" # Check to make sure our pidfile's directory exists rundir="`dirname $pidfile`" [ -d "$rundir" ] || install -d -o "$user" -g "$user" "$rundir" || exit 1 start() { start_daemon --pidfile "$pidfile" --lockfile "$LOCKFILE" --expect-user $USER --user $USER -- $RUNPATH/$DAEMON \ $XYMONLAUNCHOPTS --env=$envfile --config=$configfile --log=$logfile --pidfile=$pidfile RETVAL=$? return $RETVAL } stop() { stop_daemon --pidfile "$pidfile" --lockfile "$LOCKFILE" --expect-user $USER -- $RUNPATH/$DAEMON RETVAL=$? return $RETVAL } restart() { stop start } reload() { msg_reloading $DAEMON stop_daemon --pidfile "$pidfile" --expect-user $USER -HUP -- $RUNPATH/$DAEMON RETVAL=$? return $RETVAL } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) restart ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; condrestart) if [ -e "$LOCKFILE" ]; then restart fi ;; condreload) if [ -e "$LOCKFILE" ]; then reload fi ;; status) status --pidfile "$pidfile" --expect-user $USER -- $RUNPATH/$DAEMON RETVAL=$? ;; rotate) cat $rundir/*.pid 2>/dev/null | xargs -r kill -HUP ;; *) msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status|rotate}" RETVAL=1 esac exit $RETVAL