first version of startup script
authorAleš Křenek <ljocha@ics.muni.cz>
Thu, 19 Aug 2004 13:20:51 +0000 (13:20 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Thu, 19 Aug 2004 13:20:51 +0000 (13:20 +0000)
org.glite.lb.server/Makefile
org.glite.lb.server/config/startup [new file with mode: 0755]

index 9d89820..a1313fa 100644 (file)
@@ -112,13 +112,15 @@ distbin:
        rm -rf tmpbuilddir
         
 install:
-       mkdir -p ${PREFIX}/bin ${PREFIX}/etc
+       -mkdir -p ${PREFIX}/bin ${PREFIX}/etc ${PREFIX}/etc/init.d
        for p in bkserverd bkindex; do \
                ${INSTALL} -m 755 "glite_lb_$$p" "${PREFIX}/bin/glite-lb-$$p"; \
        done
 
        for f in dbsetup.sql index.conf.template; do \
-               ${INSTALL} -m 644 "glite-lb-$$p" ${PREFIX}/etc
+               ${INSTALL} -m 644 ${top_srcdir}/config/"glite-lb-$$p" ${PREFIX}/etc
+
+       ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-bkserverd
 
 clean:
 
diff --git a/org.glite.lb.server/config/startup b/org.glite.lb.server/config/startup
new file mode 100755 (executable)
index 0000000..8e26908
--- /dev/null
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+GLITE_LOCATION=/opt/glite
+GLITE_USER=glite
+GLITE_LOCATION_VAR=/opt/glite/var
+
+[ -f /etc/glite.conf ] && . /etc/glite.conf
+[ -f $HOME/.glite.conf ] && . $HOME/.glite.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
+
+[ -n "$GLITE_LB_SERVER_PIDFILE" ] && pidfile=$GLITE_LB_SERVER_PIDFILE ||
+       pidfile=$GLITE_LOCATION_VAR/glite_lb_bkserverd.pid
+
+start()
+{
+       [ -n "$GLITE_HOST_CERT" -a -n "$GLITE_HOST_KEY" ] &&
+               creds="-c $GLITE_HOST_CERT -k $GLITE_HOST_KEY"
+
+       [ -z "$creds" ] && echo $0: WARNING: No credentials specified. Using default lookup which is dangerous. >&2
+
+       [ -n "$GLITE_LB_SERVER_PORT" ] && port="-p $GLITE_LB_SERVER_PORT"
+
+       echo -n Starting glite_lb_bkserver ...
+       su $GLITE_USER -c "$GLITE_LOCATION/bin/glite_lb_bkserverd \
+               $creds -i $pidfile" && echo " done"
+}
+
+stop()
+{
+       if [ -f $pidfile ]; then
+               pid=`cat $pidfile`
+               kill $pid
+               echo -n Stopping glite_lb_bkserverd \($pid\) ...
+               try=0
+               while ps p $pid >/dev/null 2>&1; do 
+                       sleep 1;
+                       try=`expr $try + 1`
+                       if [ $try = 20 ]; then
+                               echo " giving up after $try retries"
+                               return 1
+                       fi
+               done
+               echo " done"
+               rm -f $pidfile
+       else
+               echo $pidfile does not exist - glite_lb_bkserverd not running? >&2
+               return 1
+       fi
+}
+
+status()
+{
+       if [ -f $pidfile ]; then
+               pid=`cat $pidfile`
+               if ps p $pid >/dev/null 2>&1; then
+                       echo glite_lb_bkserverd running as $pid 
+                       return 0
+               fi
+       fi
+
+       echo glite_lb_bkserverd not running
+       return 1
+}
+
+case x$1 in
+       xstart) start;;
+       xstop)  stop;;
+       xrestart) stop; start;;
+       xstatus) status;;
+       x*)     echo usage: $0 start,stop,restart,status >&2
+               exit 1;;
+esac