1999-04-01 07:58:44 +04:00
|
|
|
# $NetBSD: rc.subr,v 1.7 1999/04/01 03:58:44 cjs Exp $
|
1997-08-29 06:24:04 +04:00
|
|
|
# functions used by various rc scripts
|
|
|
|
|
1998-03-01 01:56:11 +03:00
|
|
|
#
|
|
|
|
# checkyesno
|
|
|
|
# Test $1 variable, and warn if not set to YES or NO.
|
|
|
|
# return 0 if it's "yes" (et al), nonzero otherwise
|
|
|
|
#
|
1997-08-29 06:24:04 +04:00
|
|
|
checkyesno() {
|
1998-03-01 01:54:02 +03:00
|
|
|
eval value=\$${1}
|
1998-01-26 07:36:26 +03:00
|
|
|
case $value in
|
1998-03-01 01:54:02 +03:00
|
|
|
|
|
|
|
# "yes", "true", "on", or "1"
|
|
|
|
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
|
|
|
|
return 0
|
1998-01-26 07:36:26 +03:00
|
|
|
;;
|
1998-03-01 01:54:02 +03:00
|
|
|
|
|
|
|
# "no", "false", "off", or "0"
|
|
|
|
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
|
|
|
|
return 1
|
1998-01-26 07:36:26 +03:00
|
|
|
;;
|
1998-03-01 01:54:02 +03:00
|
|
|
|
1998-01-26 07:36:26 +03:00
|
|
|
*)
|
|
|
|
logger -s "WARNING: \$${1} is not set properly."
|
1998-03-01 01:54:02 +03:00
|
|
|
return 1
|
1998-01-26 07:36:26 +03:00
|
|
|
;;
|
|
|
|
esac
|
1997-08-29 06:24:04 +04:00
|
|
|
}
|
1999-03-24 21:59:47 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
1999-04-01 07:58:44 +04:00
|
|
|
fstab=/etc/fstab
|
1999-03-24 21:59:47 +03:00
|
|
|
mount_critical_filesystems() {
|
|
|
|
for fs in /usr /var $critical_filesystems; do
|
1999-04-01 07:58:44 +04:00
|
|
|
if [ $1 = local ] && ! islocalfs $fs; then
|
|
|
|
continue
|
|
|
|
fi
|
1999-03-24 21:59:47 +03:00
|
|
|
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
|
|
|
|
}
|
1999-04-01 07:58:44 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|