r203 - mdadm/trunk/debian
madduck at users.alioth.debian.org
madduck at users.alioth.debian.org
Fri Oct 6 11:46:44 UTC 2006
Author: madduck
Date: 2006-10-06 11:46:43 +0000 (Fri, 06 Oct 2006)
New Revision: 203
Modified:
mdadm/trunk/debian/changelog
mdadm/trunk/debian/mdadm.postinst
mdadm/trunk/debian/mkconf
Log:
improvements wrt mkconf and MAILADDR handling
Modified: mdadm/trunk/debian/changelog
===================================================================
--- mdadm/trunk/debian/changelog 2006-10-05 12:50:39 UTC (rev 202)
+++ mdadm/trunk/debian/changelog 2006-10-06 11:46:43 UTC (rev 203)
@@ -1,8 +1,12 @@
-mdadm (2.5.3.git200608202239-8) unstable; urgency=low
+mdadm (2.5.3.git200608202239-8) unstable; urgency=medium
* This revision is dedicated to Peter Samuelson for his RAID10 expertise^W
educated guess^W^W pure luck. (:
* Documentation updates.
+ * Now preserves MAILADDR from an existing mdadm.conf when generating a new
+ one.
+ * Now writes minimal mdadm.conf file even if the MD subsystem has not been
+ loaded.
* Updated debconf translations:
- German by Mario Joußen.
- Vietnamese by Clytie Siddall (closes: #390311).
Modified: mdadm/trunk/debian/mdadm.postinst
===================================================================
--- mdadm/trunk/debian/mdadm.postinst 2006-10-05 12:50:39 UTC (rev 202)
+++ mdadm/trunk/debian/mdadm.postinst 2006-10-06 11:46:43 UTC (rev 203)
@@ -43,9 +43,14 @@
cp -a /etc/mdctl/mdctl.conf /etc/mdadm/mdadm.conf
fi
+ db_get mdadm/mail_to
+ MAILADDR="${RET:-root}"
+
[ ! -f $CONFIG ] && [ -f $ALTCONFIG ] && CONFIG=$ALTCONFIG
if [ ! -f $CONFIG ]; then
echo -n 'Generating mdadm.conf... ' >&2
+ # pass the MAILADDR variable into the script
+ MDADM_MAILADDR__="$MAILADDR"; export MDADM_MAILADDR__
if /usr/share/mdadm/mkconf generate $CONFIG 2>/dev/null; then
echo done. >&2
else
@@ -59,6 +64,17 @@
md5sum $CONFIG > /var/lib/mdadm/CONF-UNCHECKED
fi
+ if [ -w $CONFIG ] && [ -z "${MDADM_MAILADDR__:-}" ]; then
+ # if the configuration is writeable but has not been written just
+ # before, then edit it to reflect the MAILADDR preference
+ if grep -q '^MAILADDR' $CONFIG; then
+ sed -i -e "s,^MAILADDR.*,MAILADDR $MAILADDR," $CONFIG
+ else
+ echo "MAILADDR $MAILADDR" >> $CONFIG
+ fi
+ fi
+ unset MDADM_MAILADDR__
+
db_get mdadm/initrdstart
INITRDSTART="${RET:-all}"
db_get mdadm/autostart
@@ -67,8 +83,6 @@
AUTOCHECK="${RET:-true}"
db_get mdadm/start_daemon
START_DAEMON="${RET:-true}"
- db_get mdadm/mail_to
- MAILADDR="${RET:-root}"
cat <<_eof > $DEBIANCONFIG
# mdadm Debian configuration
@@ -112,12 +126,6 @@
USE_DEPRECATED_MDRUN=false
_eof
- if grep -q '^MAILADDR' $CONFIG; then
- sed -i -e "s,^MAILADDR.*,MAILADDR $MAILADDR," $CONFIG
- else
- echo "MAILADDR $MAILADDR" >> $CONFIG
- fi
-
db_stop
# try to undo udev rules (installed by 2.5.2-10, see 2.5.3.git200608202239-1
Modified: mdadm/trunk/debian/mkconf
===================================================================
--- mdadm/trunk/debian/mkconf 2006-10-05 12:50:39 UTC (rev 202)
+++ mdadm/trunk/debian/mkconf 2006-10-06 11:46:43 UTC (rev 203)
@@ -12,21 +12,25 @@
MDADM=/sbin/mdadm
DEBIANCONFIG=/etc/default/mdadm
+CONFIG=/etc/mdadm/mdadm.conf
-if [ ! -d /proc/$$ ]; then
- echo E: /proc not available. Exiting... >&2
- exit 2
-fi
-
test -f $DEBIANCONFIG && . $DEBIANCONFIG
+if [ -n "$MDADM_MAILADDR__" ]; then
+ # honour MAILADDR from the environment (from postinst)
+ MAILADDR="$MDADM_MAILADDR__"
+else
+ # preserve existing MAILADDR
+ MAILADDR="$(sed -ne 's,MAILADDR ,,p' $CONFIG 2>/dev/null || echo root)"
+fi
+
generate=0
-CONFIG=/etc/mdadm/mdadm.conf
[ "${1:-}" = force-generate ] && rm -f $CONFIG
case "${1:-}" in
generate|force-generate)
[ -n "${2:-}" ] && CONFIG=$2
- if [ -e $CONFIG ]; then
+ # only barf if the config file specifies anything else than MAILADDR
+ if egrep -qv '^(MAILADDR.*|#.*|)$' $CONFIG 2>/dev/null; then
echo "E: ${##*/}: $CONFIG already exists." >&2
exit 3
fi
@@ -43,33 +47,25 @@
# Please refer to mdadm.conf(5) for information about this file.
#
-_eof
-
-if [ -r /proc/partitions ]; then
- cat <<_eof
-# scan all partitions (/proc/partitions) for MD superblocks"
+# by default, scan all partitions (/proc/partitions) for MD superblocks.
+# alternatively, specify devices to scan, using wildcards if desired.
DEVICE partitions
-_eof
-else
- echo E: cannot read /proc/partitions and thus cannot do my magic. >&2
- exit 1
-fi
-
-cat <<_eof
# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes
# automatically tag new arrays as belonging to the local system
HOMEHOST <system>
-# instruct the monitoring daemon to send mail alerts to root
-MAILADDR root
+# instruct the monitoring daemon where to send mail alerts
+MAILADDR $MAILADDR
_eof
if [ ! -r /proc/mdstat ]; then
echo W: MD subsystem is not loaded, thus I cannot scan for arrays. >&2
+elif [ ! -r /proc/partitions ]; then
+ echo W: /proc/partitions cannot be read, thus I cannot scan for arrays. >&2
else
echo "# definitions of existing MD arrays"
$MDADM --examine --scan --config=partitions
More information about the pkg-mdadm-commits
mailing list