head	1.10;
access;
symbols
	netbsd-11-0-RC4:1.10
	netbsd-11-0-RC3:1.10
	netbsd-11-0-RC2:1.10
	netbsd-11-0-RC1:1.10
	perseant-exfatfs-base-20250801:1.10
	netbsd-11:1.10.0.2
	netbsd-11-base:1.10
	netbsd-10-1-RELEASE:1.9
	perseant-exfatfs-base-20240630:1.9
	perseant-exfatfs:1.9.0.46
	perseant-exfatfs-base:1.9
	netbsd-8-3-RELEASE:1.9
	netbsd-9-4-RELEASE:1.9
	netbsd-10-0-RELEASE:1.9
	netbsd-10-0-RC6:1.9
	netbsd-10-0-RC5:1.9
	netbsd-10-0-RC4:1.9
	netbsd-10-0-RC3:1.9
	netbsd-10-0-RC2:1.9
	netbsd-10-0-RC1:1.9
	netbsd-10:1.9.0.44
	netbsd-10-base:1.9
	netbsd-9-3-RELEASE:1.9
	cjep_sun2x-base1:1.9
	cjep_sun2x:1.9.0.42
	cjep_sun2x-base:1.9
	cjep_staticlib_x-base1:1.9
	netbsd-9-2-RELEASE:1.9
	cjep_staticlib_x:1.9.0.40
	cjep_staticlib_x-base:1.9
	netbsd-9-1-RELEASE:1.9
	phil-wifi-20200421:1.9
	phil-wifi-20200411:1.9
	is-mlppp:1.9.0.38
	is-mlppp-base:1.9
	phil-wifi-20200406:1.9
	netbsd-8-2-RELEASE:1.9
	netbsd-9-0-RELEASE:1.9
	netbsd-9-0-RC2:1.9
	netbsd-9-0-RC1:1.9
	phil-wifi-20191119:1.9
	netbsd-9:1.9.0.36
	netbsd-9-base:1.9
	phil-wifi-20190609:1.9
	netbsd-8-1-RELEASE:1.9
	netbsd-8-1-RC1:1.9
	pgoyette-compat-merge-20190127:1.9
	pgoyette-compat-20190127:1.9
	pgoyette-compat-20190118:1.9
	pgoyette-compat-1226:1.9
	pgoyette-compat-1126:1.9
	pgoyette-compat-1020:1.9
	pgoyette-compat-0930:1.9
	pgoyette-compat-0906:1.9
	netbsd-7-2-RELEASE:1.9
	pgoyette-compat-0728:1.9
	netbsd-8-0-RELEASE:1.9
	phil-wifi:1.9.0.34
	phil-wifi-base:1.9
	pgoyette-compat-0625:1.9
	netbsd-8-0-RC2:1.9
	pgoyette-compat-0521:1.9
	pgoyette-compat-0502:1.9
	pgoyette-compat-0422:1.9
	netbsd-8-0-RC1:1.9
	pgoyette-compat-0415:1.9
	pgoyette-compat-0407:1.9
	pgoyette-compat-0330:1.9
	pgoyette-compat-0322:1.9
	pgoyette-compat-0315:1.9
	netbsd-7-1-2-RELEASE:1.9
	pgoyette-compat:1.9.0.32
	pgoyette-compat-base:1.9
	netbsd-7-1-1-RELEASE:1.9
	matt-nb8-mediatek:1.9.0.30
	matt-nb8-mediatek-base:1.9
	perseant-stdc-iso10646:1.9.0.28
	perseant-stdc-iso10646-base:1.9
	netbsd-8:1.9.0.26
	netbsd-8-base:1.9
	prg-localcount2-base3:1.9
	prg-localcount2-base2:1.9
	prg-localcount2-base1:1.9
	prg-localcount2:1.9.0.24
	prg-localcount2-base:1.9
	pgoyette-localcount-20170426:1.9
	bouyer-socketcan-base1:1.9
	pgoyette-localcount-20170320:1.9
	netbsd-7-1:1.9.0.22
	netbsd-7-1-RELEASE:1.9
	netbsd-7-1-RC2:1.9
	netbsd-7-nhusb-base-20170116:1.9
	bouyer-socketcan:1.9.0.20
	bouyer-socketcan-base:1.9
	pgoyette-localcount-20170107:1.9
	netbsd-7-1-RC1:1.9
	pgoyette-localcount-20161104:1.9
	netbsd-7-0-2-RELEASE:1.9
	localcount-20160914:1.9
	netbsd-7-nhusb:1.9.0.18
	netbsd-7-nhusb-base:1.9
	pgoyette-localcount-20160806:1.9
	pgoyette-localcount-20160726:1.9
	pgoyette-localcount:1.9.0.16
	pgoyette-localcount-base:1.9
	netbsd-7-0-1-RELEASE:1.9
	netbsd-7-0:1.9.0.14
	netbsd-7-0-RELEASE:1.9
	netbsd-7-0-RC3:1.9
	netbsd-7-0-RC2:1.9
	netbsd-7-0-RC1:1.9
	netbsd-5-2-3-RELEASE:1.8
	netbsd-5-1-5-RELEASE:1.8
	netbsd-6-0-6-RELEASE:1.8.60.1
	netbsd-6-1-5-RELEASE:1.8.60.1
	netbsd-7:1.9.0.12
	netbsd-7-base:1.9
	yamt-pagecache-base9:1.9
	yamt-pagecache-tag8:1.8.58.1
	netbsd-6-1-4-RELEASE:1.8.60.1
	netbsd-6-0-5-RELEASE:1.8.60.1
	tls-earlyentropy:1.9.0.10
	tls-earlyentropy-base:1.9
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.9
	riastradh-drm2-base3:1.9
	netbsd-6-1-3-RELEASE:1.8.60.1
	netbsd-6-0-4-RELEASE:1.8.60.1
	netbsd-5-2-2-RELEASE:1.8
	netbsd-5-1-4-RELEASE:1.8
	netbsd-6-1-2-RELEASE:1.8.60.1
	netbsd-6-0-3-RELEASE:1.8.60.1
	netbsd-5-2-1-RELEASE:1.8
	netbsd-5-1-3-RELEASE:1.8
	netbsd-6-1-1-RELEASE:1.8.60.1
	riastradh-drm2-base2:1.9
	riastradh-drm2-base1:1.9
	riastradh-drm2:1.9.0.4
	riastradh-drm2-base:1.9
	netbsd-6-1:1.8.60.1.0.6
	netbsd-6-0-2-RELEASE:1.8.60.1
	netbsd-6-1-RELEASE:1.8.60.1
	khorben-n900:1.9.0.8
	netbsd-6-1-RC4:1.8.60.1
	netbsd-6-1-RC3:1.8.60.1
	agc-symver:1.9.0.6
	agc-symver-base:1.9
	netbsd-6-1-RC2:1.8.60.1
	netbsd-6-1-RC1:1.8.60.1
	yamt-pagecache-base8:1.9
	netbsd-5-2:1.8.0.62
	netbsd-6-0-1-RELEASE:1.8.60.1
	yamt-pagecache-base7:1.9
	netbsd-5-2-RELEASE:1.8
	netbsd-5-2-RC1:1.8
	matt-nb6-plus-nbase:1.8.60.1
	yamt-pagecache-base6:1.9
	netbsd-6-0:1.8.60.1.0.4
	netbsd-6-0-RELEASE:1.8.60.1
	netbsd-6-0-RC2:1.8.60.1
	tls-maxphys:1.9.0.2
	tls-maxphys-base:1.9
	matt-nb6-plus:1.8.60.1.0.2
	matt-nb6-plus-base:1.8.60.1
	netbsd-6-0-RC1:1.8.60.1
	yamt-pagecache-base5:1.8
	yamt-pagecache-base4:1.8
	netbsd-6:1.8.0.60
	netbsd-6-base:1.8
	netbsd-5-1-2-RELEASE:1.8
	netbsd-5-1-1-RELEASE:1.8
	yamt-pagecache-base3:1.8
	yamt-pagecache-base2:1.8
	yamt-pagecache:1.8.0.58
	yamt-pagecache-base:1.8
	cherry-xenmp:1.8.0.56
	cherry-xenmp-base:1.8
	bouyer-quota2-nbase:1.8
	bouyer-quota2:1.8.0.54
	bouyer-quota2-base:1.8
	matt-mips64-premerge-20101231:1.8
	matt-nb5-mips64-premerge-20101231:1.8
	matt-nb5-pq3:1.8.0.52
	matt-nb5-pq3-base:1.8
	netbsd-5-1:1.8.0.50
	netbsd-5-1-RELEASE:1.8
	netbsd-5-1-RC4:1.8
	matt-nb5-mips64-k15:1.8
	netbsd-5-1-RC3:1.8
	netbsd-5-1-RC2:1.8
	netbsd-5-1-RC1:1.8
	netbsd-5-0-2-RELEASE:1.8
	matt-nb5-mips64-premerge-20091211:1.8
	matt-premerge-20091211:1.8
	matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.8
	matt-nb4-mips64-k7-u2a-k9b:1.8
	matt-nb5-mips64-u1-k1-k5:1.8
	matt-nb5-mips64:1.8.0.48
	netbsd-5-0-1-RELEASE:1.8
	jym-xensuspend-nbase:1.8
	netbsd-5-0:1.8.0.46
	netbsd-5-0-RELEASE:1.8
	netbsd-5-0-RC4:1.8
	netbsd-5-0-RC3:1.8
	netbsd-5-0-RC2:1.8
	jym-xensuspend:1.8.0.44
	jym-xensuspend-base:1.8
	netbsd-5-0-RC1:1.8
	mjf-devfs2-base2:1.8
	netbsd-5:1.8.0.42
	netbsd-5-base:1.8
	matt-mips64-base2:1.8
	matt-mips64:1.8.0.40
	netbsd-4-0-1-RELEASE:1.8
	wrstuden-revivesa-base-3:1.8
	wrstuden-revivesa-base-2:1.8
	wrstuden-fixsa-newbase:1.8
	wrstuden-revivesa-base-1:1.8
	yamt-pf42-base4:1.8
	yamt-pf42-base3:1.8
	hpcarm-cleanup-nbase:1.8
	yamt-pf42-baseX:1.8
	yamt-pf42-base2:1.8
	wrstuden-revivesa:1.8.0.38
	wrstuden-revivesa-base:1.8
	yamt-pf42:1.8.0.36
	yamt-pf42-base:1.8
	mjf-devfs2:1.8.0.34
	mjf-devfs2-base:1.8
	keiichi-mipv6:1.8.0.32
	keiichi-mipv6-base:1.8
	mjf-devfs:1.8.0.30
	mjf-devfs-base:1.8
	matt-armv6-nbase:1.8
	matt-armv6-prevmlocking:1.8
	wrstuden-fixsa-base-1:1.8
	netbsd-4-0:1.8.0.28
	netbsd-4-0-RELEASE:1.8
	cube-autoconf:1.8.0.26
	cube-autoconf-base:1.8
	netbsd-4-0-RC5:1.8
	netbsd-4-0-RC4:1.8
	netbsd-4-0-RC3:1.8
	netbsd-4-0-RC2:1.8
	netbsd-4-0-RC1:1.8
	matt-armv6:1.8.0.24
	matt-armv6-base:1.8
	matt-mips64-base:1.8
	hpcarm-cleanup:1.8.0.22
	hpcarm-cleanup-base:1.8
	netbsd-3-1-1-RELEASE:1.8
	netbsd-3-0-3-RELEASE:1.8
	wrstuden-fixsa:1.8.0.20
	wrstuden-fixsa-base:1.8
	abandoned-netbsd-4-base:1.8
	abandoned-netbsd-4:1.8.0.14
	netbsd-3-1:1.8.0.16
	netbsd-3-1-RELEASE:1.8
	netbsd-3-0-2-RELEASE:1.8
	netbsd-3-1-RC4:1.8
	netbsd-3-1-RC3:1.8
	netbsd-3-1-RC2:1.8
	netbsd-3-1-RC1:1.8
	netbsd-4:1.8.0.18
	netbsd-4-base:1.8
	netbsd-3-0-1-RELEASE:1.8
	netbsd-3-0:1.8.0.12
	netbsd-3-0-RELEASE:1.8
	netbsd-3-0-RC6:1.8
	netbsd-3-0-RC5:1.8
	netbsd-3-0-RC4:1.8
	netbsd-3-0-RC3:1.8
	netbsd-3-0-RC2:1.8
	netbsd-3-0-RC1:1.8
	netbsd-2-0-3-RELEASE:1.8
	netbsd-2-1:1.8.0.10
	netbsd-2-1-RELEASE:1.8
	netbsd-2-1-RC6:1.8
	netbsd-2-1-RC5:1.8
	netbsd-2-1-RC4:1.8
	netbsd-2-1-RC3:1.8
	netbsd-2-1-RC2:1.8
	netbsd-2-1-RC1:1.8
	netbsd-2-0-2-RELEASE:1.8
	netbsd-3:1.8.0.8
	netbsd-3-base:1.8
	netbsd-2-0-1-RELEASE:1.8
	netbsd-2:1.8.0.6
	netbsd-2-base:1.8
	netbsd-2-0-RELEASE:1.8
	netbsd-2-0-RC5:1.8
	netbsd-2-0-RC4:1.8
	netbsd-2-0-RC3:1.8
	netbsd-2-0-RC2:1.8
	netbsd-2-0-RC1:1.8
	netbsd-2-0:1.8.0.4
	netbsd-2-0-base:1.8
	netbsd-1-6-PATCH002-RELEASE:1.8
	netbsd-1-6-PATCH002:1.8
	netbsd-1-6-PATCH002-RC4:1.8
	netbsd-1-6-PATCH002-RC3:1.8
	netbsd-1-6-PATCH002-RC2:1.8
	netbsd-1-6-PATCH002-RC1:1.8
	netbsd-1-6-PATCH001:1.8
	netbsd-1-6-PATCH001-RELEASE:1.8
	netbsd-1-6-PATCH001-RC3:1.8
	netbsd-1-6-PATCH001-RC2:1.8
	netbsd-1-6-PATCH001-RC1:1.8
	fvdl_fs64_base:1.8
	netbsd-1-6-RELEASE:1.8
	netbsd-1-6-RC3:1.8
	netbsd-1-6-RC2:1.8
	netbsd-1-6-RC1:1.8
	netbsd-1-6:1.8.0.2
	netbsd-1-6-base:1.8
	netbsd-1-5-PATCH003:1.3.4.1
	netbsd-1-5-PATCH002:1.3.4.1
	netbsd-1-5-PATCH001:1.3.4.1
	netbsd-1-5-RELEASE:1.3.4.1
	netbsd-1-5-BETA2:1.3.4.1
	netbsd-1-5-BETA:1.3.4.1
	netbsd-1-4-PATCH003:1.2
	netbsd-1-5-ALPHA2:1.3.4.1
	netbsd-1-5:1.3.0.4
	netbsd-1-5-base:1.3
	minoura-xpg4dl:1.3.0.2
	minoura-xpg4dl-base:1.3
	netbsd-1-4-PATCH002:1.2
	wrstuden-devbsize-19991221:1.2
	wrstuden-devbsize:1.2.0.6
	wrstuden-devbsize-base:1.2
	comdex-fall-1999:1.2.0.4
	comdex-fall-1999-base:1.2
	netbsd-1-4-PATCH001:1.2
	netbsd-1-4-RELEASE:1.2
	netbsd-1-4:1.2.0.2
	netbsd-1-4-base:1.2;
