Re: startup / shutdown script (rc.d)

2007-07-09 Thread gmoniey

to those interested, I finally solved this problem, it turns out that the
path wasnt correctly set for /usr/local/bin, and adding this line fixed it

PATH=/usr/local/bin:$PATH

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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-07 Thread gmoniey


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 issuedbut 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.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-06 Thread gmoniey

as my luck would have it...this didn't work...i used your script...test it by
running ./rtest start  ./rtest stop and everything worked fine (note: i
changed the name from rails to rtest as rails is an actual command)...

but when i rebooted nothing happened. I had the output dump to file and the
file was empty upon restart, which makes me believe it never actually ran..

Side Note: Jerry, the mongrel_rails command does spew some output, which is
why i dump it to file...

i even added the line rtest_enable=YES in my /etc/rc.conf file and
rebooted, but still no luck

thanks for your help fellas...i'll keep reading up as you suggested...


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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-06 Thread Jerry McAllister
On Tue, Jun 05, 2007 at 11:00:07PM -0700, gmoniey wrote:


 as my luck would have it...this didn't work...i used your script...test it by
 running ./rtest start  ./rtest stop and everything worked fine (note: i
 changed the name from rails to rtest as rails is an actual command)...

 but when i rebooted nothing happened. I had the output dump to file and the
 file was empty upon restart, which makes me believe it never actually ran..

You didn't even see the output from the echo command?
Try sticking one in before the case statement so it would always run
regardless of start or stop.


 Side Note: Jerry, the mongrel_rails command does spew some output, which is
 why i dump it to file...

OK.   But do you know whether it writes that output to STDOUT
or maybe to STDERR.If it is STDERR you will need a little
different syntax than  ''  Something like   '21 ' filename

 i even added the line rtest_enable=YES in my /etc/rc.conf file and
 rebooted, but still no luck

 thanks for your help fellas...i'll keep reading up as you suggested...


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.

jerry


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
#!/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 
  ;;
stop) 
  echo   - Running chkrc.sh with a stop argument  /tmp/chkrc.log 
  ;;
*)  
  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
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  


 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-05 Thread Mikhail Goriachev

gmoniey wrote:

thanks for the ideas, i tried both of your suggestions...i manually ran the
rails.sh file, and everything worked as expected...so i dumped the output to
file...my .sh file looks as such:


[ trim ]


the weird part is that the Rails found stop never printed...and im not sure
why the mongrel_rails fails (im assuming that the kldload works fine as it
doesn't print out any error messages if it is successfull)

i guess i will just keep playing with it...



Let's try a different approach. The following is a working script of 
your rails:


---
#!/bin/sh

# PROVIDE: rails
# KEYWORD: nojail shutdown

. /etc/rc.subr

name=rails
start_cmd=${name} start
stop_cmd=${name} stop

rails() {
case ${rc_arg} in
start)
echo -n Starting ${name}: 
echo -n 1 
echo -n 2 
echo 3
;;
stop)
echo -n Stopping ${name}: 
echo -n 3 
echo -n 2 
echo 1
;;
*)
echo dddz
esac
}

load_rc_config ${name}
run_rc_command ${1}
---

It looks different, but this is the new way how the OS fires things up. 
Place this script as /usr/local/etc/rc.d/rails. Don't add the 
extension to it (.sh). The use of extensions is old school. Chmod it to 
555 (or 755).


Now give it a spin:

# /usr/local/etc/rc.d/rails start
# /usr/local/etc/rc.d/rails stop
# /usr/local/etc/rc.d/rails restart
# /usr/local/etc/rc.d/rails blah

See what happens and then boot your machine. You'll see how it starts 
and stops. Once you're satisfied, tweak it to your needs.



If you want to control all aspects of the thing then you should read:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/configtuning-starting-services.html

Also read the rc.d(8) and all of its rc.* related man pages.


You can get lots of good examples in /etc/rc.d/. For instance 
/etc/rc.d/usbd is the simplest of them all.



Let us know how it goes.


Regards,
Mikhail.

--
Mikhail Goriachev
Webanoide

