mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 06:57:57 +00:00
8eadec40bd
The init script generated something like "DEVICE=/dev/sda" when it should have been generating "DEVICE /dev/sda". mdadm errors on this. Patch by jow. Also changed the default sendmail path to /usr/sbin/sendmail. No package in LEDE provides /sbin/sendmail. msmtp provides /usr/sbin/sendmail so use that. Also add a patch to fix file paths for mdadm runtime files. mdadm currently errors on them since /run is missing. Once /run is added to stock LEDE, this patch can be removed. Signed-off-by: Rosen Penev <rosenp@gmail.com> [rewrap commit message] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
94 lines
1.9 KiB
Bash
94 lines
1.9 KiB
Bash
#!/bin/sh /etc/rc.common
|
|
|
|
START=13
|
|
STOP=98
|
|
|
|
USE_PROCD=1
|
|
PROG=/sbin/mdadm
|
|
NAME=mdadm
|
|
|
|
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 email devices
|
|
|
|
if [ -x /usr/sbin/sendmail ]; then
|
|
config_get email "$cfg" email
|
|
[ -n "$email" ] && printf "MAILADDR %s\n" "$email" >> $CONF
|
|
fi
|
|
|
|
config_list_foreach "$cfg" devices append_list_item devices " "
|
|
[ -n "$devices" ] && printf "DEVICE %s\n" "$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
|
|
fi
|
|
|
|
[ -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() {
|
|
local email
|
|
|
|
mkdir -p "${CONF%/*}"
|
|
printf "# Autogenerated from /etc/config/mdadm, do not edit!\n" > $CONF
|
|
|
|
config_load mdadm
|
|
config_foreach mdadm_common mdadm
|
|
config_foreach mdadm_array array
|
|
|
|
$PROG --assemble --scan --config="$CONF"
|
|
|
|
procd_open_instance
|
|
procd_set_param command "$PROG" --monitor --syslog --scan --config="$CONF"
|
|
procd_close_instance
|
|
}
|
|
|
|
stop_service() {
|
|
$PROG --stop --scan
|
|
}
|
|
|