#!/sbin/runscript # Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 NX_NODE_CFG="/usr/NX/etc/node.cfg" NX_SENSOR_CMD="/usr/NX/bin/nxsensor" NX_SENSOR_PID="/usr/NX/var/run/nxsensor.pid" NX_SENSOR_HOST="127.0.0.1" NX_SENSOR_PORT="19250" depend() { need net } is_enabled() { local tmp if ! [[ -x $NX_SENSOR_CMD ]] ; then eerror "$NX_SENSOR_CMD not found" return 1 fi tmp=`/usr/bin/awk -F'"' '/^EnableSensor/ {print $2}' $NX_NODE_CFG` if [[ $tmp != "1" ]]; then eerror "nxsensor is disabled in $NX_NODE_CFG" return 1 fi tmp=`/usr/bin/awk -F'"' '/^StatisticsHost/ {print $2}' $NX_NODE_CFG` if [[ -n $tmp ]] ; then NX_SENSOR_HOST="$tmp" fi tmp=`/usr/bin/awk -F'"' '/^NodeSensorPort/ {print $2}' $NX_NODE_CFG` if [[ -n $tmp ]] ; then NX_SENSOR_PORT="$tmp" fi return 0 } start() { is_enabled || return 1 ebegin "Starting nxsensor" $NX_SENSOR_CMD -a $NX_SENSOR_HOST -a "::ffff:$NX_SENSOR_HOST" -P $NX_SENSOR_PORT -d PID=`ps -ef | grep $NX_SENSOR_CMD | grep -v grep | awk '{print $2}'` if [[ -z $PID ]] ; then eend 1 else echo $PID > $NX_SENSOR_PID eend 0 fi } stop() { ebegin "Stopping nxsensor" PID=`cat $NX_SENSOR_PID` if [[ -z $PID ]] ; then eerror "nxsensor not started" eend 1 else kill $PID rm -f $NX_SENSOR_PID eend 0 fi }