Telephone: +61 (0)3 62252501
Mobile Phone: +61 (0)4 38255158
E-Mail: [EMAIL PROTECTED]
Web: www.webanoide.org
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-05 Thread Jerry McAllister
On Mon, Jun 04, 2007 at 10:52:43PM -0700, gmoniey wrote:

 
 thanks for the ideas, i tried both of your suggestions...i manually ran the
 rails.sh file, and everything worked as expected...so i dumped the output to
 file...my .sh file looks as such:
 
 #!/bin/sh
 case $1 in
 start)
 echo RAILS found start  /tmp/test.file
 kldload accf_http  /tmp/test.file
 mongrel_rails cluster::start -v -C
 /usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
 /usr/local/www/app/script/backgroundrb start
 ;;
 stop)
 echo RAILS found stop  /tmp/test.file
 mongrel_rails cluster::stop -v -C
 /usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
 /usr/local/www/app/script/backgroundrb stop
 ;;
 *)
 echo Usage: `basename $0` {start|stop} 2
 exit 64
 ;;
 esac
 
 
 and the test.file ended up with this after the reboot:
 
 $cat /tmp/test.file
 RAILS found start
 
 
 the weird part is that the Rails found stop never printed...and im not sure
 why the mongrel_rails fails (im assuming that the kldload works fine as it
 doesn't print out any error messages if it is successfull)

Well, it looks like something after the case-start echo did not
work and things just died there and nothing else ran.
I would also put an echo just before the start and the stop sections
of the rc.d script end eg, just before the ';;'  in each..

What is the '/usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file'
supposed to accomplish?

jerry

 
 i guess i will just keep playing with it...
 
 
 
 -- 
 View this message in context: 
 http://www.nabble.com/startup---shutdown-script-%28rc.d%29-tf3848895.html#a10963533
 Sent from the freebsd-questions mailing list archive at Nabble.com.
 
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-05 Thread gmoniey

thanks guys...i will try the new script tonight (unfortunately i cant work on
this during the day...)

also, Jerry...the line:

'/usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file'

is only the second half of the  mongrel_rails line (i think the forum just
formatted it to come out to 2 lines...but it is really 1)


gmoniey wrote:
 
 thanks for the ideas, i tried both of your suggestions...i manually ran
 the rails.sh file, and everything worked as expected...so i dumped the
 output to file...my .sh file looks as such:
 
 #!/bin/sh
 case $1 in
 start)
 echo RAILS found start  /tmp/test.file
 kldload accf_http  /tmp/test.file
 mongrel_rails cluster::start -v -C
 /usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
 /usr/local/www/app/script/backgroundrb start
 ;;
 stop)
 echo RAILS found stop  /tmp/test.file
 mongrel_rails cluster::stop -v -C
 /usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
 /usr/local/www/app/script/backgroundrb stop
 ;;
 *)
 echo Usage: `basename $0` {start|stop} 2
 exit 64
 ;;
 esac
 
 
 and the test.file ended up with this after the reboot:
 
 $cat /tmp/test.file
 RAILS found start
 
 
 the weird part is that the Rails found stop never printed...and im not
 sure why the mongrel_rails fails (im assuming that the kldload works fine
 as it doesn't print out any error messages if it is successfull)
 
 i guess i will just keep playing with it...
 
 
 
 

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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-05 Thread Jerry McAllister
On Tue, Jun 05, 2007 at 09:54:14AM -0700, gmoniey wrote:

 
 thanks guys...i will try the new script tonight (unfortunately i cant work on
 this during the day...)
 
 also, Jerry...the line:
 
 '/usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file'
 
 is only the second half of the  mongrel_rails line (i think the forum just
 formatted it to come out to 2 lines...but it is really 1)

OK.  Mostly I was wondering if you really expected it to write
anything to that /tmp/test.file.I don't know what output 
it might create.

jerry

 
 
 gmoniey wrote:
  
  thanks for the ideas, i tried both of your suggestions...i manually ran
  the rails.sh file, and everything worked as expected...so i dumped the
  output to file...my .sh file looks as such:
  
  #!/bin/sh
  case $1 in
  start)
  echo RAILS found start  /tmp/test.file
  kldload accf_http  /tmp/test.file
  mongrel_rails cluster::start -v -C
  /usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
  /usr/local/www/app/script/backgroundrb start
  ;;
  stop)
  echo RAILS found stop  /tmp/test.file
  mongrel_rails cluster::stop -v -C
  /usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
  /usr/local/www/app/script/backgroundrb stop
  ;;
  *)
  echo Usage: `basename $0` {start|stop} 2
  exit 64
  ;;
  esac
  
  
  and the test.file ended up with this after the reboot:
  
  $cat /tmp/test.file
  RAILS found start
  
  
  the weird part is that the Rails found stop never printed...and im not
  sure why the mongrel_rails fails (im assuming that the kldload works fine
  as it doesn't print out any error messages if it is successfull)
  
  i guess i will just keep playing with it...
  
  
  
  
 
 -- 
 View this message in context: 
 http://www.nabble.com/startup---shutdown-script-%28rc.d%29-tf3848895.html#a10973422
 Sent from the freebsd-questions mailing list archive at Nabble.com.
 
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-04 Thread gmoniey

Hi,

so i tried the script you mentioned, and it doesnt seem as if it is being
called on startup. Here is my script (rails.sh):

#!/bin/sh
case $1 in
start)
kldload accf_http
mongrel_rails cluster::start -C
/usr/local/www/app/config/mongrel_cluster.yml
/usr/local/www/app/script/backgroundrb start
;;
stop)
mongrel_rails cluster::stop -C
/usr/local/www/app/config/mongrel_cluster.yml
/usr/local/www/app/script/backgroundrb stop
;;
*)
echo Usage: `basename $0` {start|stop} 2
exit 64
;;
esac


