Subject: Re: "fixing" the network shutdown problems with rc.d
To: None <tech-userlevel@NetBSD.ORG>
From: David Brownlee <abs@NetBSD.ORG>
List: tech-userlevel
Date: 04/11/2000 10:09:54
	It works well for NetBSD scripts, but what about people dropping
	in third party rc.d scripts?
	
	One not entirely clean option might be to set 'RC_SHUTDOWN' in
	the environment and run with a "stop" arg, and the scripts can
	key off that.

	No perfect solution :(

	I'm probably inclined to keep "shutdown" as its cleaner, but we
	need to be aware of the third part issue...


		David/absolute

On Tue, 11 Apr 2000, Simon Burge wrote:

> Greg A. Woods wrote:
> 
> > [ On Tuesday, April 11, 2000 at 10:37:14 (+1000), Robert Elz wrote: ]
> > > Subject: Re: "fixing" the network shutdown problems with rc.d 
> > >
> > > Maybe instead of rc.shutdown running the scripts with a "stop" arg
> > > it could run them with "shutdown", then just the few scripts
> > > (databases and the link) that actually need to do something at
> > > system shutdown time can have a "shutdown" case, and all the rest
> > > can just no nothing...
> > 
> > Yes, I like this idea best.  It's closest to the previous behaviour
> > too (i.e. with the previous incantation of /etc/rc.shutdown[.local]).
> 
> <AOL>Me too!</AOL>.  So how does this look then?  I've changed xdm
> because it was in the old /etc/rc.shutdown, and it's also an example
> of how to do it.  Whether or not it should be smarter like the old
> /etc/rc.shutdown is something we can debate afterwards :)
> 
> Simon.
> --
> Index: rc.shutdown
> ===================================================================
> RCS file: /cvsroot/basesrc/etc/rc.shutdown,v
> retrieving revision 1.3
> diff -p -u -r1.3 rc.shutdown
> --- rc.shutdown	2000/03/10 13:17:25	1.3
> +++ rc.shutdown	2000/04/11 06:19:28
> @@ -31,7 +31,7 @@ done
>  files=$nfiles
>  
>  for i in $files; do
> -	run_rc_script $i stop
> +	run_rc_script $i shutdown
>  done
>  
>  date
> Index: rc.subr
> ===================================================================
> RCS file: /cvsroot/basesrc/etc/rc.subr,v
> retrieving revision 1.11
> diff -p -u -r1.11 rc.subr
> --- rc.subr	2000/03/10 11:39:27	1.11
> +++ rc.subr	2000/04/11 06:19:28
> @@ -155,8 +155,8 @@ check_process()
>  
>  #
>  # run_rc_command arg [supported_args]
> -#	Scan supported_args (which has "start stop restart rcvar status"
> -#	prepended) for arg.
> +#	Scan supported_args (which has "start stop restart rcvar status
> +#	shutdown" prepended) for arg.
>  #	If there's a match, run ${arg}_cmd or the default command (see below).
>  #
>  #	If arg has a given prefix, then:
> @@ -216,6 +216,7 @@ check_process()
>  #			else
>  #				kill $sig_stop `check_process $command`
>  #			$sig_stop defaults to TERM.
> +#	shutdown	Nothing.
>  #	reload		As stop, except use $sig_reload instead.
>  #			$sig_reload defaults to HUP.
>  #	restart		Run `stop' then `start'.
> @@ -244,7 +245,7 @@ run_rc_command()
>  		;;
>  	esac
>  
> -	_keywords="start stop restart rcvar $*"
> +	_keywords="start stop restart rcvar shutdown $*"
>  	_pidcmd=
>  	if [ -z "$_rc_fast_run" ]; then
>  		if [ -n "$pidfile" ]; then
> @@ -346,6 +347,10 @@ run_rc_command()
>  			eval $_precmd || return 1
>  			echo "Stopping ${name}."
>  			kill -${sig_stop:-TERM} $_pid
> +			;;
> +
> +		shutdown)
> +			# ignored
>  			;;
>  
>  		reload)
> Index: rc.d/xdm
> ===================================================================
> RCS file: /cvsroot/basesrc/etc/rc.d/xdm,v
> retrieving revision 1.2
> diff -p -u -r1.2 xdm
> --- xdm	2000/03/13 04:04:10	1.2
> +++ xdm	2000/04/11 06:19:28
> @@ -14,4 +14,11 @@ command="/usr/X11R6/bin/${name}"
>  pidfile="/var/run/${name}.pid"
>  required_files="/usr/X11R6/lib/X11/xdm/xdm-config"
>  
> +shutdown_cmd="xdm_shutdown"
> +
> +xdm_shutdown()
> +{
> +	run_rc_command stop
> +}
> +
>  run_rc_command "$1" "reload"
>