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