1a3bfc2c1b
than printing an error, just as we do when we try to mount it.
78 lines
1.6 KiB
Plaintext
78 lines
1.6 KiB
Plaintext
# $NetBSD: rc.subr,v 1.8 1999/04/13 02:15:49 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
|
|
# Quietly ignore not-found filesystems.
|
|
return 1;
|
|
}
|