Subject: Re: Writing my own script for /etc/rc.d
To: Benjamin Walkenhorst <krylon@gmx.net>
From: Dominik Schestauber <schestau@fmi.uni-passau.de>
List: netbsd-users
Date: 01/03/2004 16:12:33
Hello Benjamin,

I found "The Design and Implementation of the NetBSD rc.d system" to be a
quite interesting read. This article can be found at:

http://www.mewburn.net/luke/talks/auug-2003/

It describes how the NetBSD rc.d system works and what the background for
some design decisions was. I hope you find it useful, though it's not
tutorial on writing rc scripts.

Greetings,

Dominik


On Thu, 1 Jan 2004, Benjamin Walkenhorst wrote:

> Date: Thu, 1 Jan 2004 16:31:49 +0100
> From: Benjamin Walkenhorst <krylon@gmx.net>
> To: netbsd-users@netbsd.org
> Subject: Writing my own script for /etc/rc.d
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello everybody,
>
> When I started learning C (about three and a half years ago), one of the
> programs I wrote was for checking the Goldbach-assumption. It says that
> for every even number >= 4 can be shown to be the sum of two prime
> numbers.
> As far as I know Goldbach so far has neither been shown to be right or
> wrong. And the only way to do so I could think of - being no
> mathematician - is to check every even number >= 4.
> More than three years later, my C is still very poor. =) But recently I
> started to care again and rewrote the program.
> I rewrote it again, when I got hold of a copy of "The C Programming
> Language 2nd edition". I even rewrote it another time, using a faster
> algorithm.
>
> Now I would like to run the program on my NetBSD-box (which I use as a
> small home server and ipnat-gateway). In fact I have done so for quite
> some time, but so far I've been controlling it manually.
> Now I am growing tired of that and would like to control goldbach via
> rc.conf. So I looked up what other scripts in /etc/rc.d look like and
> wrote a script that I thought looked quite reasonable. =) I copied it
> to /etc/rc.d, made it executable and addded "goldbach=YES" to rc.conf.
> Yet, nothing happens.
> The script looks like this:
>
> - ----------------------------
> #!/bin/sh
> #
> # $NetBSD: goldbach.sh,v 0.1 2003/12/23 13:20:00 tv Exp $
> #
> # PROVIDE: goldbach
> # REQUIRE: LOGIN
> # KEYWORD: shutdown
> #
> # To start goldbach at startup, copy this script to /etc/rc.d and set
> # goldbach=YES in /etc/rc.conf
>
> if [ -f /etc/rc.subr ]
> then
>         . /etc/rc.subr
> fi
>
> name="goldbach"
> rcvar="${name}"
> command="/home/krylon/bin/goldbach"
> ctl_command="/home/krylon/bin/rc.goldbach"
> required_files="/home/krylon/gold.log"
> start_cmd="$ctl_command start"
> stop_cmd="$ctl_command stop"
> restart_cmd="$ctl_command restart"
>
>
> if [ -f /etc/rc.subr ] ; then
>         load_rc_config $name
>         run_rc_command "$1"
> else
>         case $1 in
>                 start) $start_cmd
>                        ;;
>                 stop)  $stop_cmd
>                 ;;
>                 restart) $restart_cmd
>                          ;;
>                 status) $ctl_command status
>                         ;;
>         esac
> fi
> - --------------------------
>
> rc.goldbach is a perl-script that controls goldbach, takes care of
> log-rotation (with the new algorithms, logs grow really fast, hundreds
> of megabytes per hour) and so on. When run from the command-line, it
> runs perfectly.
> Yet, goldbach is not started at system-startup...
> Did I do something wrong with the sh-script?
> As I said, the perl-script runs perfectly when run manually. I also call
> it from cron periodically, and it works there, too.
> ;-? What am I doing wrong?
>
> Thank you very much,
>
> Kind Regards,
>
> Benjamin
>
> - --
> Benjamin Walkenhorst
> eMail: krylon@gmx.net
> http://www.krylon.de
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (NetBSD)
>
> iD8DBQE/9D11/JWwsvZUqOwRAjG/AJ9B/t94MgbMYY1AoLCfMw/LReItPACgn01i
> oYpqOl2ABu4ppT86dpuVL6g=
> =Jc8D
> -----END PGP SIGNATURE-----
>