locks; strict;
comment	@# @;


1.10
date	2024.12.07.18.45.20;	author martin;	state Exp;
branches;
next	1.9;
commitid	PRR8nimlYCbEgBAF;

1.9
date	2012.06.25.07.22.45;	author jnemeth;	state Exp;
branches
	1.9.46.1;
next	1.8;

1.8
date	2002.05.19.01.01.33;	author lukem;	state Exp;
branches
	1.8.58.1
	1.8.60.1;
next	1.7;

1.7
date	2001.11.19.03.19.28;	author lukem;	state Exp;
branches;
next	1.6;

1.6
date	2001.06.16.04.09.19;	author lukem;	state Exp;
branches;
next	1.5;

1.5
date	2000.12.15.00.00.09;	author lukem;	state Exp;
branches;
next	1.4;

1.4
date	2000.07.17.15.23.28;	author lukem;	state Exp;
branches;
next	1.3;

1.3
date	2000.03.10.13.17.25;	author lukem;	state Exp;
branches
	1.3.4.1;
next	1.2;

1.2
date	99.01.18.20.41.54;	author tron;	state Exp;
branches;
next	1.1;

1.1
date	98.10.29.20.24.57;	author bad;	state Exp;
branches;
next	;

1.9.46.1
date	2025.08.02.05.20.42;	author perseant;	state Exp;
branches;
next	;
commitid	23j6GFaDws3O875G;

