#!/bin/sh
#
# Copyright © 2006-2007 Martin F. Krafft <madduck@debian.org>
# based on the scripts in the initramfs-tools package.
# released under the terms of the Artistic Licence.
#
set -eu

PREREQ="udev"

prereqs()
{
	echo "$PREREQ"
}

case ${1:-} in
  prereqs)
    prereqs
    exit 0
    ;;
esac


. /usr/share/initramfs-tools/hook-functions

# copy the binary as early as possible
copy_exec /sbin/mdadm /sbin

# copy the udev rules
mkdir -p ${DESTDIR}/etc/udev/rules.d
for rules in 65-mdadm.vol_id.rules 85-mdadm.rules; do
	cp -p /etc/udev/rules.d/$rules ${DESTDIR}/etc/udev/rules.d
done

# copy the mdadm configuration
CONFIG=/etc/mdadm/mdadm.conf
ALTCONFIG=/etc/mdadm.conf
[ ! -f $CONFIG ] && [ -f $ALTCONFIG ] && CONFIG=$ALTCONFIG || :
mkdir -p ${DESTDIR}/etc/mdadm
cp -p $CONFIG ${DESTDIR}/etc/mdadm

# load raid modules in the initramfs
for module in linear multipath raid0 raid1 raid456 raid5 raid6 raid10; do
	force_load $module
done
