PageRenderTime 46ms CodeModel.GetById 35ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/ss7/sgw/boot/src/main/config/run.sh

http://mobicents.googlecode.com/
Shell | 174 lines | 112 code | 28 blank | 34 comment | 19 complexity | 573c11ef4b005909c5226a4af7714cf9 MD5 | raw file
  1#!/bin/sh
  2### ====================================================================== ###
  3##                                                                          ##
  4##  Mobicents Media Server Bootstrap Script                                 ##
  5##                                                                          ##
  6### ====================================================================== ###
  7
  8### $Id: run.sh abhayani@redhat.com $ ###
  9
 10DIRNAME=`dirname $0`
 11PROGNAME=`basename $0`
 12GREP="grep"
 13
 14# Use the maximum available, or set MAX_FD != -1 to use that
 15MAX_FD="maximum"
 16
 17#
 18# Helper to complain.
 19#
 20warn() {
 21    echo "${PROGNAME}: $*"
 22}
 23
 24#
 25# Helper to puke.
 26#
 27die() {
 28    warn $*
 29    exit 1
 30}
 31
 32# OS specific support (must be 'true' or 'false').
 33cygwin=false;
 34darwin=false;
 35linux=false;
 36case "`uname`" in
 37    CYGWIN*)
 38        cygwin=true
 39        ;;
 40
 41    Darwin*)
 42        darwin=true
 43        ;;
 44        
 45    Linux)
 46        linux=true
 47        ;;
 48esac
 49
 50
 51# Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower
 52if [ "$linux" = "true" ]; then
 53   JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true"
 54fi
 55
 56# For Cygwin, ensure paths are in UNIX format before anything is touched
 57if $cygwin ; then
 58    [ -n "$SGW_HOME" ] &&
 59        SGW_HOME=`cygpath --unix "$SGW_HOME"`
 60    [ -n "$JAVA_HOME" ] &&
 61        JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
 62    [ -n "$JAVAC_JAR" ] &&
 63        JAVAC_JAR=`cygpath --unix "$JAVAC_JAR"`
 64fi
 65
 66# Setup SGW_HOME
 67if [ "x$SGW_HOME" = "x" ]; then
 68    # get the full path (without any relative bits)
 69    SGW_HOME=`cd $DIRNAME/..; pwd`
 70fi
 71export SGW_HOME
 72
 73# Increase the maximum file descriptors if we can
 74if [ "$cygwin" = "false" ]; then
 75    MAX_FD_LIMIT=`ulimit -H -n`
 76    if [ $? -eq 0 ]; then
 77	if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
 78	    # use the system max
 79	    MAX_FD="$MAX_FD_LIMIT"
 80	fi
 81
 82	ulimit -n $MAX_FD
 83	if [ $? -ne 0 ]; then
 84	    warn "Could not set maximum file descriptor limit: $MAX_FD"
 85	fi
 86    else
 87	warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
 88    fi
 89fi
 90
 91# Setup the JVM
 92if [ "x$JAVA" = "x" ]; then
 93    if [ "x$JAVA_HOME" != "x" ]; then
 94	JAVA="$JAVA_HOME/bin/java"
 95    else
 96	JAVA="java"
 97    fi
 98fi
 99
100# Setup the classpath
101runjar="$SGW_HOME/bin/run.jar"
102if [ ! -f "$runjar" ]; then
103    die "Missing required file: $runjar"
104fi
105
106SGW_BOOT_CLASSPATH="$runjar"
107
108if [ "x$SGW_CLASSPATH" = "x" ]; then
109    SGW_CLASSPATH="$SGW_BOOT_CLASSPATH"
110else
111    SGW_CLASSPATH="$SGW_CLASSPATH:$SGW_BOOT_CLASSPATH"
112fi
113
114
115# If -server not set in JAVA_OPTS, set it, if supported
116SERVER_SET=`echo $JAVA_OPTS | $GREP "\-server"`
117if [ "x$SERVER_SET" = "x" ]; then
118
119    # Check for SUN(tm) JVM w/ HotSpot support
120    if [ "x$HAS_HOTSPOT" = "x" ]; then
121	HAS_HOTSPOT=`"$JAVA" -version 2>&1 | $GREP -i HotSpot`
122    fi
123
124    # Enable -server if we have Hotspot, unless we can't
125    if [ "x$HAS_HOTSPOT" != "x" ]; then
126	# MacOS does not support -server flag
127	if [ "$darwin" != "true" ]; then
128	    JAVA_OPTS="-server $JAVA_OPTS"
129	fi
130     fi
131fi
132
133# Setup MMS specific properties
134JAVA_OPTS="-Dprogram.name=$PROGNAME $JAVA_OPTS"
135JAVA_OPTS="$JAVA_OPTS -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
136#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
137# Setup the java endorsed dirs
138SGW_ENDORSED_DIRS="$SGW_HOME/lib"
139
140# Setup path for native libs
141LD_LIBRARY_PATH="$SGW_HOME/native"
142export LD_LIBRARY_PATH
143
144# For Cygwin, switch paths to Windows format before running java
145if $cygwin; then
146    SGW_HOME=`cygpath --path --windows "$SGW_HOME"`
147    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
148    SGW_CLASSPATH=`cygpath --path --windows "$SGW_CLASSPATH"`
149    SGW_ENDORSED_DIRS=`cygpath --path --windows "$SGW_ENDORSED_DIRS"`
150fi
151
152# Display our environment
153echo "========================================================================="
154echo ""
155echo "  MMS Bootstrap Environment"
156echo ""
157echo "  SGW_HOME: $SGW_HOME"
158echo ""
159echo "  JAVA: $JAVA"
160echo ""
161echo "  JAVA_OPTS: $JAVA_OPTS"
162echo ""
163echo "  CLASSPATH: $SGW_CLASSPATH"
164echo ""
165echo "========================================================================="
166echo ""
167
168      "$JAVA" $JAVA_OPTS \
169         -Djava.ext.dirs="$SGW_ENDORSED_DIRS" \
170         -classpath "$SGW_CLASSPATH" \
171         org.mobicents.ss7.sgw.boot.Main "$@"
172      SGW_STATUS=$?
173
174#java -Djava.ext.dirs=`pwd`/lib -Dmms.home=. -cp .:mms-standalone-2.0.0.BETA1-SNAPSHOT.jar org.mobicents.media.server.bootstrap.jmx.JMXMain