mirror of https://github.com/hak5/openwrt-owl.git
mdadm: extend uci config support
Extend the mdadm package to allow to explicitely configure arrays as well as device list entries. Signed-off-by: Jo-Philipp Wich <jo@mein.io>owl
parent
1449b52f02
commit
813efe57e4
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=mdadm
|
PKG_NAME:=mdadm
|
||||||
PKG_VERSION:=3.2.5
|
PKG_VERSION:=3.2.5
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm
|
PKG_SOURCE_URL:=@KERNEL/linux/utils/raid/mdadm
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
config mdadm
|
config mdadm
|
||||||
option email root
|
option email root
|
||||||
|
# list devices /dev/hd*
|
||||||
|
# list devices /dev/sd*
|
||||||
|
# list devices partitions
|
||||||
|
|
||||||
|
config array
|
||||||
|
option uuid 52c5c44a:d2162820:f75d3464:799750f8
|
||||||
|
option device /dev/md0
|
||||||
|
# option name raid:0
|
||||||
|
# option super_minor 0
|
||||||
|
# list devices /dev/sda1
|
||||||
|
# list devices /dev/sdb1
|
||||||
|
# option spares 0
|
||||||
|
# option spare_group spares
|
||||||
|
# option bitmap /bitmap.md
|
||||||
|
# option container 00000000:00000000:00000000:00000000
|
||||||
|
# option member 1
|
||||||
|
|
|
@ -7,24 +7,84 @@ USE_PROCD=1
|
||||||
PROG=/sbin/mdadm
|
PROG=/sbin/mdadm
|
||||||
NAME=mdadm
|
NAME=mdadm
|
||||||
|
|
||||||
mdadm_email() {
|
CONF="/var/etc/mdadm.conf"
|
||||||
|
|
||||||
|
append_list_item() {
|
||||||
|
append "$2" "$1" "$3"
|
||||||
|
}
|
||||||
|
|
||||||
|
append_option() {
|
||||||
|
local var="$1"
|
||||||
|
local cfg="$2"
|
||||||
|
local opt="$3"
|
||||||
|
local name="$4"
|
||||||
|
local sep="$5"
|
||||||
|
local str
|
||||||
|
|
||||||
|
if [ -n "$sep" ]; then
|
||||||
|
config_list_foreach "$cfg" "$opt" append_list_item str "$sep"
|
||||||
|
else
|
||||||
|
config_get str "$cfg" "$opt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -n "$str" ] && append "$var" $(printf "%s=%s" "${name:-${opt//_/-}}" "$str")
|
||||||
|
}
|
||||||
|
|
||||||
|
mdadm_common() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
if [ ! -x /sbin/sendmail ]; then
|
local email devices
|
||||||
|
|
||||||
|
if [ -x /sbin/sendmail ]; then
|
||||||
|
append_option email "$cfg" email "MAILADDR"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
append_option devices "$cfg" devices DEVICE " "
|
||||||
|
|
||||||
|
printf "%s\n%s\n" "$email" "$devices" >> $CONF
|
||||||
|
}
|
||||||
|
|
||||||
|
mdadm_array() {
|
||||||
|
local cfg="$1"
|
||||||
|
local uuid device devices name array
|
||||||
|
|
||||||
|
config_get uuid "$cfg" uuid
|
||||||
|
config_get name "$cfg" name
|
||||||
|
config_get device "$cfg" device
|
||||||
|
|
||||||
|
if [ -z "$device" ] || [ -z "$uuid$name" ]; then
|
||||||
|
echo "Skipping array without device, uuid or name" >&2
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
config_get email "$cfg" email
|
|
||||||
|
[ -n "$uuid" ] && append array "uuid=$uuid"
|
||||||
|
[ -n "$name" ] && append array "name=$name"
|
||||||
|
|
||||||
|
append_option array "$cfg" super_minor
|
||||||
|
append_option array "$cfg" spares
|
||||||
|
append_option array "$cfg" spare_group
|
||||||
|
append_option array "$cfg" bitmap
|
||||||
|
append_option array "$cfg" container
|
||||||
|
append_option array "$cfg" member
|
||||||
|
append_option array "$cfg" devices devices ","
|
||||||
|
|
||||||
|
printf "ARRAY %s %s\n" "$device" "$array" >> $CONF
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
local email
|
local email
|
||||||
|
|
||||||
config_load mdadm
|
mkdir -p "${CONF%/*}"
|
||||||
config_foreach mdadm_email mdadm
|
printf "# Autogenerated from /etc/config/mdadm, do not edit!\n" > $CONF
|
||||||
|
|
||||||
$PROG --assemble --scan
|
config_load mdadm
|
||||||
|
config_foreach mdadm_common mdadm
|
||||||
|
config_foreach mdadm_array array
|
||||||
|
|
||||||
|
$PROG --assemble --scan --config="$CONF"
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param command "$PROG" --monitor ${email:+--mail=$email} --syslog --scan
|
procd_set_param command "$PROG" --monitor --syslog --scan --config="$CONF"
|
||||||
procd_close_instance
|
procd_close_instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue