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