「Linux勉強」shellスクリプト起動サンプルコード

サンプルコード:
#!/bin/bash
export JAVA_HOME=/usr/java
export PATH=$JAVA_HOME/bin:$PATH

#——————————————————————-
# Mb Bootstrap Script
#——————————————————————-
function main()
{
# find Mb home.
CURR_DIR=pwd
cd dirname "$0"/..
RESV_HOME=pwd
cd $CURR_DIR

if [ -z “$RESV_HOME” ] ; then
echo
echo Must set RESV_HOME
echo
exit 1
fi

pc=ps -ef | grep "ThreadMore $1" | wc -l
echo “process count:$pc”
if [[ $pc -gt 1 ]];
then
echo “last job havent finish,exit.”
exit 1
fi

execute $1 $2
}

function execute()
{
for i in $RESV_HOME/lib/*.jar; do
CLASSPATH=$i:$CLASSPATH;
done

#echo RESV_HOME=$RESV_HOME

CLASSPATH=$RESV_HOME/conf:$RESV_HOME/smack.jar:$CLASSPATH

DEBUG_INFO=” -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n”
DEBUG=””
if [ “$1” = “load” ]
then
MAIN_CLASS=”www.smack.ThreadLocal $1″;
DEFAULT_OPTS=”-server -Xms10G -Xmx10G ” ;
else
if [ “$1” = “check” ]
then
MAIN_CLASS=”www.smack.ThreadLocal “;
DEFAULT_OPTS=”-server -Xms2G -Xmx2G” ;
else
MAIN_CLASS=”www.smack.ThreadLocal $1 $2″;
DEFAULT_OPTS=”-server -Xms2000m -Xmx2000m -Xss128k” ;
fi
fi
DEFAULT_OPTS=”$DEFAULT_OPTS -Djava.awt.headless=true -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=10.10.10.7″
DEFAULT_OPTS=”$DEFAULT_OPTS -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=60″
DEFAULT_OPTS=”$DEFAULT_OPTS -DMB.home=\”$RESV_HOME\””

echo java $DEBUG $DEFAULT_OPTS -classpath $CLASSPATH $MAIN_CLASS
java $DEBUG $DEFAULT_OPTS -classpath $CLASSPATH $MAIN_CLASS
}

main “4000” “40”