startup / shutdown script (rc.d)

gmoniey gmoniey at gmail.com
Thu Jun 7 07:29:49 UTC 2007



Jerry McAllister-2 wrote:
> 
> Just as a test, I made the following sample script and named it   chkrc.sh
> and put it in /usr/local/etc/rc.d  with execute permission.
> It works just fine running from command line or as part of boot
> or shutdown.    You might try it as proof of concept and go from
> there.    Don't include the lines of dashes I put to deliminate it.
> Start with the #!/bin/sh line and end with the blank echo line.
> 
> 

I ran this script form the command line, and everything worked fine...so
then i tried to run it after issuing a reboot command...and this was the
output:

 Entering chkrc -- at: Wed Jun  6 23:22:19 PDT 2007
  +>> running chkrc.sh with a start argument
 Leaving chkrc -- at Wed Jun  6 23:22:19 PDT 2007

kinda wierd that the stop command wasnt issued....but i am more concerned
with the start command anyways...so i added my stuff to the file, which now
looks like this:

#!/bin/sh

echo " Entering chkrc -- at: `date` " >> /tmp/chkrc.log

case "$1" in
start)
  echo "  +>> running chkrc.sh with a start argument" >> /tmp/chkrc.log
  kldload accf_http >> /tmp/chkrc.log
  mongrel_rails cluster::start -v -C
/usr/local/www/myapp/config/mongrel_cluster.yml >> /tmp/chkrc.log
  /usr/local/www/myapp/script/backgroundrb start
  ;;
stop)
  echo "  <<- Running chkrc.sh with a stop argument" >> /tmp/chkrc.log
  mongrel_rails cluster::stop -v -C
/usr/local/www/myapp/config/mongrel_cluster.yml >> /tmp/chkrc.log
  /usr/local/www/myapp/script/backgroundrb stop
  ;;
*)
  echo "Calling args for chkrc.sh are start and stop" >> /tmp/chkrc.log
;;
esac

echo " Leaving chkrc -- at `date`" >> /tmp/chkrc.log
echo " " >> /tmp/chkrc.log


and i rebooted...but the tmp file looked the same (i.e. same output as the
example you gave me), and none of my processes were running...i also tested
this script from the command line, and both the start and stop commands work
correctly, and the results are outputted to the temp file as expected...

i dont know that much about unix, but is it possible that other variables
arent setup yet...and so my calls to mongrel_rails (which has a link in my
/usr/local/bin)?

i also changed the >> to expect STDERR, and still no luck...

-- 
View this message in context: http://www.nabble.com/startup---shutdown-script-%28rc.d%29-tf3848895.html#a11003239
Sent from the freebsd-questions mailing list archive at Nabble.com.



More information about the freebsd-questions mailing list