Module Name: src Committed By: kre Date: Thu Jul 21 07:49:36 UTC 2022
Modified Files: src/etc/rc.d: raidframe Log Message: Make this better ... Allow config file for raidN to be found in /etc/conf/raid/raidN (as well as in /etc/raidN.conf) (less clutter in /etc). Allow config files to exist for raids that are autoconfigured (just skip anything autoconfigured) - this allows a (simplistic) recovery mechanism if autoconf fails, and makes it simpler to enable/disable autoconf at will, while keeping the raid working. While here, add sh quoting where it is needed, and remove it from where it is pointless. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/etc/rc.d/raidframe Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/etc/rc.d/raidframe diff -u src/etc/rc.d/raidframe:1.11 src/etc/rc.d/raidframe:1.12 --- src/etc/rc.d/raidframe:1.11 Tue Aug 3 05:15:20 2021 +++ src/etc/rc.d/raidframe Thu Jul 21 07:49:36 2022 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: raidframe,v 1.11 2021/08/03 05:15:20 mlelstv Exp $ +# $NetBSD: raidframe,v 1.12 2022/07/21 07:49:36 kre Exp $ # # PROVIDE: raidframe @@ -9,21 +9,43 @@ $_rc_subr_loaded . /etc/rc.subr -name="raidframe" +name=raidframe rcvar=$name -start_cmd="raidframe_start" -stop_cmd=":" +start_cmd=raidframe_start +stop_cmd=: raidframe_start() { # Configure non-auto-configured raid devices. - # Ensure order by globbing raid[0-9].conf before raid[1-9][0-9].conf. - # - for cfg in /etc/raid[0-9].conf /etc/raid[1-9][0-9].conf ; do - [ ! -f $cfg ] && continue + # Ensure order by globbing raid[0-9] before raid[1-9][0-9]. + # Assume no mixing of /etc/conf/raid/* and /etc/raid*.conf styles + + devices=$(sysctl -n hw.disknames) + for cfg in \ + /etc/conf/raid/raid[0-9] \ + /etc/conf/raid/raid[1-9][0-9] \ + /etc/conf/raid/raid[1-9][0-9][0-9] \ + /etc/raid[0-9].conf \ + /etc/raid[1-9][0-9].conf \ + ; do + [ -f "$cfg" ] && [ -s "$cfg" ] || continue + dev=${cfg##*/} - dev=${dev%%.conf} - raidctl -c $cfg $dev + dev=${dev%.conf} + + # This test should never fail with the possible + # config file patterns included, but for safety + case "${dev}" in + raid[0-9]|raid[1-9][0-9]|raid[1-9][0-9][0-9]) ;; + *) : "$dev not raidNN"; continue;; + esac + + case " ${devices} " in + *" ${dev} "*) : "$dev configured already"; continue;; + esac + + raidctl -c "$cfg" "$dev" && + devices="${devices} ${dev}" done }