]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/90dmraid/module-setup.sh
Debian multiarch support
[thirdparty/dracut.git] / modules.d / 90dmraid / module-setup.sh
1 #!/bin/bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4
5 check() {
6 local _rootdev
7 # if we don't have dmraid installed on the host system, no point
8 # in trying to support it in the initramfs.
9 type -P dmraid >/dev/null || return 1
10
11 . $dracutfunctions
12 [[ $debug ]] && set -x
13
14 check_dmraid() {
15 local dev=$1 fs=$2 holder DEVPATH DM_NAME
16 [[ "$fs" = "${fs%%_raid_member}" ]] && return 1
17
18 DEVPATH=$(udevadm info --query=property --name=$dev \
19 | while read line; do
20 [[ ${line#DEVPATH} = $line ]] && continue
21 eval "$line"
22 echo $DEVPATH
23 break
24 done)
25 for holder in /sys/$DEVPATH/holders/*; do
26 [[ -e $holder ]] || continue
27 DM_NAME=$(udevadm info --query=property --path=$holder \
28 | while read line; do
29 [[ ${line#DM_NAME} = $line ]] && continue
30 eval "$line"
31 echo $DM_NAME
32 break
33 done)
34 done
35
36 [[ ${DM_NAME} ]] || return 1
37 if ! [[ $kernel_only ]]; then
38 echo " rd.dm.uuid=${DM_NAME} " >> "${initdir}/etc/cmdline.d/90dmraid.conf"
39 fi
40 return 0
41 }
42
43 [[ $hostonly ]] || [[ $mount_needs ]] && {
44 for_each_host_dev_fs check_dmraid || return 1
45 }
46
47 return 0
48 }
49
50 depends() {
51 echo dm rootfs-block
52 return 0
53 }
54
55 install() {
56 local _i
57 dracut_install dmraid partx kpartx
58
59 inst "$moddir/dmraid.sh" /sbin/dmraid_scan
60
61 if [ ! -x /lib/udev/vol_id ]; then
62 inst_rules 64-md-raid.rules
63 fi
64
65 inst_libdir_file "libdmraid-events*.so*"
66
67 inst_rules "$moddir/61-dmraid-imsm.rules"
68 #inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup
69 inst_hook pre-trigger 30 "$moddir/parse-dm.sh"
70 }