mdadm: Fix config generation
[openwrt/openwrt.git] / package / utils / mdadm / files / mdadm.init
index e6624a776ed0f5d34bd09a85c499237159b56166..64a50b35de27d7ddf63bb82808b1a0c2892404e5 100644 (file)
@@ -34,14 +34,13 @@ mdadm_common() {
        local cfg="$1"
        local email devices
 
-       if [ -x /sbin/sendmail ]; then
-               append_option email "$cfg" email "MAILADDR"
-
+       if [ -x /usr/sbin/sendmail ]; then
+               config_get email "$cfg" email
+               [ -n "$email" ] && printf "MAILADDR %s\n" "$email" >> $CONF
        fi
 
-       append_option devices "$cfg" devices DEVICE " "
-
-       printf "%s\n%s\n" "$email" "$devices" >> $CONF
+       config_list_foreach "$cfg" devices append_list_item devices " "
+       [ -n "$devices" ] && printf "DEVICE %s\n" "$devices" >> $CONF
 }
 
 mdadm_array() {