#!/bin/sh # Copyright © 2001-2005 Mario Jou/3en # Copyright © 2005-2006 Martin F. Krafft # Distributable under the terms of the GNU GPL version 2. # # $Id$ # . /usr/share/debconf/confmodule # See #369953 for ordering set -eu case "${1:-}" in configure|reconfigure) if [ ! -f /proc/mdstat ] && [ -x $(command -v modprobe) ]; then modprobe -k md >/dev/null 2>&1 || : fi if [ ! -f /proc/mdstat ]; then echo 'W: failed to load MD subsystem.' >&2 fi if [ ! -e /dev/md15 ] \ && [ ! -e /dev/.static/dev/md15 ] \ && [ ! -e /dev/.devfsd ]; then echo -n 'Generating array device nodes... ' >&2 cd /dev if /sbin/MAKEDEV md >&2 >/dev/null; then echo 'done.' >&2 else echo 'failed.' >&2 fi fi DEBIANCONFIG=/etc/default/mdadm CONFIG=/etc/mdadm/mdadm.conf ALTCONFIG=/etc/mdadm.conf MDADM=/sbin/mdadm if [ -z "${2:-}" ] && [ -s /etc/mdctl/mdctl.conf ] \ && [ ! -f /etc/mdadm/mdadm.conf ]; then cp -a /etc/mdctl/mdctl.conf /etc/mdadm/mdadm.conf fi [ ! -f $CONFIG ] && [ -f $ALTCONFIG ] && CONFIG=$ALTCONFIG if [ ! -f $CONFIG ]; then echo -n 'Generating mdadm.conf... ' >&2 if /usr/share/mdadm/mkconf generate $CONFIG 2>/dev/null; then echo done. >&2 else echo "failed (/proc probably not mounted)." >&2 rm -f $CONFIG fi elif dpkg --compare-versions "${2:-2.5.3-1}" le 2.5.3-1; then # we're upgrading from before 2.5.3-1 and there's apparently already # a configuration file which we cannot verify. We'll use the sentinel # during initramfs creation. md5sum $CONFIG > /var/lib/mdadm/CONF-UNCHECKED fi db_get mdadm/initrdstart INITRDSTART="${RET:-all}" db_get mdadm/autostart AUTOSTART="${RET:-true}" db_get mdadm/autocheck 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 # # You can run 'dpkg-reconfigure mdadm' to modify the values in this file, if # you want. You can also change the values here and changes will be preserved. # Do note that only the values are preserved; the rest of the file is # rewritten. # # INITRDSTART: # list of arrays (or 'all') to start automatically when the initial ramdisk # loads. This list *must* include the array holding your root filesystem. Use # 'none' to prevent any array from being started from the initial ramdisk. INITRDSTART='$INITRDSTART' # AUTOSTART: # should mdadm start arrays listed in /etc/mdadm/mdadm.conf automatically # during boot? AUTOSTART=$AUTOSTART # AUTOCHECK: # should mdadm run periodic redundancy checks over your arrays? See # /etc/cron.d/mdadm. AUTOCHECK=$AUTOCHECK # START_DAEMON: # should mdadm start the MD monitoring daemon during boot? START_DAEMON=$START_DAEMON # MAIL_TO # this variable is now managed in /etc/mdadm/mdadm.conf (MAILADDR). # Please see mdadm.conf(5). # USE_DEPRECATED_MDRUN= # mdrun is deprecated. If you still want to use it without a warning, set # the following to true. # # NOTE: changes to this variable will not be preserved! # 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 # changelog). Do this before update-initramfs, which copies udev into # initrd. V=2.5.3.git200608202239-1~ if [ "${1:-}" = "configure" ] && [ -n "${2:-}" ] \ && dpkg --compare-versions $2 ge 2.5.2-10 \ && dpkg --compare-versions $2 lt $V; then # first, disable the rules rm -f /etc/udev/rules.d/z60_mdadm.rules if echo "0843432c9c01ed95c42481eee0cf6fbf /etc/udev/mdadm.rules" \ | md5sum -c >/dev/null; then # no changes by user, so remove rm -f /etc/udev/mdadm.rules else echo "W: I tried to remove /etc/udev/mdadm.rules (see changelog), but you" >&2 echo "W: have modified it, so I won't touch it. Please remove the file" >&2 echo "W: at your leisure." >&2 fi fi command -v update-initramfs >/dev/null && update-initramfs -u -k all ;; esac # remove S04 installed as a fix to #294404 as it does not work # we only remove the startup links if the previous version was 1.9.0-2.1 (the # one with the erroneous fix) and the S04 link exists to make sure that # chances are minimised to overwrite admin changes (even though this would # not affect woody upgraders) if [ "${1:-}" = "configure" ] && [ "${2:-}" = "1.9.0-2.1" ] \ && test -L /etc/rcS.d/S04mdadm-raid; then update-rc.d -f mdadm-raid remove fi # See #369953 set +u #DEBHELPER# set -u # do start mdadm-raid, but don't use dh_installinit to do so, to prevent # stopping raids on remove/upgrade. if [ -x /etc/init.d/mdadm-raid ]; then if [ -x "$(command -v invoke-rc.d)" ]; then invoke-rc.d mdadm-raid start || exit $? else /etc/init.d/mdadm-raid start || exit $? fi fi