#!/usr/local/bin/ksh # *********************************************************************** # # * * # # * Copyright (c) 1996-1999 Scott Crevier * # # * All Rights Reserved Worldwide * # # * * # # * This program product material is the property of Scott Crevier. * # # * This program may be used and modified by anyone free of charge, * # # * as long as this copyright notice remains in tact. By using this * # # * code, you agree to indemnify Scott Crevier from any liability * # # * that might arise from its use. * # # * * # # * scott@crevier.org - Scott M. Crevier - www.crevier.org * # # *********************************************************************** # # * smcHTRestart.pl v2.0 25-Dec-1998 * # # * * # # * This is a web server start, stop and restart script. * # # * * # # * Recommended installation: * # # * * # # * 1) Rename this script to 'htrestart'. * # # * * # # * 2) Set permissions to 700 or whatever is appropriate for you. * # # * * # # * 3) Create the following two symbolic links to this script: * # # * * # # * ln -s htrestart htstart * # # * ln -s htrestart htstop * # # * * # # * Now, to stop the server, just run 'htstop'. To start it, run * # # * run 'htstart'. Or if you make a config change and you need to * # # * restart it (nicely), run 'htrestart'. * # # * * # # *********************************************************************** # # *********************************************************************** # # * Set some variables. * # # *********************************************************************** # httpdprog=/path/to/your/httpd httpdconf=/path/to/your/httpd.conf pidfile=/path/to/your/httpd.pid servername="Apache web server" seconds=4 # *********************************************************************** # # * Function to print the web server's process id. * # # *********************************************************************** # function print_pid { pid=`cat ${pidfile}` print "$servername PID: $pid" } # *********************************************************************** # # * Check for errors. * # # *********************************************************************** # if [ ! -f $httpdprog ] then print "ERROR: program not found '$httpdprog'" exit 1 fi if [ ! -f $httpdconf ] then print "ERROR: file not found '$httpdconf'" exit 1 fi if [ ! -f $pidfile ] then print "ERROR: file not found '$pidfile'" exit 1 fi # *********************************************************************** # # * Set some more variables. * # # *********************************************************************** # pid=`cat ${pidfile}` thisprog=`basename $0` # *********************************************************************** # # * RESTART WEB SERVER * # # *********************************************************************** # if [ "$thisprog" = "htrestart" ] then print_pid print "Restarting $servername ..." kill -HUP ${pid} sleep $seconds print_pid # *********************************************************************** # # * START WEB SERVER * # # *********************************************************************** # elif [ "$thisprog" = "htstart" ] then print "Starting $servername ..." $httpdprog -f $httpdconf sleep $seconds print_pid # *********************************************************************** # # * STOP WEB SERVER * # # *********************************************************************** # elif [ "$thisprog" = "htstop" ] then print "Stopping $servername ..." kill ${pid} print "Done." fi # *********************************************************************** # # * Finish up. * # # *********************************************************************** # exit 0