Also, I double checked that the permissions were correct (I made it the same
as the other scripts in the rc.d directory). Here is the directory listing:

-r-xr-xr-x  1 root  wheel   179 Jun  3 17:26 000.apache2libs.sh
-rwxr-x---  1 root  wheel   181 May  2 02:19 000.mysql-client.sh
-r-xr-xr-x  1 root  wheel  3524 Jun  3 12:07 apache2.sh
-r-xr-xr-x  1 root  wheel  1689 May  2 02:30 mysql-server.sh
-r-xr-xr-x  1 root  wheel   651 Jan 15 19:31 proftpd.sh
-r-xr-xr-x  1 root  wheel   445 Jun  3 17:26 rails.sh


While looking through the other files in the rc.d directory, I noticed that
000.apache2libs.sh has the similar structure as the file you suggested, so I
attempted to put my commands in there, but it seems as if they are not being
called either (i.e. after reboot, when i do a ps aux, i dont see the
commands i expect to be started)...

I also tried adding rails_enable = YES in the rc.conf file, and that
didn't work (although I didn't expect it to work, as I didn't assign a name
in my script).

any ideas?


Jerry McAllister-2 wrote:
 
 On Thu, May 31, 2007 at 09:05:17PM -0700, gmoniey wrote:
 
 
 Hi Noberto,
 
 I actually looked at the apache one, and it seemed so complicated, there
 were 2 files for it, one of which was relatively short and the other was
 significantly long.
 
 Now dont get me wrong, they aren't beyond comprehension, but i simply
 dont
 have the time right now to figure them out.
 
 I dont quite see how something as simple as apachectl start is expanded
 into so many lines.
 
 It is because those scripts take in to consideration so many
 possible different conditions.   In addition, lines like:
 
   # PROVIDE: apache22
   # REQUIRE: NETWORKING SERVERS
   # BEFORE: DAEMON
   # KEYWORD: shutdown
 
 Deal with ordering of execution and integrating with other things.
 They could be meaningful, but are probably not needed in a simple
 routine like you seem to want.
 
 The basic scheme is that the system calls the scripts in rc.d
 one at a time.   During startup it calls them with an argument
 of 'start'  and when it is shutting down, it calls them with
 an argument of 'stop'.   So, all you script has to do is look
 for a first argument (past the script name) and check for start
 or stop and possibly error if it is anything else.
 
 Presuming you have one routine to run at startup
 called  /usr/local/bin/mystartuproutine
 and one routine to run at shutdown
 called /usr/local/bin/myshutdownroutine
 and these two files have execute permission,
 then something as simple as this would work.
 
 Put this little script in /usr/local/etc/rc.d/  with
 a name something like mystuff.sh and give it execute permission.
 
 
 #!/bin/sh
 case $1 in
 start)
   /usr/local/bin/mystartuproutine
 ;;
 stop)
   /usr/local/bin/myshutdownroutine
 ;;
 *)
 echo Usage: `basename $0` {start|stop} 2
 exit 64
 ;;
 esac
 
 
 You might want to add some other checks and conditions such
 as checking if those files exist and some niceties such as 
 making variables of your routine names later.
 
 jerry
 
 
 maybe i will get some time in the near future to understand it...
 
 
 Norberto Meijome-2 wrote:
  
  On Thu, 31 May 2007 14:06:45 -0700 (PDT)
  gmoniey [EMAIL PROTECTED] wrote:
  
  I was wondering if there is a simple way to create 1 script that will
 be
  called during startup and shutdown. Basically, I am looking for
 something
  like this:
  
  the easiest way (for me) is to grab the rc script of anything that you
  know
  well (for example, apache) and modify it for your needs. anyway, at
 least
  you
  can learn from the one that is already made, without having to start
 from
  scratch.
  
  B 
  
  _
  {Beto|Norberto|Numard} Meijome
  
  People demand freedom of speech to make up for the freedom of thought
  which
  they avoid.  Soren Aabye Kierkegaard
  
  I speak for myself, not my employer. Contents may be hot. Slippery when
  wet.
  Reading disclaimers makes you go blind. Writing them is worse. You have
  been
  Warned.
  ___
  freebsd-questions@freebsd.org mailing list
  http://lists.freebsd.org/mailman/listinfo/freebsd-questions
  To unsubscribe, send any mail to
  [EMAIL PROTECTED]
  
  
 
 -- 
 View this message in context:
 http://www.nabble.com/startup---shutdown-script-%28rc.d%29-tf3848895.html#a10906324
 Sent from the 