1.8.58.1
date	2012.10.30.18.48.58;	author yamt;	state Exp;
branches;
next	;

1.8.60.1
date	2012.07.02.21.20.52;	author jdc;	state Exp;
branches;
next	;

1.3.4.1
date	2000.08.09.18.39.38;	author lukem;	state Exp;
branches;
next	;


desc
@@


1.10
log
@Now that shutdown(8) provides info why we are shutting down to the
shutdown scripts, add an optional local hook /etc/rc.shutdown.final
called last in the shutdown sequence and passed the reason.

This allows for easy local integration of special UPS commands before
we power down (e.g. to restart the UPS after some delay in case
utility power is restored too early and the machine has already powered
down and will only restart when it's power input is restored after being
off for a few seconds)
@
text
@#!/bin/sh
#
# $NetBSD: rc.shutdown,v 1.9 2012/06/25 07:22:45 jnemeth Exp $
#
# rc.shutdown --
#	Run the scripts in /etc/rc.d with reverse rcorder.

#	System shutdown script run by shutdown(8) at system shutdown time.
#	Note that halt(8) and reboot(8) do NOT invoke this script.

export HOME=/
export PATH=/sbin:/bin:/usr/sbin:/usr/bin

. /etc/rc.subr
. /etc/rc.conf

if ! checkyesno do_rcshutdown; then
	echo "Skipping shutdown hooks."
	exit 0
