startup / shutdown script (rc.d)
Mikhail Goriachev
mikhailg at webanoide.org
Tue Jun 5 07:31:57 UTC 2007
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 "dddzzzzz"
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: mikhailg at webanoide.org
Web: www.webanoide.org
More information about the freebsd-questions
mailing list