Re: startup / shutdown script (rc.d)

2007-06-04 Thread Jerry McAllister
On Mon, Jun 04, 2007 at 09:55:26AM -0700, gmoniey wrote:

 
 Hi,
 
 so i tried the script you mentioned, and it doesnt seem as if it is being
 called on startup. Here is my script (rails.sh):
 
 #!/bin/sh
 case $1 in
 start)
 kldload accf_http
 mongrel_rails cluster::start -C
 /usr/local/www/app/config/mongrel_cluster.yml
 /usr/local/www/app/script/backgroundrb start
 ;;
 stop)
 mongrel_rails cluster::stop -C
 /usr/local/www/app/config/mongrel_cluster.yml
 /usr/local/www/app/script/backgroundrb stop
 ;;
 *)
 echo Usage: `basename $0` {start|stop} 2
 exit 64
 ;;
 esac
 

try making it write to a file at the beginning and end of 
the start and stop sections.   
Something like:
  echo RAILS found start  /tmp/railstest
   ...  other stuff  ...
  echo RAILS finishing start  /tmp/railstest

or whatever makes sense to you.

Maybe your script is crashing for some other reason.

jerry

 
 Also, I double checked that the permissions were correct (I made it the same
 as the other scripts in the rc.d directory). Here is the directory listing:
 
 -r-xr-xr-x  1 root  wheel   179 Jun  3 17:26 000.apache2libs.sh
 -rwxr-x---  1 root  wheel   181 May  2 02:19 000.mysql-client.sh
 -r-xr-xr-x  1 root  wheel  3524 Jun  3 12:07 apache2.sh
 -r-xr-xr-x  1 root  wheel  1689 May  2 02:30 mysql-server.sh
 -r-xr-xr-x  1 root  wheel   651 Jan 15 19:31 proftpd.sh
 -r-xr-xr-x  1 root  wheel   445 Jun  3 17:26 rails.sh
 
 
 While looking through the other files in the rc.d directory, I noticed that
 000.apache2libs.sh has the similar structure as the file you suggested, so I
 attempted to put my commands in there, but it seems as if they are not being
 called either (i.e. after reboot, when i do a ps aux, i dont see the
 commands i expect to be started)...
 
 I also tried adding rails_enable = YES in the rc.conf file, and that
 didn't work (although I didn't expect it to work, as I didn't assign a name
 in my script).
 
 any ideas?
 
 
 Jerry McAllister-2 wrote:
  
  On Thu, May 31, 2007 at 09:05:17PM -0700, gmoniey wrote:
  
  
  Hi Noberto,
  
  I actually looked at the apache one, and it seemed so complicated, there
  were 2 files for it, one of which was relatively short and the other was
  significantly long.
  
  Now dont get me wrong, they aren't beyond comprehension, but i simply
  dont
  have the time right now to figure them out.
  
  I dont quite see how something as simple as apachectl start is expanded
  into so many lines.
  
  It is because those scripts take in to consideration so many
  possible different conditions.   In addition, lines like:
  
