startup / shutdown script (rc.d)
gmoniey
gmoniey at gmail.com
Mon Jun 4 16:55:27 UTC 2007
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 <gmoniey at gmail.com> 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 at freebsd.org mailing list
>> > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> > To unsubscribe, send any mail to
>> > "freebsd-questions-unsubscribe at freebsd.org"
>> >
>> >
>>
>> --
>> 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 at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to
>> "freebsd-questions-unsubscribe at freebsd.org"
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"
>
>
--
View this message in context: http://www.nabble.com/startup---shutdown-script-%28rc.d%29-tf3848895.html#a10953687
Sent from the freebsd-questions mailing list archive at Nabble.com.
More information about the freebsd-questions
mailing list