Subject: Writing my own script for /etc/rc.d
To: None <netbsd-users@netbsd.org>
From: Benjamin Walkenhorst <krylon@gmx.net>
List: netbsd-users
Date: 01/01/2004 16:31:49
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello everybody,

When I started learning C (about three and a half years ago), one of the=20
programs I wrote was for checking the Goldbach-assumption. It says that=20
for every even number >=3D 4 can be shown to be the sum of two prime=20
numbers.
As far as I know Goldbach so far has neither been shown to be right or=20
wrong. And the only way to do so I could think of - being no=20
mathematician - is to check every even number >=3D 4.
More than three years later, my C is still very poor. =3D) But recently I=
=20
started to care again and rewrote the program.
I rewrote it again, when I got hold of a copy of "The C Programming=20
Language 2nd edition". I even rewrote it another time, using a faster=20
algorithm.

Now I would like to run the program on my NetBSD-box (which I use as a=20
small home server and ipnat-gateway). In fact I have done so for quite=20
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=20
rc.conf. So I looked up what other scripts in /etc/rc.d look like and=20
wrote a script that I thought looked quite reasonable. =3D) I copied it=20
to /etc/rc.d, made it executable and addded "goldbach=3DYES" 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=3DYES in /etc/rc.conf

if [ -f /etc/rc.subr ]
then
        . /etc/rc.subr
fi

name=3D"goldbach"
rcvar=3D"${name}"
command=3D"/home/krylon/bin/goldbach"
ctl_command=3D"/home/krylon/bin/rc.goldbach"
required_files=3D"/home/krylon/gold.log"
start_cmd=3D"$ctl_command start"
stop_cmd=3D"$ctl_command stop"
restart_cmd=3D"$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=20
log-rotation (with the new algorithms, logs grow really fast, hundreds=20
of megabytes per hour) and so on. When run from the command-line, it=20
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=20
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=3D
=3DJc8D
-----END PGP SIGNATURE-----