# PROVIDE: apache22
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
  
  Deal with ordering of execution and integrating with other things.
  They could be meaningful, but are probably not needed in a simple
  routine like you seem to want.
  
  The basic scheme is that the system calls the scripts in rc.d
  one at a time.   During startup it calls them with an argument
  of 'start'  and when it is shutting down, it calls them with
  an argument of 'stop'.   So, all you script has to do is look
  for a first argument (past the script name) and check for start
  or stop and possibly error if it is anything else.
  
  Presuming you have one routine to run at startup
  called  /usr/local/bin/mystartuproutine
  and one routine to run at shutdown
  called /usr/local/bin/myshutdownroutine
  and these two files have execute permission,
  then something as simple as this would work.
  
  Put this little script in /usr/local/etc/rc.d/  with
  a name something like mystuff.sh and give it execute permission.
  
  
  #!/bin/sh
  case $1 in
  start)
  /usr/local/bin/mystartuproutine
  ;;
  stop)
  /usr/local/bin/myshutdownroutine
  ;;
  *)
  echo Usage: `basename $0` {start|stop} 2
  exit 64
  ;;
  esac
  
  
  You might want to add some other checks and conditions such
  as checking if those files exist and some niceties such as 
  making variables of your routine names later.
  
  jerry
  
  
  maybe i will get some time in the near future to understand it...
  
  
  Norberto Meijome-2 wrote:
   
   On Thu, 31 May 2007 14:06:45 -0700 (PDT)
   gmoniey [EMAIL PROTECTED] wrote:
   
   I was wondering if there is a simple way to create 1 script that will
  be
   called during startup and shutdown. Basically, I am looking for
  something
   like this:
   
   the easiest way (for me) is to grab the rc script of anything that you
   know
   well (for example, apache) and modify it for your needs. anyway, at
  least
   you
   can learn from the one that is already made, without having to start
  from
   scratch.
   
   B 
   
   _
   {Beto|Norberto|Numard} Meijome
   
   People demand freedom of speech to make up for the freedom of thought
   which
   they avoid.  Soren Aabye Kierkegaard
   
   I 

Re: startup / shutdown script (rc.d)

2007-06-04 Thread RW
On Mon, 4 Jun 2007 09:55:26 -0700 (PDT)
gmoniey [EMAIL PROTECTED] wrote:

 
 Hi,
 
 so i tried the script you mentioned, and it doesnt seem as if it is
 being called on startup. Here is my script (rails.sh):
...
 While looking through the other files in the rc.d directory, I
 noticed that 000.apache2libs.sh has the similar structure as the file
 you suggested, so I attempted to put my commands in there, but it
 seems as if they are not being called either (i.e. after reboot, when
 i do a ps aux, i dont see the commands i expect to be started)...

what happens if you just type./rails.sh start 
manually? 

