version 1.494, 2017/04/18 23:06:50 |
version 1.495, 2017/05/01 14:01:47 |
|
|
|
|
# Subroutines (have to come first). |
# Subroutines (have to come first). |
|
|
|
|
# Strip in- and whole-line comments from a file. |
# Strip in- and whole-line comments from a file. |
# Strip leading and trailing whitespace if IFS is set. |
# Strip leading and trailing whitespace if IFS is set. |
# Usage: stripcom /path/to/file |
# Usage: stripcom /path/to/file |
|
|
done |
done |
} |
} |
|
|
|
# Push the old seed into the kernel, create a future seed and create a seed |
|
# file for the boot-loader. |
random_seed() { |
random_seed() { |
# push the old seed into the kernel |
|
dd if=/var/db/host.random of=/dev/random bs=65536 count=1 status=none |
dd if=/var/db/host.random of=/dev/random bs=65536 count=1 status=none |
chmod 600 /var/db/host.random |
chmod 600 /var/db/host.random |
# ... and create a future seed |
|
dd if=/dev/random of=/var/db/host.random bs=65536 count=1 status=none |
dd if=/dev/random of=/var/db/host.random bs=65536 count=1 status=none |
# and create a seed file for the boot-loader |
|
dd if=/dev/random of=/etc/random.seed bs=512 count=1 status=none |
dd if=/dev/random of=/etc/random.seed bs=512 count=1 status=none |
chmod 600 /etc/random.seed |
chmod 600 /etc/random.seed |
} |
} |
|
|
domainname "$(stripcom /etc/defaultdomain)" |
domainname "$(stripcom /etc/defaultdomain)" |
fi |
fi |
|
|
# Need to get local functions from rc.subr. |
# Get local functions from rc.subr to load rc.conf into scope. |
FUNCS_ONLY=1 . /etc/rc.d/rc.subr |
FUNCS_ONLY=1 . /etc/rc.d/rc.subr |
|
|
# Load rc.conf into scope. |
|
_rc_parse_conf |
_rc_parse_conf |
|
|
|
# If executed with the 'shutdown' parameter by the halt, reboot or shutdown: |
|
# - update seed files |
|
# - execute the rc.d scripts specified by $pkg_scripts in reverse order |
|
# - bring carp interfaces down gracefully |
if [[ $1 == shutdown ]]; then |
if [[ $1 == shutdown ]]; then |
if echo 2>/dev/null >>/var/db/host.random || \ |
if echo 2>/dev/null >>/var/db/host.random || \ |
echo 2>/dev/null >>/etc/random.seed; then |
echo 2>/dev/null >>/etc/random.seed; then |
|
|
[[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown |
[[ -f /etc/rc.shutdown ]] && sh /etc/rc.shutdown |
fi |
fi |
|
|
# Bring carp interfaces down gracefully. |
|
ifconfig | while read _if _junk; do |
ifconfig | while read _if _junk; do |
[[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down |
[[ $_if == carp+([0-9]): ]] && ifconfig ${_if%:} down |
done |
done |
|
|
# Add swap block-devices. |
# Add swap block-devices. |
swapctl -A -t blk |
swapctl -A -t blk |
|
|
|
# Run filesystem check unless a /fastboot file exists. |
if [[ -e /fastboot ]]; then |
if [[ -e /fastboot ]]; then |
echo "Fast boot: skipping disk checks." |
echo "Fast boot: skipping disk checks." |
elif [[ $1 == autoboot ]]; then |
elif [[ $1 == autoboot ]]; then |
|
|
do_fsck |
do_fsck |
fi |
fi |
|
|
|
# From now on, allow user to interrupt (^C) the boot process. |
trap "echo 'Boot interrupted.'; exit 1" 3 |
trap "echo 'Boot interrupted.'; exit 1" 3 |
|
|
|
# Unmount all filesystems except root. |
umount -a >/dev/null 2>&1 |
umount -a >/dev/null 2>&1 |
|
|
|
# Mount all filesystems except those of type NFS and VND. |
mount -a -t nonfs,vnd |
mount -a -t nonfs,vnd |
mount -uw / # root on nfs requires this, others aren't hurt. |
|
rm -f /fastboot # XXX (root now writeable) |
|
|
|
# Set flags on ttys. (Do early, in case they use tty for SLIP in netstart.) |
# Re-mount the root filesystem read/writeable. (root on nfs requires this, |
|
# others aren't hurt.) |
|
mount -uw / |
|
|
|
rm -f /fastboot |
|
|
|
# Set flags on ttys. (Do early, in case they use tty for SLIP in netstart.) |
echo 'setting tty flags' |
echo 'setting tty flags' |
ttyflags -a |
ttyflags -a |
|
|
|
|
pfctl -e |
pfctl -e |
fi |
fi |
|
|
# Fill net.inet.(tcp|udp).baddynamic lists from /etc/services. |
|
fill_baddynamic udp |
fill_baddynamic udp |
fill_baddynamic tcp |
fill_baddynamic tcp |
|
|
|
|
|
|
sh /etc/netstart |
sh /etc/netstart |
|
|
dmesg >/dev/random # Any write triggers a rekey. |
# Any write triggers a rekey. |
|
dmesg >/dev/random |
|
|
# Load pf rules and bring up pfsync interface. |
# Load pf rules and bring up pfsync interface. |
if [[ $pf != NO ]]; then |
if [[ $pf != NO ]]; then |
|
|
(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) |
(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) |
(cd /var/authpf && rm -rf -- *) |
(cd /var/authpf && rm -rf -- *) |
|
|
dmesg >/var/run/dmesg.boot # Save a copy of the boot messages. |
# Save a copy of the boot messages. |
|
dmesg >/var/run/dmesg.boot |
|
|
make_keys |
make_keys |
|
|
|
|
chmod 666 /dev/tty[pqrstuvwxyzPQRST]* |
chmod 666 /dev/tty[pqrstuvwxyzPQRST]* |
chown root:wheel /dev/tty[pqrstuvwxyzPQRST]* |
chown root:wheel /dev/tty[pqrstuvwxyzPQRST]* |
|
|
# Check the password temp/lock file. |
# Check for the password temp/lock file. |
if [[ -f /etc/ptmp ]]; then |
if [[ -f /etc/ptmp ]]; then |
logger -s -p auth.err \ |
logger -s -p auth.err \ |
'password file may be incorrect -- /etc/ptmp exists' |
'password file may be incorrect -- /etc/ptmp exists' |
|
|
|
|
[[ -f /etc/rc.local ]] && sh /etc/rc.local |
[[ -f /etc/rc.local ]] && sh /etc/rc.local |
|
|
ifconfig -g carp -carpdemote 128 # Disable carp interlock. |
# Disable carp interlock. |
|
ifconfig -g carp -carpdemote 128 |
|
|
mixerctl_conf |
mixerctl_conf |
|
|