![cjs](/assets/img/avatar_default.png)
of "local" it will not mount filesystem types it identifies as network file systems (currently just nfs). Call the function twice, before networking starts with arg "local", after networking starts with arg "network". Remove critfs_require_network as is now redundant.
80 lines
1.7 KiB
Plaintext
80 lines
1.7 KiB
Plaintext
# $NetBSD: rc.subr,v 1.7 1999/04/01 03:58:44 cjs 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() {
|
|
for fs in /usr /var $critical_filesystems; do
|
|
if [ $1 = local ] && ! islocalfs $fs; then
|
|
continue
|
|
fi
|
|
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
|
|
# We didn't find the FS. Return local to show error as
|
|
# early in boot sequence as possible.
|
|
echo "WARNING: islocalfs() in rc.subr doesn't recognise fstype $fs"
|
|
return 1;
|
|
}
|