Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Nov 1998 21:19:19 +0000
From:      Nik Clayton <nik@nothing-going-on.demon.co.uk>
To:        Nik Clayton <nik@nothing-going-on.demon.co.uk>, hackers@FreeBSD.ORG
Subject:   Re: /etc/rc.d, and changes to /etc/rc?
Message-ID:  <19981118211919.10512@nothing-going-on.org>
In-Reply-To: <19981117210138.03327@nothing-going-on.org>; from Nik Clayton on Tue, Nov 17, 1998 at 09:01:38PM %2B0000
References:  <19981115235938.22908@nothing-going-on.org> <19981117210138.03327@nothing-going-on.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--lL+5n6rz5pIUxbDc
Content-Type: text/plain; charset=us-ascii

On Tue, Nov 17, 1998 at 09:01:38PM +0000, Nik Clayton wrote:
> If there are no more comments by Thursday I'll take it as tacit agreement,
> and go ahead. I'll do sendmail first.

Well, that's certainly one way to kick off a discussion.

Attached is a quick implementation of what I've been talking about. All
it does is provide startup scripts for inetd and an NFS server. This is 
a minimal implementation, provided for people to kick around.

To use these;

 1. mkdir /etc/rc.d

 2. Copy inetd.sh and nfs_server.sh (attached) to this directory. Make
    them executable.

 3. Edit /etc/rc and change the line that starts inetd to

        /etc/rc.d/inet.sh start

    (keep it wrapped in the test for ${inetd_enable} though)

 4. Edit /etc/rc.network. Find the block that tests for ${nfs_server_enable}
    and replace the contents of the block with

        /etc/rc.d/nfs_server.sh start

You can then start playing around. 

inetd.sh is how I expect most of these scripts to look. There's only one
daemon to start, which makes the surrounding code look somewhat extraneous
for all it's got to do.

Hopefully, nfs_server.sh makes my point a little more clearly. As you can
see there are a number of daemons that need to be started and/or stopped for
NFS serving. 

Suppose you've changed the NFS server flags in /etc/rc.conf, and want to
test that they work. 

Currently, you would do this by;

  - Reading /etc/rc.network to determine what daemons have been started.

  - Kill them. In some cases killall or kill will be sufficient. In others
    you need to stop programs in a specific order -- for these programs
    you have to make sure you know what that order is.

  - Restart them. Either by typing/cutting-pasting the commands from
    /etc/rc.network, plugging in the same values as you have put in 
    /etc/rc.conf. Or by crafting together a small shell script to pull
    in the values from /etc/rc.conf and starting the daemons in this 
    script.

  - Even now, you're not 100% guaranteed that what you've just done 
    mirrors what will be run the next time the system boots.

With this (new) approach, you just

    # /etc/rc.d/nfs_server restart

and watch as it kills the daemons, and restarts them with whatever 
values you currently have in /etc/rc.conf. It does it consistently,
correctly, and will happen the same way when the system boots.

To answer some of the points raised by other people;

Yes, this will make booting slower, and push up the PID of the first
login process run. So what? The slow down is imperceptible, and I would
expect it to be on the order of 3 or 4 seconds maximum if this approach
is fully adopted (and even then your disks would need to be pretty slow
for it to be that drastic). You waste more time than that checking that 
you've killed all the daemons and restarted them properly, so over time 
it's probably a net win.

Yes, it's different from how things have been done before. So what? 
It's not change for change's sake, it brings the benefits I've outlined
above and in earlier messages which (IMHO) make the change worthwhile.

Yes, it will confuse old-hand BSD administrators. So did the introduction
of /etc/rc.conf (nee' /etc/sysconfig). Perhaps confuse is the wrong 
word. It might disorient them slightly, but only briefly. All that's
happened is that the content of some of the /rc/rc.* files has been
moved out into other files in another directory. init hasn't changed,
the order hasn't changed, the mechanism for deciding what order to run
things in hasn't changed.

N
-- 
	    C.R.F. Consulting -- we're run to make me richer. . .

--lL+5n6rz5pIUxbDc
Content-Type: application/x-sh
Content-Disposition: attachment; filename="inetd.sh"

#!/bin/sh
#
# Start/stop/restart inetd
#
# $Id$
#

basename=`basename $0`

# Allow ourself to be overridden by local changes
if [ -x /usr/local/etc/rc.d/${basename} ]; then
	exec /usr/local/etc/rc.d/${basename}
fi

# If there is a global configuration file, suck it in
if [ -r /etc/rc.conf ]; then
	. /etc/rc.conf
fi

# Check for first parameter
if [ $1x = x ]; then
	echo ${basename}: No argument provided
	exit 1
fi

case $1 in
start)
	inetd ${inetd_flags} && echo -n ' inetd'
	;;
stop)
	killall inetd
	;;
restart)
	$0 stop && $0 start
	;;
*)
	echo ${basename}: First argument must be one of start, stop, restart
	exit 1
	;;
esac

exit 0

--lL+5n6rz5pIUxbDc
Content-Type: application/x-sh
Content-Disposition: attachment; filename="nfs_server.sh"

#!/bin/sh
#
# Start/stop/restart nfs servers
#
# $Id$
#

basename=`basename $0`

# Allow ourself to be overridden by local changes
if [ -x /usr/local/etc/rc.d/${basename} ]; then
	exec /usr/local/etc/rc.d/${basename}
fi

# If there is a global configuration file, suck it in
if [ -r /etc/rc.conf ]; then
	. /etc/rc.conf
fi

# Check for first parameter
if [ $1x = x ]; then
	echo ${basename}: No argument provided
	exit 1
fi

case $1 in
start)
	if [ ! -r /etc/exports ]; then
		echo ${basename}: /etc/exports not found, aborting
		exit 1
	fi
	if [ "X${weak_mountd_authentication}" = X"YES" ]; then
		mountd_flags="-n"
	fi
	/sbin/mountd ${mountd_flags} && echo -n ' mountd'
	if [ "X${nfs_reserved_port_only}" = X"YES" ]; then
		echo -n ' nfsprivport=YES'
		sysctl -w vfs.nfs.nfs_privport=1 > /dev/null 2>&1
	fi
	nfsd ${nfs_server_flags} && echo -n ' nfsd'
	if [ "X${rpc_lockd_enable}" = X"YES" ]; then
		/usr/sbin/rpc.lockd && echo -n ' rpc.lockd'
	fi
	if [ "X${rpc_statd_enable}" = X"YES" ]; then
		/usr/sbin/rpc.statd && echo -n ' rpc.statd'
	fi
	;;
stop)
	# Need to kill everything started by 'start'. Can't test the
	# ${*_enable} variables, since they might have changed since
	# 'start' was run.
	killall rpc.statd
	killall rpc.lockd
	killall nfsd
	kill `cat /var/run/mountd.pid`
	;;
restart)
	$0 stop && $0 start
	;;
*)
	echo ${basename}: First argument must be one of start, stop, restart
	exit 1
	;;
esac

exit 0

--lL+5n6rz5pIUxbDc--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981118211919.10512>