fi

_rcshutdown_action="$1"
set --

stty status '^T'

#	Set shell to ignore SIGINT, but not children;
#	shell catches SIGQUIT and returns to single user.
#
trap : INT
trap "echo 'Shutdown interrupted.'; exit 1" QUIT

#	If requested, start a watchdog timer in the background which
#	will terminate rc.shutdown if rc.shutdown doesn't complete
#	within the specified time.
#
_rcshutdown_watchdog=
if [ -n "$rcshutdown_timeout" ]; then
	sleep $rcshutdown_timeout && (
	    _msg="$rcshutdown_timeout second watchdog timeout expired. Shutdown terminated."
	    logger -t rc.shutdown "$_msg"
	    echo "$_msg"
	    date
	    kill -KILL $$ >/dev/null 2>&1
	    ) &
	_rcshutdown_watchdog=$!
fi


#	Determine the shutdown order of the rc.d scripts,
#	and perform the operation
#
scripts=$(for rcd in ${rc_directories:-/etc/rc.d}; do
	test -d ${rcd} && echo ${rcd}/*; done)
files=$(rcorder -k shutdown ${rcshutdown_rcorder_flags} ${scripts})

for _rc_elem in $(reverse_list $files); do
	run_rc_script $_rc_elem stop
done

#
#	Run final local handlers (if any exist)
#
if [ -r /etc/rc.shutdown.final ]; then
	set -- "$_rcshutdown_action"
	. /etc/rc.shutdown.final
fi


#	Terminate the background watchdog timer (if it is running)
#
if [ -n "$_rcshutdown_watchdog" ]; then
	kill -TERM $_rcshutdown_watchdog >/dev/null 2>&1
fi

date
exit 0
@


1.9
log
@PR/46601 - Jim Bernard -- add support for rc_directories
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.8 2002/05/19 01:01:33 lukem Exp $
d22 3
d61 8
@


1.9.46.1
log
@Sync with HEAD
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.10 2024/12/07 18:45:20 martin Exp $
a21 3
_rcshutdown_action="$1"
set --

a57 8
#
#	Run final local handlers (if any exist)
#
if [ -r /etc/rc.shutdown.final ]; then
	set -- "$_rcshutdown_action"
	. /etc/rc.shutdown.final
fi

@


1.8
log
@Add two new rc.conf(5) variables:
    rc_rcorder_flags		extra flags to rcorder(8) in /etc/rc
    rcshutdown_rcorder_flags	extra flags to rcorder(8) in /etc/rc.shutdown

This can be used to specify extra directories to search for rc.d scripts in.
For example, adding the following to rc.conf(5):
	rc_rcorder_flags="/usr/pkg/etc/rc.d/*"
	rcshutdown_rcorder_flags="/usr/pkg/etc/rc.d/*"
will add the files in /usr/pkg/etc/rc.d to the list of files that rcorder(8)
uses to build the list of scripts to start or stop.

I proposed this functionality on tech-userlevel@@ over one month ago.
Closes the recent [misc/16888], which asked for a similar feature.
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.7 2001/11/19 03:19:28 lukem Exp $
d47 1
a47 1
#	Determine the shutdown order of the /etc/rc.d scripts,
d50 3
a52 1
files=$(rcorder -k shutdown ${rcshutdown_rcorder_flags} /etc/rc.d/*)
@


1.8.58.1
log
@sync with head
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.8 2002/05/19 01:01:33 lukem Exp $
d47 1
a47 1
#	Determine the shutdown order of the rc.d scripts,
d50 1
a50 3
scripts=$(for rcd in ${rc_directories:-/etc/rc.d}; do
	test -d ${rcd} && echo ${rcd}/*; done)
files=$(rcorder -k shutdown ${rcshutdown_rcorder_flags} ${scripts})
@


1.8.60.1
log
@Pull up revision 1.9 (requested by jnemeth in ticket #375).

PR/46601 - Jim Bernard -- add support for rc_directories
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.8 2002/05/19 01:01:33 lukem Exp $
d47 1
a47 1
#	Determine the shutdown order of the rc.d scripts,
d50 1
a50 3
scripts=$(for rcd in ${rc_directories:-/etc/rc.d}; do
	test -d ${rcd} && echo ${rcd}/*; done)
files=$(rcorder -k shutdown ${rcshutdown_rcorder_flags} ${scripts})
@


1.7
log
@use reverse_list() (from rc.subr) to reverse the list
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.6 2001/06/16 04:09:19 lukem Exp $
d50 1
a50 1
files=`rcorder -k shutdown /etc/rc.d/*`
d52 1
a52 1
for _rc_elem in `reverse_list $files`; do
@


1.6
log
@- Implement an optional global watchdog timeout for rc.shutdown, which is
  enabled by setting $rcshutdown_timeout to a number of seconds to wait for
  before terminating rc.shutdown.  This is disabled by default.
- Use symbolic names rather than numbers when defining a trap.
- Improve some comments.
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.5 2000/12/15 00:00:09 lukem Exp $
a50 5
nfiles=
for i in $files; do			# reverse order of files
	nfiles="$i $nfiles"
done
files=$nfiles
d52 2
a53 2
for i in $files; do
	run_rc_script $i stop
@


1.5
log
@- describe what rc.shutdown does, and what invokes it
- remove `.sh' suffix on script name in description
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.4 2000/07/17 15:23:28 lukem Exp $
d24 2
a25 2
#	Set shell to ignore SIGINT (2), but not children;
#	shell catches SIGQUIT (3) and returns to single user.
d27 2
a28 2
trap : 2
trap "echo 'Shutdown interrupted.'; exit 1" 3
d30 20
d51 1
d60 7
@


1.4
log
@run rcorder with `-k shutdown', so that only the scripts with a
`shutdown' keyword get run at shutdown time.
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.3 2000/03/10 13:17:25 lukem Exp $
d5 1
a5 1
# rc.shutdown.sh --
d7 3
@


1.3
log
@if checkyesno do_rcshutdown, run scripts in /etc/rc.d/* in the
reverse order returned by rcorder
@
text
@d3 1
a3 1
# $NetBSD$
d27 1
a27 1
files=`rcorder /etc/rc.d/*`
@


1.3.4.1
log
@pull up revs 1.4
approved by: thorpej

	1.4:
	run rcorder with `-k shutdown', so that only the scripts with a
	`shutdown' keyword get run at shutdown time.
@
text
@d3 1
a3 1
# $NetBSD: rc.shutdown,v 1.4 2000/07/17 15:23:28 lukem Exp $
d27 1
a27 1
files=`rcorder -k shutdown /etc/rc.d/*`
@


1.2
log
@Check for location of xdm's pid file as suggested by Simon Burge.
Fixes PR misc/6828 by Paul Goyette.
@
text
@d1 6
a6 6
#	$NetBSD: rc.shutdown,v 1.1 1998/10/29 20:24:57 bad Exp $

# System shutdown script run by shutdown before halting/rebooting
# or going single-user.

stty status '^T'
d9 1
a9 1
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin
d11 2
a12 6
if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
else
	echo "Can't read /etc/rc.subr; aborting."
	exit 1;
fi
d14 1
a14 7
if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

if checkyesno do_rcshutdown; then
	: # Everything's hunkdory
else
d19 1
a19 3
if [ -f /etc/rc.shutdown.local ]; then
	. /etc/rc.shutdown.local
fi
d21 15
a35 17
# Kill xdm and wait for it to terminate.
if checkyesno xdm; then
	XDM_PIDFILE=`awk '/DisplayManager.pidFile/ {print $2}' \
		     /usr/X11R6/lib/X11/xdm/xdm-config`
	if [ -n "$XDM_PIDFILE" -a -e "$XDM_PIDFILE" ]
	then
		XDM_PID=`sed 1q $XDM_PIDFILE`
		if [ -n "$XDM_PID" ]; then
			echo -n ' xdm'
			kill $XDM_PID
			while kill -0 $XDM_PID 2>/dev/null; do
				sleep 1
			done
			rm -f $XDM_PIDFILE
		fi
	fi
fi
d37 1
@


1.1
log
@A basic /etc/rc.shutdown.  Bails out if do_rcshutdown!=YES in /etc/rc.conf
(default is YES).  Kills xdm and waits for it to terminate if it was enabled
in rc.conf (based on a code snippet from Ignatios).
@
text
@d1 1
a1 1
#	$NetBSD$
d35 13
a47 7
	XDM_PID=`sed 1q /var/run/xdm-pid`
	if [ -n "$XDM_PID" ]; then
		echo -n ' xdm'
		kill $XDM_PID
		while kill -0 $XDM_PID; do
			sleep 1
		done
@

