Subject: Re: starting package with /etc/rc.d
To: Jeremy C. Reed <reed@reedmedia.net>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-pkg
Date: 11/25/2005 15:29:28
On Wed, 23 Nov 2005, Jeremy C. Reed wrote:

> On Wed, 23 Nov 2005, Iain Hibbert wrote:
>
> > -c specify a login class - I know nothing about this, and have no
> > /etc/login.conf file, is that likely to be important? (how does that work?
> > the man page seems to think it should have an argument, is that the shell
> > command?)
>
> Yes it is the shell command. -c with su if used after user name (nullmail)
> ends up being passed to the shell. So read the shell's man page for -c instead
> of su's man page.
>
> I think the reason that the -x was ignored in your earlier test was because
> the sh-bang line was never used (see run_rc_script function in /etc/rc.subr).

ok, done some more investigating..

> Maybe you need to add the -x to /etc/rc itself.

I am definitely running something, because 'Starting nullmailer' is
printed to the console and I fiddled in /etc/rc.subr and got it to print
the command it was about to execute just before it did so - below is the
/etc/rc.d/nullmailer file and it looks ok, but I had another thought about
the command_args - nullmailer-send does not have any kind of logging
function so its piped through logger - I can't find this done by any other
programs, would this be the right way to go about it?

I wonder if something is getting lost, in particular the & or | characters
on their way through variables (this sort of thing always gets me)..
though I can't see what the difference is between

iain

#!/bin/sh
#
# $NetBSD: nullmailer.sh,v 1.2 2005/08/20 02:20:45 schmonz Exp $
#
# PROVIDE: mail
# REQUIRE: LOGIN

$_rc_subr_loaded . /etc/rc.subr

name="nullmailer"
rcvar=${name}
required_files="/usr/pkg/etc/nullmailer/remotes"
required_files="${required_files} /var/spool/nullmailer/trigger"
required_dirs="/var/spool/nullmailer/queue /var/spool/nullmailer/tmp"
command="/usr/pkg/libexec/nullmailer/nullmailer-send"
command_args="2>&1 | logger -t nullmailer -p mail.info &"

nullmailer_user="nullmail"
nullmailer_group="nullmail"

load_rc_config $name
run_rc_command "$1"