xref: /minix3/etc/usr/rc (revision 6331e8f845c0bb82b87270fe845cc88531c3ff1b)
1b684a8edSBen Gras# /usr/etc/rc - continued system initialization.
2b684a8edSBen Gras
361a4e15bSJorrit HerderRANDOM_FILE=/usr/adm/random.dat
4e21c135fSBen GrasLOCAL_FILE=/usr/etc/rc.local
561a4e15bSJorrit Herder
65acaa081SBen GrasARCH="`sysenv arch`"
75acaa081SBen Gras
85acaa081SBen Grasif [ ! "$ARCH" ]
95acaa081SBen Grasthen    # Older kernels do not provide an arch sysenv variable.
105acaa081SBen Gras        # We assume we are on x86 then, as existing systems with
115acaa081SBen Gras        # kernel and userland (i.e. this script) unsynchronized
125acaa081SBen Gras        # will be x86.
135acaa081SBen Gras        ARCH=i386
145acaa081SBen Grasfi
155acaa081SBen Gras
16349a1580SBen Gras# Get $SERVICES_DIRS
17349a1580SBen Gras. /etc/rc.conf
18349a1580SBen Gras
19349a1580SBen Gras# Directories to find services in
20349a1580SBen Grasif [ ! "$SERVICES_DIRS" ]
21349a1580SBen Grasthen	SERVICES_DIRS=/usr/sbin
22349a1580SBen Grasfi
23349a1580SBen Gras
24a03f679eSBen Gras# Booting from cd?
25a03f679eSBen Grasbootcd="`/bin/sysenv bootcd`"
26a03f679eSBen Gras
27b684a8edSBen Grascase "$#:$1" in
28b684a8edSBen Gras1:start|1:stop|1:down)
29b684a8edSBen Gras    action=$1
30b684a8edSBen Gras    ;;
31b684a8edSBen Gras*)  echo >&2 "Usage: $0 start|stop|down"
32b684a8edSBen Gras    exit 1
33b684a8edSBen Grasesac
34b684a8edSBen Gras
35e21c135fSBen Grasif [ -f "$LOCAL_FILE" ]
36e21c135fSBen Grasthen	. "$LOCAL_FILE" $1
37e21c135fSBen Grasfi
38e21c135fSBen Gras
3940e9875fSJorrit Herderdisabled()
4040e9875fSJorrit Herder{
4140e9875fSJorrit Herder    ifs="$IFS"; IFS=,
428cb902dcSJorrit Herder    for skip in `sysenv disable`
4340e9875fSJorrit Herder    do
448cb902dcSJorrit Herder        if [ "$skip" = "$1" ]
4540e9875fSJorrit Herder	then
4640e9875fSJorrit Herder                IFS="$ifs"; unset ifs
4740e9875fSJorrit Herder		return 0
4840e9875fSJorrit Herder	fi
4940e9875fSJorrit Herder    done
5040e9875fSJorrit Herder    IFS="$ifs"; unset ifs
5140e9875fSJorrit Herder    return 1
5240e9875fSJorrit Herder}
5340e9875fSJorrit Herder
54b684a8edSBen Grasdaemonize()
55b684a8edSBen Gras{
56b684a8edSBen Gras    # Function to start a daemon, if it exists.
57b684a8edSBen Gras    local IFS=':'
58b684a8edSBen Gras    local name="$1"
59b684a8edSBen Gras    test "$1" = tcpd && name="$2"
60b684a8edSBen Gras
61b684a8edSBen Gras    for dir in $PATH
62b684a8edSBen Gras    do
63b684a8edSBen Gras	if [ -f "$dir/$1" ]
64b684a8edSBen Gras	then
6540e9875fSJorrit Herder
6640e9875fSJorrit Herder            # check if this service is disabled at the boot monitor.
6740e9875fSJorrit Herder            if disabled $name; then return; fi
6840e9875fSJorrit Herder
69b684a8edSBen Gras	    echo -n " $name"
70b684a8edSBen Gras	    "$@" &
71b684a8edSBen Gras	    return
72b684a8edSBen Gras	fi
73b684a8edSBen Gras    done
74b684a8edSBen Gras}
75b684a8edSBen Gras
7661a4e15bSJorrit Herderup()
7761a4e15bSJorrit Herder{
783de6a807SCristiano Giuffrida    # Function to dynamically start a system service
793de6a807SCristiano Giuffrida    opt=""
803de6a807SCristiano Giuffrida    prefix=$(expr "$1 " : '\(-\)')
813de6a807SCristiano Giuffrida    if [ "$prefix" = "-" ];
823de6a807SCristiano Giuffrida    then
8365ef5397SCristiano Giuffrida         opt=$1
8465ef5397SCristiano Giuffrida         shift
853de6a807SCristiano Giuffrida    fi
8661a4e15bSJorrit Herder    service=$1
872aac756eSJorrit Herder    shift
8861a4e15bSJorrit Herder
8961a4e15bSJorrit Herder    # First check if this service is disabled at the boot monitor.
9040e9875fSJorrit Herder    if disabled $service; then return; fi
9161a4e15bSJorrit Herder
9261a4e15bSJorrit Herder    # Service is not disabled. Try to bring it up.
93349a1580SBen Gras    found=""
94349a1580SBen Gras    for dir in $SERVICES_DIRS
95349a1580SBen Gras    do	bin=$dir/$service
96349a1580SBen Gras	if [ -x $bin -a -z "$found" ]
97349a1580SBen Gras	then	service $opt up $bin "$@"
9861a4e15bSJorrit Herder    		echo -n " $service"
99349a1580SBen Gras		found=yes
100349a1580SBen Gras	fi
101349a1580SBen Gras    done
102349a1580SBen Gras    if [ -z "$found" ]
103349a1580SBen Gras    then	echo " ($service not found in $SERVICES_DIRS)"
104349a1580SBen Gras    fi
10561a4e15bSJorrit Herder}
106f8c380c1SPhilip Homburg
1079ba65d2eSDavid van Moolenbroekget_eth_labels() {
1089ba65d2eSDavid van Moolenbroek  # Filter out the non-vlan ethernet entries from inet.conf.
1099ba65d2eSDavid van Moolenbroek  # Produce as output a list of "drivername_instancenr"-formatted labels.
1106759b24cSThomas Veerman  sed 's/\008/ /g' /etc/inet.conf | \
1119ba65d2eSDavid van Moolenbroek    sed -n 's/^ *eth[0-9][0-9]* *\([^ ][^ ]*\) *\([0-9][0-9]*\).*$/\1_\2/p' | \
1129ba65d2eSDavid van Moolenbroek    grep -v '^vlan_'
1139ba65d2eSDavid van Moolenbroek}
114103f18cbSBen Gras
115e7855d00SThomas Cort# Detect expansion boards on the BeagleBone and load the proper drivers.
116e7855d00SThomas Cortcapemgr() {
117e7855d00SThomas Cort
118e7855d00SThomas Cort    # Probe each possible cape EEPROM slave address for a BeagleBone cape.
119e7855d00SThomas Cort    for slave_addr in 54 55 56 57
120e7855d00SThomas Cort    do
121e7855d00SThomas Cort
122e7855d00SThomas Cort        # See if there is a readable EEPROM with address ${slave_addr}.
123e7855d00SThomas Cort        eepromread -f /dev/i2c-3 -a 0x${slave_addr} > /dev/null 2>&1
124e7855d00SThomas Cort        RESULT=$?
125e7855d00SThomas Cort	if [ $RESULT -eq 0 ]
126e7855d00SThomas Cort	then
127e7855d00SThomas Cort
128e7855d00SThomas Cort	    # Found an alive EEPROM. Try reading the cape name.
129e7855d00SThomas Cort            CAPE=`eepromread -i -f /dev/i2c-3 -a 0x${slave_addr} | \
130e7855d00SThomas Cort	        sed -n 's/^PART_NUMBER     : \(.*\)$/\1/p' | \
131e7855d00SThomas Cort		sed -e 's/\.*$//g'` # Strip trailing periods.
132e7855d00SThomas Cort
133e7855d00SThomas Cort	    # Look for a cape specific RC script.
134e7855d00SThomas Cort            if [ -x /etc/rc.capes/${CAPE} ]
135e7855d00SThomas Cort	    then
136e7855d00SThomas Cort
137e7855d00SThomas Cort	        # CAT24C256 EEPROM -- all capes have this chip.
138e7855d00SThomas Cort		test -e /dev/eepromb3s${slave_addr} || \
139e7855d00SThomas Cort		    (cd /dev && MAKEDEV eepromb3s${slave_addr})
140e7855d00SThomas Cort		up cat24c256 -dev /dev/eepromb3s${slave_addr} \
141e7855d00SThomas Cort		    -label cat24c256.3.${slave_addr} \
142e7855d00SThomas Cort		    -args "bus=3 address=0x${slave_addr}"
143e7855d00SThomas Cort
144e7855d00SThomas Cort                # Load the drivers for the cape and do any other configuration.
145e7855d00SThomas Cort		. "/etc/rc.capes/${CAPE}"
146e7855d00SThomas Cort
147e7855d00SThomas Cort	    else
148e7855d00SThomas Cort
149e7855d00SThomas Cort		echo ""
150e7855d00SThomas Cort	        echo "** UNSUPPORTED CAPE: ${CAPE}"
151e7855d00SThomas Cort		echo ""
152e7855d00SThomas Cort
153e7855d00SThomas Cort	    fi
154e7855d00SThomas Cort	fi
155e7855d00SThomas Cort    done
156e7855d00SThomas Cort}
157e7855d00SThomas Cort
158103f18cbSBen GrasDAEMONS=/etc/rc.daemons
159103f18cbSBen Gras
160b684a8edSBen Grascase $action in
161b684a8edSBen Grasstart)
162b684a8edSBen Gras    # Select console font.
163b684a8edSBen Gras    test -f /etc/font && loadfont /etc/font </dev/console
164b684a8edSBen Gras
165b684a8edSBen Gras    # Cleanup.
166e257c999SThomas Veerman    rm -rf /tmp/* /usr/run/* /usr/spool/lpd/* /usr/spool/locks/*
167b684a8edSBen Gras
168e5610815SJorrit Herder    # Start servers and drivers set at the boot monitor.
1693cb00065SJorrit Herder    echo -n "Starting services:"
170*6331e8f8SDavid van Moolenbroek    up -n random -dev /dev/random -period 3HZ
171c12b74daSPhilip Homburg
172f8c380c1SPhilip Homburg    # load random number generator
173f8c380c1SPhilip Homburg    if [ -f $RANDOM_FILE ]
174f8c380c1SPhilip Homburg    then
175f8c380c1SPhilip Homburg    	cat < $RANDOM_FILE >/dev/random
176f8c380c1SPhilip Homburg    	# overwrite $RANDOM_FILE. We don't want to use this data again
1770bd61375SJorrit Herder    	dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
178f8c380c1SPhilip Homburg    fi
179f8c380c1SPhilip Homburg
1809ba65d2eSDavid van Moolenbroek    # start network driver instances for all configured ethernet devices
1819ba65d2eSDavid van Moolenbroek    for label in $(get_eth_labels); do
1829ba65d2eSDavid van Moolenbroek        driver=$(echo $label | sed 's/\(.*\)_.*/\1/')
1839ba65d2eSDavid van Moolenbroek        instance=$(echo $label | sed 's/.*_//')
1849ba65d2eSDavid van Moolenbroek        eval arg=\$${label}_arg
1859ba65d2eSDavid van Moolenbroek        if [ ! -z "$arg" ]; then arg=" $arg"; fi
1869ba65d2eSDavid van Moolenbroek        arg="-args \"instance=$instance$arg\""
1879ba65d2eSDavid van Moolenbroek        eval up $driver -label $label $arg -period 5HZ
188e5610815SJorrit Herder    done
1890039e023STomas Hruby    if [ X`/bin/sysenv lwip` = Xyes ]
1900039e023STomas Hruby    then
191*6331e8f8SDavid van Moolenbroek	up lwip -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE
1920039e023STomas Hruby    else
1935a98cd3eSCristiano Giuffrida	up inet -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE
1940039e023STomas Hruby    fi
1955acaa081SBen Gras
1963de6a807SCristiano Giuffrida    up -n ipc
1975acaa081SBen Gras
1985acaa081SBen Gras    if [ $ARCH = i386 ]
1995acaa081SBen Gras    then
2005acaa081SBen Gras	up -n printer -dev /dev/lp -period 10HZ
2010aa01a2dSDavid van Moolenbroek	# start VirtualBox time sync driver if the device is there
2020aa01a2dSDavid van Moolenbroek	if grep '^[^ ]* [^ ]* 80EE:CAFE ' /proc/pci >/dev/null; then
2030aa01a2dSDavid van Moolenbroek		up -n vbox -period 10HZ
2040aa01a2dSDavid van Moolenbroek	fi
2055acaa081SBen Gras    fi
2065acaa081SBen Gras
20761a4e15bSJorrit Herder    echo .
208b684a8edSBen Gras
209b684a8edSBen Gras    # Network initialization.
210b684a8edSBen Gras    (: </dev/tcp) 2>/dev/null && net=t	# Is there a TCP/IP server?
211b684a8edSBen Gras
212b684a8edSBen Gras    echo -n "Starting daemons:"
213b684a8edSBen Gras    daemonize update
2149748a653SBen Gras
2159748a653SBen Gras    # Ugly error message when starting cron from CD.
2169748a653SBen Gras    # (and cron unnecessary then so..)
2179748a653SBen Gras    if [ ! -f /CD ]
218ea398f99SBen Gras    then	daemonize cron
2193775ce2eSBen Gras    else	mkdir /tmp/log
220ea398f99SBen Gras    		rm -f /var/log || true
2213775ce2eSBen Gras		ln -s /tmp/log /var/log || true
2223775ce2eSBen Gras		. /etc/rc.cd
2239748a653SBen Gras    fi
2247a1853a5SBen Gras    # syslogd has not been started yet
2256137c589SBen Gras    rm -f /var/run/syslogd.pid
226a3dfe3c9SBen Gras    daemonize syslogd
2270bd61375SJorrit Herder    echo .
228b684a8edSBen Gras
229550fdfb4SThomas Cort    # i2c only supported on ARM at the moment
230550fdfb4SThomas Cort    if [ $ARCH = earm ]
231550fdfb4SThomas Cort    then
232550fdfb4SThomas Cort	echo -n "Starting i2c subsystem: "
233550fdfb4SThomas Cort	for bus in 1 2 3
234550fdfb4SThomas Cort	do
235550fdfb4SThomas Cort		test -e /dev/i2c-${bus} || (cd /dev && MAKEDEV i2c-${bus})
236550fdfb4SThomas Cort		up i2c -dev /dev/i2c-${bus} -label i2c.${bus} \
237550fdfb4SThomas Cort			-args instance=${bus}
238550fdfb4SThomas Cort	done
239550fdfb4SThomas Cort	echo .
240fdbede5dSThomas Cort
241df28b6a5SKees Jongenburger	BOARD_NAME=`sysenv board`
242fdbede5dSThomas Cort	case "${BOARD_NAME}" in
24326f14d6bSThomas Cort
244df28b6a5SKees Jongenburger		ARM-ARMV7-TI-BB-WHITE)
245df28b6a5SKees Jongenburger			echo "Running on a BeagleBone"
246fdbede5dSThomas Cort			echo -n "Starting i2c device drivers: "
24726f14d6bSThomas Cort
24826f14d6bSThomas Cort			# start EEPROM driver for reading board info
24926f14d6bSThomas Cort			test -e /dev/eepromb1s50 || \
25026f14d6bSThomas Cort				(cd /dev && MAKEDEV eepromb1s50)
251fdbede5dSThomas Cort			up cat24c256 -dev /dev/eepromb1s50 \
252d9b62047SThomas Cort				-label cat24c256.1.50 \
253d9b62047SThomas Cort				-args 'bus=1 address=0x50'
254d9b62047SThomas Cort
255d9b62047SThomas Cort			# Start TPS65217 driver for power management.
256d9b62047SThomas Cort			up tps65217 -label tps65217.1.24 \
257d9b62047SThomas Cort			        -args 'bus=1 address=0x24'
258d9b62047SThomas Cort
25926f14d6bSThomas Cort			# check for the presence of a display
26026f14d6bSThomas Cort			eepromread -f /dev/i2c-2 -n > /dev/null 2>&1
26126f14d6bSThomas Cort			RESULT=$?
26226f14d6bSThomas Cort			if [ $RESULT -eq 0 ]
26326f14d6bSThomas Cort			then
26426f14d6bSThomas Cort				# start eeprom driver for reading EDID.
26526f14d6bSThomas Cort				test -e /dev/eepromb2s50 || \
26626f14d6bSThomas Cort					(cd /dev && MAKEDEV eepromb2s50)
26726f14d6bSThomas Cort				up cat24c256 -dev /dev/eepromb2s50 \
26826f14d6bSThomas Cort					-label cat24c256.2.50 \
26926f14d6bSThomas Cort					-args 'bus=2 address=0x50'
27026f14d6bSThomas Cort
27126f14d6bSThomas Cort				# start frame buffer
27226f14d6bSThomas Cort				#up fb -dev /dev/fb0 -args edid.0=cat24c256.2.50
27326f14d6bSThomas Cort				# fb hasn't been ported to AM335X yet.
27426f14d6bSThomas Cort			fi
27526f14d6bSThomas Cort
276e7855d00SThomas Cort			# Detect expansion boards and start drivers.
277e7855d00SThomas Cort			capemgr
278e7855d00SThomas Cort
279fdbede5dSThomas Cort			;;
28026f14d6bSThomas Cort
281df28b6a5SKees Jongenburger		ARM-ARMV7-TI-BB-BLACK)
282df28b6a5SKees Jongenburger			echo "Running on a BeagleBone Black"
283fdbede5dSThomas Cort			echo -n "Starting i2c device drivers: "
28426f14d6bSThomas Cort
28526f14d6bSThomas Cort			# start EEPROM driver for reading board info
28626f14d6bSThomas Cort			test -e /dev/eepromb1s50 || \
28726f14d6bSThomas Cort				(cd /dev && MAKEDEV eepromb1s50)
288fdbede5dSThomas Cort			up cat24c256 -dev /dev/eepromb1s50 \
28926f14d6bSThomas Cort				-label cat24c256.1.50 \
29026f14d6bSThomas Cort				-args 'bus=1 address=0x50'
2911b78e86fSThomas Cort
292d9b62047SThomas Cort			# Start TPS65217 driver for power management.
293d9b62047SThomas Cort			up tps65217 -label tps65217.1.24 \
294d9b62047SThomas Cort			        -args 'bus=1 address=0x24'
295d9b62047SThomas Cort
296d9b62047SThomas Cort			# Start TDA19988 driver for reading EDID.
2971b78e86fSThomas Cort			up tda19988 -label tda19988.1.3470 -args \
2981b78e86fSThomas Cort				'cec_bus=1 cec_address=0x34 hdmi_bus=1 hdmi_address=0x70'
29926f14d6bSThomas Cort
30026f14d6bSThomas Cort			# start frame buffer
30126f14d6bSThomas Cort			#up fb -dev /dev/fb0 -args edid.0=tda19988.1.3470
30226f14d6bSThomas Cort			# fb hasn't been ported to AM335X yet.
30326f14d6bSThomas Cort
304e7855d00SThomas Cort			# Detect expansion boards and start drivers.
305e7855d00SThomas Cort			capemgr
306e7855d00SThomas Cort
307fdbede5dSThomas Cort			;;
30826f14d6bSThomas Cort
309df28b6a5SKees Jongenburger		ARM-ARMV7-TI-BBXM-GENERIC)
310df28b6a5SKees Jongenburger			echo "Running on a BeagleBoard-xM"
311fdbede5dSThomas Cort			echo -n "Starting i2c device drivers: "
312bab2a34eSThomas Cort
313bab2a34eSThomas Cort			# Start TPS65950 driver for power management.
314bab2a34eSThomas Cort			up tps65950 -label tps65950.1.48 \
315bab2a34eSThomas Cort				-args 'bus=1 address=0x48'
316bab2a34eSThomas Cort
317039c8db7SThomas Cort			# Set the system time to the time in the TPS65950's RTC
318039c8db7SThomas Cort			readclock
319039c8db7SThomas Cort
32026f14d6bSThomas Cort			# check for the presence of a display
32126f14d6bSThomas Cort			eepromread -f /dev/i2c-3 -n > /dev/null 2>&1
32226f14d6bSThomas Cort			RESULT=$?
32326f14d6bSThomas Cort			if [ $RESULT -eq 0 ]
32426f14d6bSThomas Cort			then
32526f14d6bSThomas Cort				# start eeprom driver for reading edid
32626f14d6bSThomas Cort				test -e /dev/eepromb3s50 || \
32726f14d6bSThomas Cort					(cd /dev && MAKEDEV eepromb3s50)
32826f14d6bSThomas Cort				up cat24c256 -dev /dev/eepromb3s50 \
32926f14d6bSThomas Cort					-label cat24c256.3.50 \
33026f14d6bSThomas Cort					-args 'bus=3 address=0x50'
33126f14d6bSThomas Cort
33226f14d6bSThomas Cort				# start frame buffer
33326f14d6bSThomas Cort				up fb -dev /dev/fb0 -args edid.0=cat24c256.3.50
33426f14d6bSThomas Cort			fi
33526f14d6bSThomas Cort
336fdbede5dSThomas Cort			;;
337fdbede5dSThomas Cort	esac
338fdbede5dSThomas Cort
339fdbede5dSThomas Cort	echo .
340550fdfb4SThomas Cort    fi
341550fdfb4SThomas Cort
342b684a8edSBen Gras    if [ "$net" ]
343b684a8edSBen Gras    then
344b684a8edSBen Gras	if [ -f /etc/rc.net ]
345b684a8edSBen Gras	then
346b684a8edSBen Gras	    # Let a customized TCP/IP initialization script figure it out.
347b684a8edSBen Gras	    . /etc/rc.net
348b684a8edSBen Gras	else
349b684a8edSBen Gras	    # Standard network daemons.
3500bd61375SJorrit Herder    	    echo -n "Starting networking:"
3519a37f632SDavid van Moolenbroek	    if grep -s 'psip0.*default' /etc/inet.conf >/dev/null
352ef676bd3SBen Gras	    then	ifconfig -h 10.0.0.1
35348c6bb79SCristiano Giuffrida	    else
3540039e023STomas Hruby		    if [ X`/bin/sysenv lwip` = Xyes ]
3550039e023STomas Hruby		    then
3560039e023STomas Hruby			dhcpd --lwip &
3570039e023STomas Hruby			echo -n " dhcpd"
3580039e023STomas Hruby		    else
359816f5dd5SBen Gras			daemonize dhcpd
360ef676bd3SBen Gras		    fi
3610039e023STomas Hruby	    fi
3627a0f8e28SBen Gras	    daemonize nonamed -L
363103f18cbSBen Gras	    if [ -f "$DAEMONS" ]
364103f18cbSBen Gras	    then	. "$DAEMONS"
365103f18cbSBen Gras	    fi
366b684a8edSBen Gras	    # The last daemon has been started, so close the list:
367b684a8edSBen Gras	    echo .
36894095d87SBen Gras	fi
36994095d87SBen Gras    fi
370b684a8edSBen Gras
371b684a8edSBen Gras    if [ "$net" ]
372b684a8edSBen Gras    then
373b684a8edSBen Gras	# Get the nodename from the DNS and set it.
374b684a8edSBen Gras	trap '' 2
375b857dec7SBen Gras	intr -t 20 hostaddr -h
376b684a8edSBen Gras	trap 2
377b684a8edSBen Gras    fi
378b684a8edSBen Gras
379b684a8edSBen Gras    # Recover files being edited when the system crashed.
380b684a8edSBen Gras    test -f /usr/bin/elvprsv && elvprsv /usr/tmp/elv*
381b684a8edSBen Gras
382b684a8edSBen Gras    # Run the daily cleanup on systems that are not on at night.
383b684a8edSBen Gras    test -f /usr/etc/daily && sh /usr/etc/daily boot &
384f8c380c1SPhilip Homburg;;
385f8c380c1SPhilip Homburgstop|down)
386093cfe11SBen Gras    	# Save random data, if /usr is mounted rw.
387d9f4f719SThomas Veerman	if grep ' \/usr .*rw.*' /etc/mtab >/dev/null
388093cfe11SBen Gras	then
389f8c380c1SPhilip Homburg	  if dd if=/dev/random of=$RANDOM_FILE.new bs=1024 count=1 2>/dev/null
390f8c380c1SPhilip Homburg    	  then
391f8c380c1SPhilip Homburg    		mv $RANDOM_FILE.new $RANDOM_FILE
392f8c380c1SPhilip Homburg	  else
393f8c380c1SPhilip Homburg		echo 'Failed to save random data.'
394f8c380c1SPhilip Homburg	  fi
395428f9d63SBen Gras	fi
396b684a8edSBen Grasesac
397ba667a07SBen Gras
3989ce3961bSBen Grasd=
399ba667a07SBen Gras# Let packages run their own scripts
4009ce3961bSBen Grasfor d in /usr/local/etc/rc.d /usr/pkg/etc/rc.d
4019ce3961bSBen Grasdo
402a03f679eSBen Grasif [ -d "$d" -a -z "$bootcd" ]
4039ce3961bSBen Grasthen	( if cd $d
404ba667a07SBen Gras	then
405fec2fa95SBen Gras		echo -n "Local packages ($action): "
406ba667a07SBen Gras		for f in *
407ba667a07SBen Gras		do
408ba667a07SBen Gras			if [ -x "$f" ]
409ba667a07SBen Gras			then	echo -n "$f "
410ba667a07SBen Gras				sh "$f" "$action"
411ba667a07SBen Gras			fi
412ba667a07SBen Gras		done
413ba667a07SBen Gras		echo " done."
414ba667a07SBen Gras	fi
4159ce3961bSBen Gras	)
416ba667a07SBen Grasfi
4179ce3961bSBen Grasdone
418