NetBSD/etc/rc.d/raidframe

54 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
#
# $NetBSD: raidframe,v 1.12 2022/07/21 07:49:36 kre Exp $
#
# PROVIDE: raidframe
# REQUIRE: devpubd
# BEFORE: DISKS
$_rc_subr_loaded . /etc/rc.subr
name=raidframe
rcvar=$name
start_cmd=raidframe_start
stop_cmd=:
raidframe_start()
{
# Configure non-auto-configured raid devices.
# 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}
# 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
}
load_rc_config $name
run_rc_command "$1"