rc.subr revision 1.10
11.10Sdrochner# $NetBSD: rc.subr,v 1.10 1999/07/07 21:24:56 drochner Exp $ 21.1Scjs# functions used by various rc scripts 31.1Scjs 41.5Slukem# 51.5Slukem# checkyesno 61.5Slukem# Test $1 variable, and warn if not set to YES or NO. 71.5Slukem# return 0 if it's "yes" (et al), nonzero otherwise 81.5Slukem# 91.1Scjscheckyesno() { 101.4Slukem eval value=\$${1} 111.3Slukem case $value in 121.4Slukem 131.4Slukem # "yes", "true", "on", or "1" 141.4Slukem [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) 151.4Slukem return 0 161.3Slukem ;; 171.4Slukem 181.4Slukem # "no", "false", "off", or "0" 191.4Slukem [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) 201.4Slukem return 1 211.3Slukem ;; 221.4Slukem 231.3Slukem *) 241.3Slukem logger -s "WARNING: \$${1} is not set properly." 251.4Slukem return 1 261.3Slukem ;; 271.3Slukem esac 281.6Smellon} 291.6Smellon 301.6Smellon# 311.6Smellon# mount_critical_filesystems 321.6Smellon# Go through the list of critical filesystems, checking each one 331.6Smellon# to see if it is mounted, and if it is not, mounting it. 341.6Smellon# 351.7Scjsfstab=/etc/fstab 361.6Smellonmount_critical_filesystems() { 371.10Sdrochner if [ $1 = local ]; then 381.10Sdrochner _fslist=$critical_filesystems_beforenet 391.10Sdrochner else 401.10Sdrochner _fslist=$critical_filesystems 411.10Sdrochner fi 421.10Sdrochner for fs in $_fslist; do 431.6Smellon mount | ( 441.6Smellon ismounted=no 451.6Smellon while read what _on on _type type; do 461.6Smellon if [ $on = $fs ]; then 471.6Smellon ismounted=yes 481.6Smellon fi 491.6Smellon done 501.6Smellon if [ $ismounted = no ]; then 511.6Smellon mount $fs >/dev/null 2>&1 521.6Smellon fi 531.6Smellon ) 541.6Smellon done 551.7Scjs} 561.7Scjs 571.7Scjsislocalfs() { 581.7Scjs if [ -z "$1" ]; then 591.7Scjs echo 'islocalfs() called with no fs argument: aborting.' 601.7Scjs exit 3 611.7Scjs fi 621.7Scjs while read dev dir type opts; do 631.7Scjs if [ "$1" = "$dir" ]; then 641.7Scjs case $type in 651.7Scjs # Local filesystems. 661.7Scjs ados|cd9660|ext2fs|fdesc|ffs) return 0;; 671.7Scjs filecore|kernfs|lfs|mfs|msdos|null) return 0;; 681.7Scjs portal|procfs|ufs|umap|union) return 0;; 691.7Scjs # Network filesystems 701.7Scjs nfs) return 1;; 711.7Scjs # If we don't know, err on the safe side 721.7Scjs # and assume it's a network FS. 731.7Scjs *) return 1;; 741.7Scjs esac 751.7Scjs fi 761.7Scjs done < $fstab 771.8Scjs # Quietly ignore not-found filesystems. 781.7Scjs return 1; 791.1Scjs} 80