If it works, but not during start-up, it may needs some other
service to start first. 
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-04 Thread Jerry McAllister
On Tue, Jun 05, 2007 at 03:12:24AM +0100, RW wrote:

 On Mon, 4 Jun 2007 09:55:26 -0700 (PDT)
 gmoniey [EMAIL PROTECTED] wrote:
 
  
  Hi,
  
  so i tried the script you mentioned, and it doesnt seem as if it is
  being called on startup. Here is my script (rails.sh):
 ...
  While looking through the other files in the rc.d directory, I
  noticed that 000.apache2libs.sh has the similar structure as the file
  you suggested, so I attempted to put my commands in there, but it
  seems as if they are not being called either (i.e. after reboot, when
  i do a ps aux, i dont see the commands i expect to be started)...
 
 what happens if you just type./rails.sh start 
 manually? 
 
 If it works, but not during start-up, it may needs some other
 service to start first. 

Good idea.  I usually do that to test my own scripts, so am surprised
I didn't think of it when posting.

jerry

 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-04 Thread gmoniey

thanks for the ideas, i tried both of your suggestions...i manually ran the
rails.sh file, and everything worked as expected...so i dumped the output to
file...my .sh file looks as such:

#!/bin/sh
case $1 in
start)
echo RAILS found start  /tmp/test.file
kldload accf_http  /tmp/test.file
mongrel_rails cluster::start -v -C
/usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
/usr/local/www/app/script/backgroundrb start
;;
stop)
echo RAILS found stop  /tmp/test.file
mongrel_rails cluster::stop -v -C
/usr/local/www/app/config/mongrel_cluster.yml  /tmp/test.file
/usr/local/www/app/script/backgroundrb stop
;;
*)
echo Usage: `basename $0` {start|stop} 2
exit 64
;;
esac


and the test.file ended up with this after the reboot:

$cat /tmp/test.file
RAILS found start


the weird part is that the Rails found stop never printed...and im not sure
why the mongrel_rails fails (im assuming that the kldload works fine as it
doesn't print out any error messages if it is successfull)

i guess i will just keep playing with it...



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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-01 Thread RW
On Thu, 31 May 2007 14:06:45 -0700 (PDT)
gmoniey [EMAIL PROTECTED] wrote:

 
 Hi,
 
 I was wondering if there is a simple way to create 1 script that will
 be called during startup and shutdown. Basically, I am looking for
 something like this:
 
 if startup
run command 1 with params
run command 2 with params
run command 3 with params
 
 if shutdown
run command 4 with params
run command 5 with params
run command 6 with params
 
 i have tried lookin up rc.d documentation, but it very vague and
 difficult to understand...thanks

There are lots of existing scripts that do this kind of thing. A good
example is /etc/rc.d/random which feeds entropy files to /dev/random on
startup, and writes-out entropy on shutdown. It's pretty easy to see
what's going-on.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-01 Thread Jerry McAllister
On Thu, May 31, 2007 at 09:05:17PM -0700, gmoniey wrote:

 
 Hi Noberto,
 
 I actually looked at the apache one, and it seemed so complicated, there
 were 2 files for it, one of which was relatively short and the other was
 significantly long.
 
 Now dont get me wrong, they aren't beyond comprehension, but i simply dont
 have the time right now to figure them out.
 
 I dont quite see how something as simple as apachectl start is expanded
 into so many lines.

It is because those scripts take in to consideration so many
possible different conditions.   In addition, lines like:

  # PROVIDE: apache22
  # REQUIRE: NETWORKING SERVERS
  # BEFORE: DAEMON
  # KEYWORD: shutdown

Deal with ordering of execution and integrating with other things.
They could be meaningful, but are probably not needed in a simple
routine like you seem to want.

The basic scheme is that the system calls the scripts in rc.d
one at a time.   During startup it calls them with an argument
of 'start'  and when it is shutting down, it calls them with
an argument of 'stop'.   So, all you script has to do is look
for a first argument (past the script name) and check for start
or stop and possibly error if it is anything else.

Presuming you have one routine to run at startup
called  /usr/local/bin/mystartuproutine
and one routine to run at shutdown
called /usr/local/bin/myshutdownroutine
and these two files have execute permission,
then something as simple as this would work.

Put this little script in /usr/local/etc/rc.d/  with
a name something like mystuff.sh and give it execute permission.


#!/bin/sh
case $1 in
start)
/usr/local/bin/mystartuproutine
;;
stop)
/usr/local/bin/myshutdownroutine
;;
*)
echo Usage: `basename $0` {start|stop} 2
exit 64
;;
esac


