NetBSD/etc/rc.subr
drochner db20439533 repair diskless startup: "netstart" needs "sysctl" and "awk" now, thus
"/usr" must be mounted. mount_critical_filesystems() didn't mount it,
even if listed in "critical_filesystems", if it is nfs.
Solution: introduce another rc.conf variable
"critical_filesystems_beforenet" which contains filesystems to be mounted
before "netstart".
Perhaps "netstart" should be split up, but this would make things even
more complex...
1999-07-07 21:24:56 +00:00

80 lines
1.6 KiB
Plaintext

# $NetBSD: rc.subr,v 1.10 1999/07/07 21:24:56 drochner Exp $
# functions used by various rc scripts
#
# checkyesno
# Test $1 variable, and warn if not set to YES or NO.
# return 0 if it's "yes" (et al), nonzero otherwise
#
checkyesno() {
eval value=\$${1}
case $value in
# "yes", "true", "on", or "1"
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
return 0
;;
# "no", "false", "off", or "0"
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
return 1
;;
*)
logger -s "WARNING: \$${1} is not set properly."
return 1
;;
esac
}
#
# mount_critical_filesystems
# Go through the list of critical filesystems, checking each one
# to see if it is mounted, and if it is not, mounting it.
#
fstab=/etc/fstab
mount_critical_filesystems() {
if [ $1 = local ]; then
_fslist=$critical_filesystems_beforenet
else
_fslist=$critical_filesystems
fi
for fs in $_fslist; do
mount | (
ismounted=no
while read what _on on _type type; do
if [ $on = $fs ]; then
ismounted=yes
fi
done
if [ $ismounted = no ]; then
mount $fs >/dev/null 2>&1
fi
)
done
}
islocalfs() {
if [ -z "$1" ]; then
echo 'islocalfs() called with no fs argument: aborting.'
exit 3
fi
while read dev dir type opts; do
if [ "$1" = "$dir" ]; then
case $type in
# Local filesystems.
ados|cd9660|ext2fs|fdesc|ffs) return 0;;
filecore|kernfs|lfs|mfs|msdos|null) return 0;;
portal|procfs|ufs|umap|union) return 0;;
# Network filesystems
nfs) return 1;;
# If we don't know, err on the safe side
# and assume it's a network FS.
*) return 1;;
esac
fi
done < $fstab
# Quietly ignore not-found filesystems.
return 1;
}