Home | History | Annotate | Line # | Download | only in rc.d
      1   1.1    lukem #!/bin/sh
      2   1.1    lukem #
      3  1.12      kre # $NetBSD: raidframe,v 1.12 2022/07/21 07:49:36 kre Exp $
      4   1.1    lukem #
      5   1.1    lukem 
      6  1.10    joerg # PROVIDE: raidframe
      7  1.11  mlelstv # REQUIRE: devpubd
      8  1.10    joerg # BEFORE:  DISKS
      9   1.1    lukem 
     10   1.9  mycroft $_rc_subr_loaded . /etc/rc.subr
     11   1.1    lukem 
     12  1.12      kre name=raidframe
     13   1.8      wiz rcvar=$name
     14  1.12      kre start_cmd=raidframe_start
     15  1.12      kre stop_cmd=:
     16   1.1    lukem 
     17   1.1    lukem raidframe_start()
     18   1.1    lukem {
     19   1.6    lukem 	# Configure non-auto-configured raid devices.
     20  1.12      kre 	# Ensure order by globbing raid[0-9] before raid[1-9][0-9].
     21  1.12      kre 	# Assume no mixing of /etc/conf/raid/* and /etc/raid*.conf styles
     22  1.12      kre 
     23  1.12      kre 	devices=$(sysctl -n hw.disknames)
     24  1.12      kre 	for cfg in 					\
     25  1.12      kre 		/etc/conf/raid/raid[0-9]		\
     26  1.12      kre 		/etc/conf/raid/raid[1-9][0-9]		\
     27  1.12      kre 		/etc/conf/raid/raid[1-9][0-9][0-9]	\
     28  1.12      kre 		/etc/raid[0-9].conf			\
     29  1.12      kre 		/etc/raid[1-9][0-9].conf		\
     30  1.12      kre 	; do
     31  1.12      kre 		[ -f "$cfg" ] && [ -s "$cfg" ] || continue
     32  1.12      kre 
     33   1.5    lukem 		dev=${cfg##*/}
     34  1.12      kre 		dev=${dev%.conf}
     35  1.12      kre 
     36  1.12      kre 		# This test should never fail with the possible
     37  1.12      kre 		# config file patterns included, but for safety
     38  1.12      kre 		case "${dev}" in
     39  1.12      kre 		raid[0-9]|raid[1-9][0-9]|raid[1-9][0-9][0-9])	;;
     40  1.12      kre 		*)	: "$dev not raidNN"; continue;;
     41  1.12      kre 		esac
     42  1.12      kre 
     43  1.12      kre 		case " ${devices} " in
     44  1.12      kre 		*" ${dev} "*)	: "$dev configured already"; continue;;
     45  1.12      kre 		esac
     46  1.12      kre 
     47  1.12      kre 		raidctl -c "$cfg" "$dev" &&
     48  1.12      kre 			devices="${devices} ${dev}"
     49   1.1    lukem 	done
     50   1.1    lukem }
     51   1.1    lukem 
     52   1.3    lukem load_rc_config $name
     53   1.1    lukem run_rc_command "$1"
     54