endif
-include Makefile.inc
--include ../project/version.properties
+-include ${top_srcdir}/project/version.properties
version:=${module.version}
CC=gcc
$(MAKE) install PREFIX=${stagedir}
install: compile
- -mkdir -p ${PREFIX}/bin ${PREFIX}/examples ${PREFIX}/share/doc/${package}-${version} ${PREFIX}/share/man/man8
+ -mkdir -p ${PREFIX}/bin ${PREFIX}/examples ${PREFIX}/share/doc/${package}-${version} ${PREFIX}/share/man/man8 ${PREFIX}/etc/init.d
${INSTALL} -m 755 harvester ${PREFIX}/bin/glite-lb-harvester
${INSTALL} -m 755 harvester-dbg ${PREFIX}/examples/glite-lb-harvester-dbg
- ${INSTALL} -m 755 ../examples/test.sh ${PREFIX}/examples/glite-lb-harvester-test.sh
- ${INSTALL} -m 444 ../doc/README ${PREFIX}/share/doc/${package}-${version}
+ ${INSTALL} -m 755 ${top_srcdir}/examples/test.sh ${PREFIX}/examples/glite-lb-harvester-test.sh
+ ${INSTALL} -m 444 ${top_srcdir}/doc/README ${PREFIX}/share/doc/${package}-${version}
${INSTALL} -m 444 glite-lb-harvester.8 ${PREFIX}/share/man/man8
+ ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-harvester
clean:
rm -rfv *.o *.lo *.loT .libs/ manpage.links manpage.refs
--- /dev/null
+#!/bin/sh
+# chkconfig: 345 75 25
+#
+# Copyright (c) Members of the EGEE Collaboration. 2004-2010.
+# See http://www.eu-egee.org/partners/ for details on the copyright holders.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+GLITE_LOCATION=${GLITE_LOCATION:-/opt/glite}
+GLITE_LOCATION_VAR=${GLITE_LOCATION_VAR:-/var/glite}
+
+[ -f /etc/glite.conf ] && . /etc/glite.conf
+[ -f $GLITE_LOCATION/etc/glite-wms.conf ] && . $GLITE_LOCATION/etc/glite-wms.conf
+
+[ -f $GLITE_LOCATION/etc/lb.conf ] && . $GLITE_LOCATION/etc/lb.conf
+[ -f $GLITE_LOCATION_VAR/etc/lb.conf ] && . $GLITE_LOCATION_VAR/etc/lb.conf
+
+[ -f $HOME/.glite.conf ] && . $HOME/.glite.conf
+
+pidfile=${GLITE_LB_HARVESTER_PIDFILE:-"$GLITE_LOCATION_VAR/glite-lb-harvester.pid"}
+level=${GLITE_LB_HARVESTER_DEBUG_LEVEL:-"1"}
+
+# database or configuration file needed
+# (using the file as default)
+etc=$GLITE_LOCATION/etc/glite-lb
+[ -z "$GLITE_LB_HARVESTER_DBCS" -a -z "$GLITE_LB_HARVESTER_CONFIG" ] && GLITE_LB_HARVESTER_CONFIG=$etc/harvester.conf
+if [ -n "$GLITE_LB_HARVESTER_CONFIG" ]; then
+ [ ! -d "$etc" ] && mkdir -p "$etc"
+ conf="$conf -c $GLITE_LB_HARVESTER_CONFIG"
+ if [ ! -f "$GLITE_LB_HARVESTER_CONFIG" ]; then
+ hostname -f > $GLITE_LB_HARVESTER_CONFIG
+ fi
+fi
+[ -n "$GLITE_LB_HARVESTER_DBCS" ] && conf="$conf -m $GLITE_LB_HARVESTER_DBCS"
+
+unset creds port log4c
+
+[ -n "$GLITE_HOST_CERT" -a -n "$GLITE_HOST_KEY" ] &&
+ creds="-C $GLITE_HOST_CERT -K $GLITE_HOST_KEY"
+
+if test -z "$creds"; then
+ if su - $GLITE_USER -c "test -r /etc/grid-security/hostkey.pem -a -r /etc/grid-security/hostcert.pem"; then
+ echo "$0: WARNING: /etc/grid-security/hostkey.pem readable by $GLITE_USER"
+ creds="-C /etc/grid-security/hostcert.pem -K /etc/grid-security/hostkey.pem"
+ fi
+fi
+
+start_daemon()
+{
+ local name="$1"
+ local pidfile="$2"
+ local cmd="$3"
+
+ if [ -f "$pidfile" ]; then
+ if kill -0 `cat $pidfile`; then
+ return 0
+ fi
+ echo -n "Warning: stalled $pidfile for $name"
+ rm -f "$pidfile"
+ fi
+ echo -n "Starting $name ..."
+ su - $GLITE_USER -c "$log4c $cmd" && echo " done" || echo " FAILED"
+}
+
+stop_daemon()
+{
+ name="$1"
+ local pidfile="$2"
+
+ if [ -f "$pidfile" ]; then
+ pid=`cat "$pidfile"`
+ echo -n Stopping $name \($pid\) ...
+ kill $pid
+ try=0
+ while kill -0 $pid >/dev/null 2>&1; do
+ sleep 1;
+ try=`expr $try + 1`
+ if [ $try = 20 ]; then
+ kill -9 $pid
+ echo " force quit after $try retries"
+ return 1
+ fi
+ done
+ echo " done"
+ rm -f $pidfile
+ else
+ echo $name not running
+ return 1
+ fi
+}
+
+status_daemon()
+{
+ local name="$1"
+ local pidfile="$2"
+ local enabled="$3"
+
+ if [ -f "$pidfile" ]; then
+ pid=`cat "$pidfile"`
+ if kill -0 $pid >/dev/null 2>&1; then
+ echo "$name running as $pid"
+ else
+ echo "$name not running (stalled pidfile)"
+ return 1
+ fi
+ else
+ if test -n "$enabled" -a x"$enabled" = x"0"; then
+ echo "$name not running (disabled)"
+ return 0
+ else
+ echo "$name not running"
+ return 1
+ fi
+ fi
+
+ return 0
+}
+
+start()
+{
+ if test -z "$GLITE_USER" ;then
+ echo 'Error: GLITE_USER is not set'
+ echo FAILED
+ return 1
+ fi
+
+ log4c="LOG4C_RCPATH='$GLITE_LOCATION/etc/glite-lb'"
+
+ [ -z "$creds" ] && echo $0: WARNING: No credentials specified. Using default lookup which is dangerous. >&2
+
+ [ -n "$GLITE_LB_HARVESTER_PORT" ] && port="-p $GLITE_LB_HARVESTER_PORT"
+
+ start_daemon glite-lb-harvester "$pidfile" "$GLITE_LOCATION/bin/glite-lb-harvester \
+ $creds $conf -i $pidfile -d $level $port --daemon\
+ $GLITE_LB_HARVESTER_OTHER_OPTIONS"
+}
+
+stop()
+{
+ stop_daemon "glite-lb-harvester" $pidfile
+}
+
+status()
+{
+ retval=0
+ status_daemon "glite-lb-harvester" "$pidfile" || retval=1
+
+ return $retval
+}
+
+cleanup()
+{
+ stop | grep -v 'glite-lb-harvester not running'
+ echo -n "Cleaning up notifications ..."
+ $log4c glite-lb-harvester --cleanup $creds $conf -d $level $GLITE_LB_HARVESTER_OTHER_OPTIONS
+ if [ $? = 0 ]; then
+ echo " done"
+ else
+ echo " FAILED"
+ return 1
+ fi
+}
+
+case x$1 in
+ xstart) start;;
+ xstop) stop;;
+ xrestart) stop; start;;
+ xstatus) status;;
+ xcleanup) cleanup;;
+ x*) echo usage: $0 start,stop,restart,status,cleanup >&2
+ exit 1;;
+esac