Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Nov 1999 01:50:41 +0100 (CET)
From:      Cyrille Lefevre <root@d074.paris-222.cybercable.fr>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   conf/14931: rc logging facility
Message-ID:  <199911170050.BAA01005@d074.paris-222.cybercable.fr>

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

>Number:         14931
>Category:       conf
>Synopsis:       rc logging facility
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 16 17:00:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Cyrille Lefevre
>Release:        FreeBSD 3.3-STABLE i386
>Organization:
ACME
>Environment:

FreeBSD gits 3.3-STABLE FreeBSD 3.3-STABLE #5: Sun Nov 14 04:01:58 CET 1999     root@gits:/disk3/3.3-STABLE/src/sys/compile/CUSTOM  i386

>Description:

	Modifications to the /etc/rc startup file to provide
	a logging facility. so it is easy to see if something
	is wrong within /etc/rc.* startup files.

>How-To-Repeat:

	reboot ;-)

>Fix:
	
	split the /etc/rc into two scripts, /etc/rc and /etc/rc.boot.
	the first one provides the required things as well as the
	logging facilities, and the second one the rest as usual
	(optional things !).

	I'm sorry to not provide you a diff output, but the output
	is really !@#$%^&*, humm, not good at all to understand
	the philosophy of the logging facility.

	instead, I provide you a shell script which act as a patch.

#!/bin/sh

# ========== rc ==========

sed -n 1,/adjkerntz/p /etc/rc | grep -v adjkerntz > /tmp/rc
cat << 'EOF' >> /tmp/rc
# rc logging facility.
#

if [ -f /etc/rc.boot ]; then
	rc_boot=/etc/rc.boot
else
	rc_boot=
fi

# We need script(1) to do logging.
# Maybe a static-ly linked version exists ?
# Much better in case of /usr is not mounted.
#

if [ -x /bin/script ]; then
	rc_script=/bin/script
if [ -x /usr/bin/script ]; then
	rc_script=/usr/bin/script
else
	rc_script=
fi

# Do not use /var/run, it is cleaned by rc.* startup files.
#

if [ -d /var/log -a -w /var/log ]; then
	rc_log=/var/log/rc.log
elif [ -w /etc ]; then
	rc_log=/etc/rc.log
else
	rc_log=
fi

if [ "X$rc_boot" != "X" ]; then
	if [ "X$rc_script" != "X" -a "X$rc_log" != "X" ]; then
		chmod 664 $rc_log
		chmod 755 $rc_boot
		SHELL=$rc_boot $rc_script $rc_log
		rc_status=$?
		chmod 644 $rc_boot
		exit $rc_status
	else
		chmod 644 $rc_boot
		. $rc_boot
	fi
else
	echo "rc.boot file not found, startup aborted"
	exit 1
fi
EOF

# ========== rc.boot ==========

cat << 'EOF' >> /tmp/rc.boot
#!/bin/sh

# Set shell to ignore SIGINT (2), but not children;
# shell catches SIGQUIT (3) and returns to single user after fsck.
trap : 2
trap : 3	# shouldn't be needed

SHELL=/bin/sh
export SHELL

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

set -T
trap "echo 'Reboot interrupted'; exit 1" 3
EOF
sed -n /adjkerntz/,\$p /etc/rc >> /tmp/rc.boot

# ===== copy disabled =====

# cp /tmp/rc /etc/rc
# cp /tmp/rc.boot /etc/rc.boot

# eof

>Release-Note:
>Audit-Trail:
>Unformatted:


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




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