#!/sbin/runscript # Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # opts="${opts} reload configtest" 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'"' '/^ENABLE_SENSOR/ {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'"' '/^NODE_SENSOR_HOST/ {print $2}' $NX_NODE_CFG` if [[ -n $tmp ]] ; then NX_SENSOR_HOST="$tmp" fi tmp=`/usr/bin/awk -F'"' '/^NODE_SENSOR_PORT/ {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 }