I recently installed ColdFusion 11 on RHEL, but the cfinit script did not exist. I then pulled up a ColdFusion 10 init script, updated the CF10-CF11 bits, corrected the coding error for the CFSTATUS section particular to my OS and have the script below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
#!/bin/bash # chkconfig: 345 90 14 # description: starts the ColdFusion MX server PATH=/usr/xpg4/bin:/bin:/sbin:/usr/bin:/usr/sbin:$PATH CONNECTOR=“” RUNTIME_USER=“”nobody“” JAVA_HOME=“/opt/coldfusion11/jre” DOCROOT=“” CF_DIR=“/opt/coldfusion11/cfusion” IS_RUNNING=“false” IS_MAC=“false” VERSION=“ColdFusion 11” SPACE=” “ CLASSPATH=$CF_DIR/runtime/bin/tomcat–juli.jar:$CF_DIR/bin/cf–bootstrap.jar JVMCONFIG=$CF_DIR/bin/jvm.config . $CF_DIR/bin/parseargs $JVMCONFIG CLASSPATH=$CLASSPATH:$JAVA_CLASSPATH JAVA_LIBRARY_PATH=$JAVA_LIBRARYPATH JAVA_EXECUTABLE=“$JAVA_HOME/bin/java” #Get the server instance name arr=$(echo $CF_DIR | tr “/” “\n”) for x in $arr do CF_INSTANCE_NAME=“$x” done for word in $JVM_ARGS do if [ “$word” != “-Xdebug” ]; then if [ ${word:0:9} != “-Xrunjdwp” ]; then JVM_ARGS_NODEBUG=“$JVM_ARGS_NODEBUG$SPACE$word” fi fi done ID=`id –u` if [ “`uname`” = “Darwin” ]; then # nothing, on OSX we don’t care about the user name. We assume that the user running it has permission to do everything IS_MAC=“true” elif [ ! $ID –eq 0 ]; then echo “You must be root to start ColdFusion .” exit 1 fi cfrunning() { IS_RUNNING=“false” if [ $OS = “Solaris” ]; then # The comm output on Solaris includes the full path $PSCMD | fgrep $CF_DIR |fgrep java > /dev/null 2>&1 else # other platforms have only the executable name $PSCMD | fgrep java | grep –v grep | grep com.adobe.coldfusion.bootstrap.Bootstrap | grep “start” | grep –w $CF_DIR > /dev/null 2>&1 fi if [ $? –eq 0 ]; then IS_RUNNING=“true” fi } cfstart() { # [ -f $CF_DIR/bin/jvm.config ] || { # ln -s $CF_DIR/runtime/bin/jvm.config $CF_DIR/bin/jvm.config # } cfrunning if [ “$IS_RUNNING” = “true” ]; then echo “$VERSION server instance named $CF_INSTANCE_NAME is already running” echo exiting exit 2 fi echo “Starting $VERSION server instance named $CF_INSTANCE_NAME …” eval $CFSTART echo “The $VERSION server instance named $CF_INSTANCE_NAME is starting up and will be available shortly.” # Insert a sleep statement to give the server a few moments. sleep 5 cfrunning if [ “$IS_RUNNING” = “false” ]; then echo “There has been an error starting $VERSION server instance named $CF_INSTANCE_NAME, please check the logs.” exit 1 fi [ –f “$CF_DIR/bin/cf-connectors.sh” ] && { # give the server a few more seconds to come up sleep 5 echo “======================================================================” echo “Running the $VERSION connector wizard” echo “======================================================================” sh $CF_DIR/bin/cf–connectors.sh && { mv –f $CF_DIR/bin/cf–connectors.sh $CF_DIR/bin/cf–connectors–run.sh } } echo “======================================================================” echo “$VERSION server instance named $CF_INSTANCE_NAME has been started.” echo “$VERSION will write logs to $CF_DIR/logs/coldfusion-out.log” echo “======================================================================” } cfstop() { cfrunning if [ “$IS_RUNNING” = “false” ]; then echo “$VERSION server instance named $CF_INSTANCE_NAME does not seem to be currently running” return fi echo “Stopping $VERSION server instance named $CF_INSTANCE_NAME, please wait” eval $CFSTOP sleep 10 cfrunning if [ “$IS_RUNNING” = “true” ]; then if [ $OS = “Solaris” –a ! –f “/usr/ucb/ps” ]; then $PSCMD | fgrep java | fgrep $CF_DIR | awk ‘{print $2}’ | xargs kill –9 > /dev/null 2>&1 else # other platforms have only the executable name $PSCMD | fgrep java | grep –v grep | grep com.adobe.coldfusion.bootstrap.Bootstrap | grep “start” | grep –w $CF_DIR | awk ‘{print $2}’ | sudo xargs kill –9 > /dev/null 2>&1 fi sleep 2 fi cfrunning if [ “$IS_RUNNING” = “true” ]; then echo “$VERSION server is not responding. You have to forcefully stop the following ColdFusion PIDs manually: “ if [ $OS = “Solaris” ]; then $PSCMD | fgrep java | fgrep $CF_DIR | awk ‘{print $2}’ else # other platforms have only the executable name $PSCMD | fgrep java | grep –v grep | grep com.adobe.coldfusion.bootstrap.Bootstrap | grep “start” | grep –w $CF_DIR | awk ‘{print $2}’ fi echo exiting exit 1 fi echo “$VERSION server instance named $CF_INSTANCE_NAME has been stopped” } cfstatus() { eval $CFSTATUS } case `uname` in SunOS) OS=Solaris if [ –f “/usr/ucb/ps” ]; then PSCMD=“/usr/ucb/ps -auxww” else PSCMD=“ps -eo comm” fi JAVA_EXECUTABLE=“$JAVA_HOME/bin/sparcv9/java” LD_LIBRARY_PATH=“$CF_DIR/lib:$CF_DIR/lib/_solaris/bin:$JAVA_LIBRARY_PATH” CFSTART=‘su $RUNTIME_USER -c “LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd $CF_DIR/bin; nohup $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS com.adobe.coldfusion.bootstrap.Bootstrap -start &”‘ CFSTOP=‘su $RUNTIME_USER -c “cd $CF_DIR/bin; $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS_NODEBUG com.adobe.coldfusion.bootstrap.Bootstrap -stop”‘ CFSTATUS=‘su $RUNTIME_USER -c “cd $CF_DIR/bin; $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS_NODEBUG com.adobe.coldfusion.bootstrap.Bootstrap -status”‘ ;; Darwin) OS=Darwin PSCMD=“ps -ef” LD_LIBRARY_PATH=“$CF_DIR/lib:$JAVA_LIBRARY_PATH” CFSTART=‘LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export LD_LIBRARY_PATH;cd $CF_DIR/bin; $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS com.adobe.coldfusion.bootstrap.Bootstrap -start&’ CFSTOP=‘env -i; cd $CF_DIR/bin; $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS_NODEBUG com.adobe.coldfusion.bootstrap.Bootstrap -stop’ CFSTATUS=‘su $RUNTIME_USER -c “cd $CF_DIR/bin; $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS_NODEBUG com.adobe.coldfusion.bootstrap.Bootstrap -status”‘ ;; Linux) OS=Linux PSCMD=“ps -ef” LD_LIBRARY_PATH=“$CF_DIR/lib:$CF_DIR/lib/_ilnx21/bin:$JAVA_LIBRARY_PATH” SUCMDFILE=su if [ –x /sbin/runuser ]; then SUCMDFILE=/sbin/runuser fi CFSTART=‘$SUCMDFILE -s /bin/sh $RUNTIME_USER -c “export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; cd $CF_DIR/bin; nohup $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS com.adobe.coldfusion.bootstrap.Bootstrap -start &”‘ CFSTOP=‘$SUCMDFILE -s /bin/sh $RUNTIME_USER -c “env -i; cd $CF_DIR/bin;$JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS_NODEBUG com.adobe.coldfusion.bootstrap.Bootstrap -stop”‘ CFSTATUS=‘$SUCMDFILE -s /bin/sh $RUNTIME_USER -c “cd $CF_DIR/bin; $JAVA_EXECUTABLE -classpath $CLASSPATH $JVM_ARGS_NODEBUG com.adobe.coldfusion.bootstrap.Bootstrap -status”‘ ;; *) echo “Your OS: `uname` is unsupported” echo “exiting” exit 1 ;; esac ARG=$1 [ –z “$ARG” ] && ARG=usage case $ARG in start) cfstart ;; stop) cfstop ;; restart) echo “Restarting $VERSION server instance named $CF_INSTANCE_NAME …” cfstop cfstart ;; status) cfstatus ;; wsconfig) WSCONFIG_JAR=$CF_DIR/runtime/lib/wsconfig.jar if [ $# -eq 0 ]; then # no arguments so display built-in help from wsconfig.jar $JAVA_EXECUTABLE –jar $WSCONFIG_JAR –help break else # brief help if [ “$2” = “help” ]; then echo “To configure a webserver connector you must specify the -ws and -dir options.” echo “If configuring Apache it is recomended that you also specify the -bin and “ echo “-script options.” echo “” echo “To list all configured webserver connectors use the -list option.” echo “To remove a configured webserver connector use the -r option with the “ echo “-ws and -dir options.” echo “To remove all webserver connectors use the -uninstall option.” echo “To upgrade all installed webserver connectors use the -upgrade option.” echo “” echo “For more detailed help see $0 $1.” fi break fi # pass on all args to wsconfig.jar shift $JAVA_EXECUTABLE –jar $WSCONFIG_JAR $@ –coldfusion ;; *) echo “Usage:$0 (start|stop|restart|status|wsconfig)” ;; esac exit 0 |
I then ensured permissions on the file and made sure it would add to startup correctly:
1 2 3 |
chown root:root /etc/init.d/coldfusion_11 chmod +x /etc/init.d/coldfusion_11 chkconfig —add /etc/init.d/coldfusion_11 |
Leave a Reply