Subject: Re: rc.d/* help - writing my own script
To: None <netbsd-help@netbsd.org>
From: Jukka Salmi <j+nbsd@2006.salmi.ch>
List: netbsd-help
Date: 02/03/2006 14:46:04
Jan Danielsson --> netbsd-help (2006-02-03 14:19:54 +0100):
> Hello all,
>
> I have written a small python script which gathers statistics and
> stores it in a database. Now I would like to launch (and stop) it using
> the rc.d/ system.
>
> This is what I tried to use (without knowing much about how it all
> works):
>
> -------------------------------
> #!/bin/sh
>
> # PROVIDE: pflogger
> # REQUIRE: pf pgsql
> # KEYWORD: shutdown
>
> $_rc_subr_loaded . /etc/rc.subr
>
> name="pflogger"
> rcvar=$name
> command="/usr/local/bin/${name}.py"
> pidfile="/var/run/${name}.pid"
>
> load_rc_config $name
> run_rc_command "$1"
> -------------------------------
>
> Problem is, this doesn't launch the script in a background process, i.e.:
>
> # /usr/local/bin/pflogger.py &
>
> How do I accomplish this, and how so I make it stoppable via
> "/etc/rc.d/pflogger stop" ?
To start the script in the background, set
command_args='&'
in your rc script. To be able to shut down the process, just add
command_interpreter='/path/to/your/python/binary'
to the rc script; `/etc/rc.d/your-script stop' should work now.
HTH, Jukka
--
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~