rc.subr revision 1.6
1# $NetBSD: rc.subr,v 1.6 1999/03/24 18:59:47 mellon Exp $ 2# functions used by various rc scripts 3 4# 5# checkyesno 6# Test $1 variable, and warn if not set to YES or NO. 7# return 0 if it's "yes" (et al), nonzero otherwise 8# 9checkyesno() { 10 eval value=\$${1} 11 case $value in 12 13 # "yes", "true", "on", or "1" 14 [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) 15 return 0 16 ;; 17 18 # "no", "false", "off", or "0" 19 [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) 20 return 1 21 ;; 22 23 *) 24 logger -s "WARNING: \$${1} is not set properly." 25 return 1 26 ;; 27 esac 28} 29 30# 31# mount_critical_filesystems 32# Go through the list of critical filesystems, checking each one 33# to see if it is mounted, and if it is not, mounting it. 34# 35mount_critical_filesystems() { 36 for fs in /usr /var $critical_filesystems; do 37 mount | ( 38 ismounted=no 39 while read what _on on _type type; do 40 if [ $on = $fs ]; then 41 ismounted=yes 42 fi 43 done 44 if [ $ismounted = no ]; then 45 mount $fs >/dev/null 2>&1 46 fi 47 ) 48 done 49} 50