You might want to add some other checks and conditions such
as checking if those files exist and some niceties such as 
making variables of your routine names later.

jerry

 
 maybe i will get some time in the near future to understand it...
 
 
 Norberto Meijome-2 wrote:
  
  On Thu, 31 May 2007 14:06:45 -0700 (PDT)
  gmoniey [EMAIL PROTECTED] wrote:
  
  I was wondering if there is a simple way to create 1 script that will be
  called during startup and shutdown. Basically, I am looking for something
  like this:
  
  the easiest way (for me) is to grab the rc script of anything that you
  know
  well (for example, apache) and modify it for your needs. anyway, at least
  you
  can learn from the one that is already made, without having to start from
  scratch.
  
  B 
  
  _
  {Beto|Norberto|Numard} Meijome
  
  People demand freedom of speech to make up for the freedom of thought
  which
  they avoid.  Soren Aabye Kierkegaard
  
  I speak for myself, not my employer. Contents may be hot. Slippery when
  wet.
  Reading disclaimers makes you go blind. Writing them is worse. You have
  been
  Warned.
  ___
  freebsd-questions@freebsd.org mailing list
  http://lists.freebsd.org/mailman/listinfo/freebsd-questions
  To unsubscribe, send any mail to
  [EMAIL PROTECTED]
  
  
 
 -- 
 View this message in context: 
 http://www.nabble.com/startup---shutdown-script-%28rc.d%29-tf3848895.html#a10906324
 Sent from the freebsd-questions mailing list archive at Nabble.com.
 
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-06-01 Thread gmoniey

thanks to both of youi will give those examples a shot tonight...thanks
again!



gmoniey wrote:
 
 Hi Noberto,
 
 I actually looked at the apache one, and it seemed so complicated, there
 were 2 files for it, one of which was relatively short and the other was
 significantly long.
 
 Now dont get me wrong, they aren't beyond comprehension, but i simply dont
 have the time right now to figure them out.
 
 I dont quite see how something as simple as apachectl start is expanded
 into so many lines.
 
 maybe i will get some time in the near future to understand it...
 
 
 
 Norberto Meijome-2 wrote:
 
 On Thu, 31 May 2007 14:06:45 -0700 (PDT)
 gmoniey [EMAIL PROTECTED] wrote:
 
 I was wondering if there is a simple way to create 1 script that will be
 called during startup and shutdown. Basically, I am looking for
 something
 like this:
 
 the easiest way (for me) is to grab the rc script of anything that you
 know
 well (for example, apache) and modify it for your needs. anyway, at least
 you
 can learn from the one that is already made, without having to start from
 scratch.
 
 B 
 
 _
 {Beto|Norberto|Numard} Meijome
 
 People demand freedom of speech to make up for the freedom of thought
 which
 they avoid.  Soren Aabye Kierkegaard
 
 I speak for myself, not my employer. Contents may be hot. Slippery when
 wet.
 Reading disclaimers makes you go blind. Writing them is worse. You have
 been
 Warned.
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 [EMAIL PROTECTED]
 
 
 
 

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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-05-31 Thread Duane Hill

On Thu, 31 May 2007, gmoniey wrote:



Hi,

I was wondering if there is a simple way to create 1 script that will be
called during startup and shutdown. Basically, I am looking for something
like this:

if startup
  run command 1 with params
  run command 2 with params
  run command 3 with params

if shutdown
  run command 4 with params
  run command 5 with params
  run command 6 with params

i have tried lookin up rc.d documentation, but it very vague and difficult
to understand...thanks


I don't know if this is too vague as well or not. However, I used the man 
page for 'rc' on startup/shutdown scripts. Just do 'man rc'.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


startup / shutdown script (rc.d)

2007-05-31 Thread gmoniey

Hi,

I was wondering if there is a simple way to create 1 script that will be
called during startup and shutdown. Basically, I am looking for something
like this:

