Why would you get burned for that? That was an excellent answer! I
guess its not the OpenBSD way but that's ok, your system is your
system and it should be able to work for you, not you work for it ;)

So what drawbacks have you had with this?

Thanks,
- Jake


On 9/18/07, Edwards, David  (JTS) <[EMAIL PROTECTED]> wrote:
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > On Behalf Of Jake Conk
> > Sent: Tuesday, 18 September 2007 6:36 PM
> > To: misc@openbsd.org
> > Subject: Simple startup daemon's on boot question?
> >
> > Hello,
> >
> > Simple noob question... I've installed a few packages (ie nrpe2 and
> > openvpn) that on other systems like Linux and even BSD based systems
> > such as FreeBSD provide means of a rc script which can start and stop
> > the service and you can configure this script to be executed on boot.
> >
> > After installing these packages on OpenBSD I've listed the package
> > contents and don't notice any equivalent files that would do this. Are
> > we supposed to write our own startup scripts and place them in
> > /etc/rc.local to be executed when the system boots? Does OpenBSD not
> > use rc scripts that start/stop/restart/ and status applications?
>
> I'm probably going to get burnt for this but :-)
>
> Put this in /etc/rc.conf.local:
> ---
> local_startup_dir=/etc/rc.d
> ---
>
> Put this in /etc/rc.local
> ------
> . /etc/rc.conf.local
> for f in ${local_startup_dir}/*.sh ; do
>   if [ -x $f ]; then
>     logger -p daemon.notice -t rc.local "Starting $f"
>     $f start
>     sleep 1
>   fi
> done
> -------
>
> Create the /etc/rc.d directory and plonk start/stop
> executable scripts in there (should all end in .sh).
>
> To turn a script off temporarily, make it non-executable
> or change .sh to .sh.off or something.
>
> Use numbers (01, 02 etc) in the front of the filename
> to determine which scripts run first..
>
> I use a template script like this:
> ----------
> #!/bin/sh
> #
> # To start the pf-syslog log catcher
> #
> what=syslog-ng
> where=/usr/local/sbin
> args=""
>
> KillProc()
> {
>   proc=$1
>   sig=$2
>
>   pid=`ps -xo pid,args | grep -v grep | grep "$proc" | awk '{print $1}'`
>
>   if [ "X$pid" != "X" ]; then
>      kill -$sig $pid
>      echo $pid
>
>   else
>      echo "Nothing to kill"
>   fi
> }
>
> case "$1" in
> "start")
>         if [ -f $where/$what ]; then
>             echo "Starting $what"
>             /$where/$what $args
>         fi
>     ;;
> "stop")
>         echo "Stopping $what"
>         KillProc $what TERM
>         exit 0
>     ;;
> *)
>     echo "$0: Usage $0 start||stop "
>     ;;
> esac
>
> exit 0
> ------------
>
> I have found over the years that this approach has a
> lot of benefits and few drawbacks.
>
> Introducing fresh admin staff to BSD is a lot easier
> if they don't have to do the "grep for PID"
> "kill -TERM PID" thing to stop a running "service".
> And of course "look in /etc/rc.local",
> work out how to start it then start it..
>
> Believe it or not, I've had people reboot servers in
> order to stop and start a service <sigh>..
>
> ciao
> dave
> ---
> Dave Edwards

Reply via email to