#!/bin/sh # I've made this script so many different ways over the years... # Here is a nice simple start up script (be sure to chmod 755) # Make sure your system supports 'kill -0' ... run this script with 'info' as # an argument to find out. ### you can use this for any progam, just edit the fields below. # PIDFILE='/www/dev.skunkstudios.com/docs/log/mongrel.8001.pid' # NAME='mongrel' # COMMAND='cd /www/dev.skunkstudios.com/docs && mongrel_rails cluster::start' PIDFILE='/var/run/named.pid' NAME='named' COMMAND='/usr/sbin/named -u bind -g bind' # ------------------------------------------------------------ case "$1" in restart) $0 stop echo -n "re" $0 start ;; start) echo "starting $NAME" $COMMAND ;; stop) echo "stopping $NAME" if [ -f $PIDFILE ]; then PID=`cat $PIDFILE` kill $PID sleep 1 if kill -0 $PID 2> /dev/null; then echo " ." kill $PID sleep 2 fi if kill -0 $PID 2> /dev/null; then echo " ." kill -9 $PID sleep 2 fi if kill -0 $PID 2> /dev/null; then echo "! Check to make sure pid $PID is gone..." echo "! I tried to tell it to stop 3 times and then gave up." fi fi ;; info) echo "info on $NAME" if [ -f $PIDFILE ]; then PID=`cat $PIDFILE` if kill -0 $PID 2> /dev/null; then ps wwp $PID else echo "There is a pidfile ($PIDFILE) but the process is not running (checked pid: $PID)" fi else echo "! No pid file found... Checked $PIDFILE" fi ;; *) echo "" echo "Usage: `basename $0` { start | restart | stop | info }" echo "" exit 64 ;; esac ## ---------------------------------------------------------------------- ## Copyright (c) 2007 Rudy Rucker ## ## Permission is hereby granted, free of charge, to any person ## obtaining a copy of this software and associated documentation ## files (the "Software"), to deal in the Software without ## restriction, including without limitation the rights to use, ## copy, modify, merge, publish, distribute, sublicense, and/or sell ## copies of the Software, and to permit persons to whom the ## Software is furnished to do so, subject to the following ## conditions: ## ## The above copyright notice and this permission notice shall be ## included in all copies or substantial portions of the Software. ## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES ## OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ## NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ## HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ## WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING ## FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR ## OTHER DEALINGS IN THE SOFTWARE. ## ----------------------------------------------------------------------