if startup
   run command 1 with params
   run command 2 with params
   run command 3 with params

if shutdown
   run command 4 with params
   run command 5 with params
   run command 6 with params

i have tried lookin up rc.d documentation, but it very vague and difficult
to understand...thanks
-- 
View this message in context: 
http://www.nabble.com/startup---shutdown-script-%28rc.d%29-tf3848895.html#a10902043
Sent from the freebsd-questions mailing list archive at Nabble.com.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-05-31 Thread Norberto Meijome
On Thu, 31 May 2007 14:06:45 -0700 (PDT)
gmoniey [EMAIL PROTECTED] wrote:

 I was wondering if there is a simple way to create 1 script that will be
 called during startup and shutdown. Basically, I am looking for something
 like this:

the easiest way (for me) is to grab the rc script of anything that you know
well (for example, apache) and modify it for your needs. anyway, at least you
can learn from the one that is already made, without having to start from
scratch.

B 

_
{Beto|Norberto|Numard} Meijome

People demand freedom of speech to make up for the freedom of thought which
they avoid.  Soren Aabye Kierkegaard

I speak for myself, not my employer. Contents may be hot. Slippery when wet.
Reading disclaimers makes you go blind. Writing them is worse. You have been
Warned.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-05-31 Thread gmoniey

Hi Noberto,

I actually looked at the apache one, and it seemed so complicated, there
were 2 files for it, one of which was relatively short and the other was
significantly long.

Now dont get me wrong, they aren't beyond comprehension, but i simply dont
have the time right now to figure them out.

I dont quite see how something as simple as apachectl start is expanded
into so many lines.

maybe i will get some time in the near future to understand it...



Norberto Meijome-2 wrote:
 
 On Thu, 31 May 2007 14:06:45 -0700 (PDT)
 gmoniey [EMAIL PROTECTED] wrote:
 
 I was wondering if there is a simple way to create 1 script that will be
 called during startup and shutdown. Basically, I am looking for something
 like this:
 
 the easiest way (for me) is to grab the rc script of anything that you
 know
 well (for example, apache) and modify it for your needs. anyway, at least
 you
 can learn from the one that is already made, without having to start from
 scratch.
 
 B 
 
 _
 {Beto|Norberto|Numard} Meijome
 
 People demand freedom of speech to make up for the freedom of thought
 which
 they avoid.  Soren Aabye Kierkegaard
 
 I speak for myself, not my employer. Contents may be hot. Slippery when
 wet.
 Reading disclaimers makes you go blind. Writing them is worse. You have
 been
 Warned.
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 [EMAIL PROTECTED]
 
 

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

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: startup / shutdown script (rc.d)

2007-05-31 Thread Norberto Meijome
On Thu, 31 May 2007 21:05:17 -0700 (PDT)
gmoniey [EMAIL PROTECTED] wrote:

 I actually looked at the apache one, and it seemed so complicated, there
 were 2 files for it, one of which was relatively short and the other was
 significantly long.
 
 Now dont get me wrong, they aren't beyond comprehension, but i simply dont
 have the time right now to figure them out.
 
 I dont quite see how something as simple as apachectl start is expanded
 into so many lines.
 
 maybe i will get some time in the near future to understand it...

fair enough. How's this for a simpler script?
---
#!/bin/sh

RTOOL=/usr/local/bin/radeontool
case $1 in
start)
if [ -x $RTOOL ]; then
echo -n ' Radeon'
$RTOOL light
$RTOOL light on
$RTOOL light
$RTOOL dac 
$RTOOL dac off
$RTOOL dac
fi
;;
stop)
;;
*)
echo Usage: `basename $0` {start|stop} 2
exit 64
;;
esac

-

it doesnt read anything from rc.conf at all (which is where some of the extra 
stuff is)

_
{Beto|Norberto|Numard} Meijome

Too bad ignorance isn't painful.
  Don Lindsay

I speak for myself, not my employer. Contents may be hot. Slippery when wet. 
Reading disclaimers makes you go blind. Writing them is worse. You have been 
Warned.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]