#! /bin/sh /usr/share/dpatch/dpatch-run ## 01_javapathfix.dpatch by ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Creates new function to fix paths to sun java command @DPATCH@ diff -urNad ourgrid~/bin/corepeer ourgrid/bin/corepeer --- ourgrid~/bin/corepeer 2006-12-27 14:49:24.000000000 -0300 +++ ourgrid/bin/corepeer 2006-12-27 15:07:14.000000000 -0300 @@ -22,6 +22,7 @@ ERR_BASE=64 ERR_MGROOT_NOT_DEFINED=$[ERR_BASE + 0] ERR_VARS_NOT_DEFINED=$[ERR_BASE + 1] +ERR_JAVA_NOT_FOUND=$[ERR_BASE + 2] # # Usage function to show how to use corepeer. @@ -107,26 +108,38 @@ JAVAOPTIONS=" -classpath $CLASSPATH -DMGROOT=$MGROOT -Dsun.net.inetaddr.ttl=0" } +# Set the JAVA_CMD to call the Java Virtual Machine +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +setjavacmd(){ + JAVA_CMD=/usr/lib/jvm/java-1.5.0-sun/bin/java + if [ -z "$JAVA_CMD" ]; then + echo "ERR_JAVA_NOT_FOUND" + return $ERR_JAVA_NOT_FOUND + else + return $OK + fi +} + # +++++ Start CorePeer start() { - java $JAVAOPTIONS $main start & + $JAVA_CMD $JAVAOPTIONS $main start & sleep 3 } stop() { - java $JAVAOPTIONS $main stop & + $JAVA_CMD $JAVAOPTIONS $main stop & sleep 3 } status() { - java $JAVAOPTIONS $main status + $JAVA_CMD $JAVAOPTIONS $main status exit $? } main="org.ourgrid.corepeer.ui.CommandManager" # Check -findmgroot && setenvvars && setclasspath && setjavaoptions +findmgroot && setenvvars && setclasspath && setjavaoptions && setjavacmd case "$1" in start) diff -urNad ourgrid~/bin/mygrid ourgrid/bin/mygrid --- ourgrid~/bin/mygrid 2006-12-27 14:49:24.000000000 -0300 +++ ourgrid/bin/mygrid 2006-12-27 15:08:34.000000000 -0300 @@ -91,6 +91,18 @@ fi } +# Set the JAVA_CMD to call the Java Virtual Machine +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +setjavacmd(){ + JAVA_CMD=/usr/lib/jvm/java-1.5.0-sun/bin/java + if [ -z "$JAVA_CMD" ]; then + echo "ERR_JAVA_NOT_FOUND" + return $ERR_JAVA_NOT_FOUND + else + return $OK + fi +} + # Set the $VAR $BIN and $LIB # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - setenvvars(){ @@ -106,30 +118,30 @@ } checkenvironment() { - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$checkconfenv" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$checkconfenv" } start() { - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" -reg "$checkconfenv" - java -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$startcommand" & + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" -reg "$checkconfenv" + $JAVA_CMD -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$startcommand" & sleep 3 } # +++++ MyGrid Config config() { - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" -reg "$checkconfenv" --mgproperties + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" -reg "$checkconfenv" --mgproperties } # +++++ Stop MyGrid stop() { - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$stopcommand" "$COMMAND_ARGS" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$stopcommand" "$COMMAND_ARGS" } status() { - java -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$statuscommand" "$COMMAND_ARGS" "$COMMAND_ARGS2" "$COMMAND_ARGS3" + $JAVA_CMD -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$statuscommand" "$COMMAND_ARGS" "$COMMAND_ARGS2" "$COMMAND_ARGS3" exit $? } @@ -322,7 +334,7 @@ # Some Checkings -findmgroot && setenvvars && setclasspath && setjavaoptions +findmgroot && setenvvars && setclasspath && setjavaoptions && setjavacmd ret=$? @@ -354,31 +366,31 @@ ;; addjob) - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$addjobcommand" "$COMMAND_ARGS" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$addjobcommand" "$COMMAND_ARGS" ;; canceljob) - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$canceljobcommand" "$COMMAND_ARGS" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$canceljobcommand" "$COMMAND_ARGS" ;; waitforjob) - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$waitforjobcommand" "$COMMAND_ARGS" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$waitforjobcommand" "$COMMAND_ARGS" ;; setgrid) - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$setgridcommand" "$COMMAND_ARGS" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$setgridcommand" "$COMMAND_ARGS" ;; gui) echo "Starting MyGrid GUI" - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" -reg "$gui" "$COMMAND_ARGS" & + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" -reg "$gui" "$COMMAND_ARGS" & ;; clean) if [ $nargs -eq 1 ]; then - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$cleancommand" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$cleancommand" else - java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$cleancommand" "$COMMAND_ARGS" + $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$cleancommand" "$COMMAND_ARGS" fi ;; *) usage diff -urNad ourgrid~/bin/peer ourgrid/bin/peer --- ourgrid~/bin/peer 2006-12-27 14:49:24.000000000 -0300 +++ ourgrid/bin/peer 2006-12-27 15:06:36.000000000 -0300 @@ -110,6 +110,18 @@ fi } +# Set the JAVA_CMD to call the Java Virtual Machine +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +setjavacmd(){ + JAVA_CMD=/usr/lib/jvm/java-1.5.0-sun/bin/java + if [ -z "$JAVA_CMD" ]; then + echo "ERR_JAVA_NOT_FOUND" + return $ERR_JAVA_NOT_FOUND + else + return $OK + fi +} + # Start OurGrid Peer # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - pre_peer() { @@ -128,28 +140,28 @@ ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #gui() { # pre_peer -# java -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$guicommand" & +# $JAVA_CMD -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$guicommand" & #} # Starts OurGrid Peer # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - start() { pre_peer - java -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$startcommand" & + $JAVA_CMD -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$startcommand" & sleep 3 } # Stop OurGrid Peer # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - stop() { - java -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$stopcommand" + $JAVA_CMD -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$stopcommand" } # Show OurGrid Peer Status # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - status() { - java -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$statuscommand" + $JAVA_CMD -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$statuscommand" exit $? } @@ -264,7 +276,7 @@ mgname=`basename $0` # Check -findmgroot && setenvvars && setclasspath && setjavaoptions +findmgroot && setenvvars && setclasspath && setjavaoptions && setjavacmd ret=$? @@ -288,7 +300,7 @@ # exit $? # ;; setgums) - java -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$setgumscommand" "$COMMAND_ARGS" + $JAVA_CMD -Xms64m -Xmx1024m -classpath "$CLASSPATH" "$JAVAOPTIONS" "$commandmanager" "$setgumscommand" "$COMMAND_ARGS" ;; *) usage exit $ret diff -urNad ourgrid~/bin/startWebStatus ourgrid/bin/startWebStatus --- ourgrid~/bin/startWebStatus 2006-12-27 14:49:24.000000000 -0300 +++ ourgrid/bin/startWebStatus 2006-12-27 15:08:32.000000000 -0300 @@ -1 +1,28 @@ -java -cp .:../lib/log4j.jar:../lib/ourgrid.jar -Dcorepeer.url= -Dcorepeer.port= -Dwebstatus.port= -Dsun.net.inetaddr.ttl=0 org.ourgrid.webstatus.WebStatusImpl > thread.log.$$ & +#!/bin/bash +# Setting macros +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +OK=0 +NOK=1 + +# Setting error codes (from 2 to 254) +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ERR_STD_MISUSE=2 + +ERR_BASE=64 +ERR_JAVA_NOT_FOUND=$[ERR_BASE + 0] + +# Set the JAVA_CMD to call the Java Virtual Machine +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +setjavacmd(){ + JAVA_CMD=/usr/lib/jvm/java-1.5.0-sun/bin/java + if [ -z "$JAVA_CMD" ]; then + echo "ERR_JAVA_NOT_FOUND" + return $ERR_JAVA_NOT_FOUND + else + return $OK + fi +} +# ---- Main ---- # +setjavacmd +# TODO:fix the wrong classpaths below ... +$JAVA_CMD -cp .:../lib/log4j.jar:../lib/ourgrid.jar -Dcorepeer.url= -Dcorepeer.port= -Dwebstatus.port= -Dsun.net.inetaddr.ttl=0 org.ourgrid.webstatus.WebStatusImpl > thread.log.$$ & diff -urNad ourgrid~/bin/uaadmin ourgrid/bin/uaadmin --- ourgrid~/bin/uaadmin 2006-12-27 14:49:24.000000000 -0300 +++ ourgrid/bin/uaadmin 2006-12-27 15:08:33.000000000 -0300 @@ -10,10 +10,6 @@ # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#!/bin/sh - # Find MGROOT: # $0 is the executable $MGROOT/bin/mygrid or a link to it # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -81,7 +77,19 @@ return $OK fi } - + +# Set the JAVA_CMD to call the Java Virtual Machine +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +setjavacmd(){ + JAVA_CMD=/usr/lib/jvm/java-1.5.0-sun/bin/java + if [ -z "$JAVA_CMD" ]; then + echo "ERR_JAVA_NOT_FOUND" + return $ERR_JAVA_NOT_FOUND + else + return $OK + fi +} + # Set the JAVAOPTION to invoke OurGrid classes # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - setjavaoptions(){ @@ -113,31 +121,31 @@ # Tries to start all User Agents from the specified SDF start() { - java -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname start "$1" + $JAVA_CMD -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname start "$1" sleep 2 } # Tries to stop all User Agents from the specified SDF stop() { - java -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname stop "$1" + $JAVA_CMD -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname stop "$1" sleep 2 } restart() { - java -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname restart "$1" + $JAVA_CMD -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname restart "$1" sleep 2 } # Tests all User Agents from the specified SDF status() { - java -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname status "$1" + $JAVA_CMD -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname status "$1" sleep 2 } # Tries to clean the environment deleting the temporary files clean() { - java -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname clean "$1" + $JAVA_CMD -DMGROOT="$MGROOT" -cp "$CLASSPATH" $deployerclassname clean "$1" sleep 2 } @@ -184,7 +192,7 @@ SDF=$2 if [ "$COMMAND_NAME" = "init" ] || [ "$COMMAND_NAME" = "start" ] || [ "$COMMAND_NAME" = "stop" ] || [ "$COMMAND_NAME" = "shutdown" ] || [ "$COMMAND_NAME" = "test" ] || [ "$COMMAND_NAME" = "status" ] || [ "$COMMAND_NAME" = "restart" ] || [ "$COMMAND_NAME" = "clean" ] then - findmgroot && setenvvars && setclasspath + findmgroot && setenvvars && setclasspath && setjavacmd ret=$? else usage