SHARE
TWEET

ColdFusion9_StartScript_Fix_For_Builder_on_Mac

a guest Apr 1st, 2010 811 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # chkconfig: 345 90 14
  4. # description: starts the ColdFusion MX server
  5.  
  6.  
  7. PATH=/usr/xpg4/bin:/bin:/sbin:/usr/bin:/usr/sbin:$PATH
  8. CONNECTOR=""
  9. RUNTIME_USER="QA"
  10. JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"
  11. JAVA_EXECUTABLE="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java"
  12. DOCROOT="/opt/ColdFusion9/wwwroot"
  13. CF_DIR="/opt/ColdFusion9"
  14. JRUN_BIN="${CF_DIR}/runtime/bin"
  15. IS_RUNNING="false"
  16. IS_MAC="false"
  17.  
  18. ID=`id -u`
  19.  
  20. if [ "`uname`" = "Darwin" ]; then
  21.   # nothing, on OSX we don't care about the user name.  We assume that the user running it has permission to do everything
  22.   IS_MAC="true"
  23. elif [ ! $ID -eq 0 ]; then
  24.         echo "You must be root to start ColdFusion ."
  25.         exit 1
  26. fi
  27.  
  28. cfrunning() {
  29.     IS_RUNNING="false"
  30.     if [ $OS = "Solaris" ]; then
  31.         # The comm output on Solaris includes the full path
  32.         ps -eo comm | xargs -n 1 basename | fgrep coldfusion9 > /dev/null 2>&1
  33.     else
  34.         # other platforms have only the executable name
  35.         # $PSCMD | fgrep coldfusion9  > /dev/null 2>&1
  36.         $PSCMD | grep -i $JRUN_BIN | grep -v 'grep' > /dev/null 2>&1
  37.     fi
  38.     if [ $? -eq 0 ]; then
  39.         IS_RUNNING="true"
  40.     fi
  41. }
  42.  
  43.  
  44. cfstart() {
  45.  
  46.         [ -f $CF_DIR/bin/jvm.config ] || {
  47.                 ln -s $CF_DIR/runtime/bin/jvm.config $CF_DIR/bin/jvm.config
  48.         }
  49.  
  50.     cfrunning
  51.    
  52.     if [ "$IS_RUNNING" = "true" ]; then
  53.                 echo "ColdFusion 9 is already running"
  54.                 echo exiting
  55.                 exit 2    
  56.     fi
  57.  
  58.  
  59.         echo "Starting ColdFusion 9..."
  60.  
  61.         eval $CFSTART >> $CF_DIR/logs/cfserver.log 2>&1
  62.  
  63.         echo "The ColdFusion 9 server is starting up and will be available shortly."
  64.  
  65.         # Insert a sleep statement to give the server a few moments.
  66.  
  67.         sleep 5
  68.  
  69.     cfrunning
  70.    
  71.     if [ "$IS_RUNNING" = "false" ]; then
  72.                 echo "There has been an error starting ColdFusion 9, please check the logs."
  73.                 exit 1
  74.         fi
  75.  
  76.         [ -f "$CF_DIR/bin/cf-connectors.sh" ] && {
  77.                 # give the server a few more seconds to come up
  78.                 sleep 5
  79.                 echo "======================================================================"
  80.                 echo "Running the ColdFusion 9 connector wizard"
  81.                 echo "======================================================================"
  82.  
  83.                 sh $CF_DIR/bin/cf-connectors.sh && {
  84.                         mv -f $CF_DIR/bin/cf-connectors.sh $CF_DIR/bin/cf-connectors-run.sh
  85.                 }
  86.         }
  87.  
  88.  
  89.         echo "======================================================================"
  90.         echo "ColdFusion 9 has been started."
  91.         echo "ColdFusion 9 will write logs to $CF_DIR/logs/cfserver.log"
  92.         echo "======================================================================"
  93.  
  94. }
  95.  
  96. cfstop() {
  97.  
  98.         cfrunning
  99.                
  100.         if [ "$IS_RUNNING" = "false" ]; then
  101.                 echo "ColdFusion 9 does not seem to be currently running"
  102.                 return
  103.         fi
  104.  
  105.         echo "Stopping ColdFusion 9, please wait"
  106.  
  107.         eval $CFSTOP
  108.  
  109.         sleep 10
  110.  
  111.         cfrunning
  112.        
  113.         if [ "$IS_RUNNING" = "true" ]; then
  114.             echo "The ColdFusion 9 server seems to be hanging, will stop non-gracefully"       
  115.         if [ $OS = "Solaris" ]; then
  116.             $PSCMD | fgrep runtime/bin/coldfusion9 | awk '{print $1}' | xargs kill -9 > /dev/null 2>&1
  117.         else
  118.             # other platforms have only the executable name
  119.             # $PSCMD | fgrep coldfusion9 | awk '{print $1}' | xargs kill -9 > /dev/null 2>&1
  120.             $PSCMD | grep -i $JRUN_BIN | awk '{print $1}' | xargs kill -9 > /dev/null 2>&1
  121.             echo "DEBUG: $PSCMD | grep -i $JRUN_BIN | grep -v 'grep' | awk '{print $1}'"
  122.  
  123.         fi
  124.         sleep 2
  125.         fi
  126.        
  127.         cfrunning
  128.        
  129.         if [ "$IS_RUNNING" = "true" ]; then
  130.                 echo "There are some very stubborn ColdFusion 9 processes that will not die, please kill the following PIDs by hand: "
  131.         if [ $OS = "Solaris" ]; then
  132.                     $PSCMD | fgrep runtime/bin/coldfusion9 | awk '{print $1}'
  133.         else
  134.             # other platforms have only the executable name
  135.                 # $PSCMD | fgrep coldfusion9 | awk '{print $1}'
  136.                 $PSCMD | grep -i $JRUN_BIN | awk '{print $1}'
  137.                 echo "DEBUG: $PSCMD | grep -i $JRUN_BIN | grep -v 'grep' | awk '{print $1}'"
  138.         fi
  139.                 echo exiting
  140.                 exit 1
  141.         fi
  142.  
  143.         echo "ColdFusion 9 has been stopped"
  144. }
  145.  
  146.  
  147. case `uname` in
  148.  
  149.         SunOS)
  150.                 OS=Solaris
  151.                 PSCMD="ps -eo pid,comm"
  152.                 LD_LIBRARY_PATH="$CF_DIR/lib:$CF_DIR/lib/_solaris/bin"
  153.                 CFSTART='su $RUNTIME_USER -c "PATH=$PATH:$CF_DIR/runtime/bin; export PATH; LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd $CF_DIR/runtime/bin; nohup $CF_DIR/runtime/bin/coldfusion9 -jar jrun.jar -autorestart -start coldfusion &"'
  154.                 CFSTOP='su $RUNTIME_USER -c "PATH=$PATH:$CF_DIR/runtime/bin; export PATH; cd $CF_DIR/runtime/bin; $CF_DIR/runtime/bin/coldfusion9 -jar jrun.jar stop coldfusion"'
  155.         ;;
  156.  
  157.         Darwin)
  158.                 OS=Darwin
  159.                 # PSCMD="ps -axc"
  160.                 PSCMD="ps -ef"
  161.                 LD_LIBRARY_PATH="$CF_DIR/lib"
  162.                 CFSTART='export PATH=$PATH:$CF_DIR/runtime/bin; LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export LD_LIBRARY_PATH;cd $CF_DIR/runtime/bin; $CF_DIR/runtime/bin/coldfusion9 -jar jrun.jar -start coldfusion &'
  163.                 CFSTOP='env -i; cd $CF_DIR/runtime/bin; $CF_DIR/runtime/bin/coldfusion9 -jar jrun.jar stop coldfusion'
  164.         ;;
  165.  
  166.         Linux)
  167.                 OS=Linux
  168.                 PSCMD="ps -eo pid,comm"
  169.                 LD_LIBRARY_PATH="$CF_DIR/lib:$CF_DIR/lib/_ilnx21/bin"
  170.                 SUCMDFILE=su
  171.                 if [ -x /sbin/runuser ]; then
  172.                         SUCMDFILE=/sbin/runuser
  173.                 fi
  174.                 CFSTART='$SUCMDFILE -s /bin/sh $RUNTIME_USER -c "export PATH=$PATH:$CF_DIR/runtime/bin; export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; cd $CF_DIR/runtime/bin; nohup $CF_DIR/runtime/bin/coldfusion9 -jar jrun.jar -autorestart -start coldfusion &"'
  175.                 CFSTOP='$SUCMDFILE -s /bin/sh $RUNTIME_USER -c "env -i; cd $CF_DIR/runtime/bin; $CF_DIR/runtime/bin/coldfusion9 -jar jrun.jar stop coldfusion"'
  176.  
  177.                 # Some Java JVMs (both from Sun and IBM) don't work with the new floating stack
  178.                 # feature of the i686 version of glibc.  Force glibc to use the deprecated stack model.
  179.                 # Check if the OS is SuSE8.1 or SuSE 9 - if it is, do not use the deprecated stack model.
  180.                 #SUSEFLAG=`grep 'SuSE Linux 8.1\|UnitedLinux 1.0\|SuSE Linux 9\|SUSE LINUX Enterprise Server 9' /etc/SuSE-release /etc/UnitedLinux-release /etc/UnitedLinux-release 2> /dev/null`
  181.  
  182.                 #if [ ! "$SUSEFLAG" ]; then
  183.                         #LD_ASSUME_KERNEL=2.2.9
  184.                         #export LD_ASSUME_KERNEL
  185.                 #fi
  186.         ;;
  187.  
  188.         *)
  189.                 echo "Your OS: `uname` is unsupported"
  190.                 echo "exiting"
  191.                 exit 1
  192.         ;;
  193.  
  194. esac
  195.  
  196. ARG=$1
  197.  
  198. [ -z "$ARG" ] && ARG=usage
  199.  
  200. case $ARG in
  201.  
  202.         start)
  203.                 cfstart
  204.         ;;
  205.  
  206.         stop)
  207.                 cfstop
  208.         ;;
  209.  
  210.         restart)
  211.                 echo "Restarting ColdFusion 9..."
  212.                 cfstop
  213.                 cfstart
  214.         ;;
  215.  
  216.         status)
  217.                 if [ -x "$CF_DIR/bin/cfstat" ]; then
  218.                         shift
  219.                         $CF_DIR/bin/cfstat $@
  220.                 else
  221.                         echo "$0: $CF_DIR/bin/cfstat no such file"
  222.                 fi
  223.         ;;
  224.  
  225.         wsconfig)
  226.                 WSCONFIG_JAR=$CF_DIR/runtime/lib/wsconfig.jar
  227.  
  228.                 if [ $# -eq 0 ]; then
  229.                         # no arguments so display built-in help from wsconfig.jar
  230.                         $JAVA_EXECUTABLE -jar $WSCONFIG_JAR -help
  231.                         break
  232.                 else
  233.                         # brief help
  234.                         if [ "$2" = "help" ]; then
  235.                                 echo "To configure a webserver connector you must specify the -ws and -dir options."
  236.                                 echo "If configuring Apache it is recomended that you also specify the -bin and "
  237.                                 echo "-script options."
  238.                                 echo ""
  239.                                 echo "To list all configured webserver connectors use the -list option."
  240.                                 echo "To remove a configured webserver connector use the -r option with the "
  241.                                 echo "-ws and -dir options."
  242.                                 echo "To remove all webserver connectors use the -uninstall option."
  243.                                 echo "To upgrade all installed webserver connectors use the -upgrade option."
  244.                                 echo ""
  245.                                 echo "For more detailed help see $0 $1."
  246.                         fi
  247.                         break
  248.                 fi
  249.  
  250.                 # pass on all args to wsconfig.jar
  251.                 shift
  252.                 $JAVA_EXECUTABLE -jar $WSCONFIG_JAR $@ -coldfusion
  253.         ;;
  254.  
  255.         *)
  256.                 echo "Usage:$0 (start|stop|restart|status|wsconfig)"
  257.         ;;
  258.  
  259. esac
  260.  
  261.  
  262. exit 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top