]> git.ipfire.org Git - thirdparty/dracut.git/blame - modules.d/90dmraid/module-setup.sh
add parameter --print-cmdline
[thirdparty/dracut.git] / modules.d / 90dmraid / module-setup.sh
CommitLineData
95d2dabc
HH
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
5check() {
29b10e65 6 local _rootdev
95d2dabc
HH
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
d351541e
HH
11 [[ $hostonly ]] || [[ $mount_needs ]] && {
12 for fs in "${host_fs_types[@]}"; do
13 [[ $fs = *_raid_member ]] && return 0
14 done
15 return 255
16 }
17
18 return 0
19}
20
21depends() {
22 echo dm rootfs-block
23 return 0
24}
25
1743473b
HH
26cmdline() {
27 local _activated
28 declare -A _activated
480d772f 29
1743473b
HH
30 for dev in "${!host_fs_types[@]}"; do
31 local holder DEVPATH DM_NAME majmin
32 [[ "${host_fs_types[$dev]}" != *_raid_member ]] && continue
69f7ed96
HH
33
34 majmin=$(get_maj_min $dev)
35 DEVPATH=$(
36 for i in /sys/block/*; do
37 [[ -e "$i/dev" ]] || continue
38 if [[ $a == $(<"$i/dev") ]]; then
39 printf "%s" "$i"
480d772f 40 break
69f7ed96
HH
41 fi
42 done
43 )
44
45 for holder in "$DEVPATH"/holders/*; do
46 [[ -e "$holder" ]] || continue
47 dev="/dev/${holder##*/}"
1743473b 48 DM_NAME="$(dmsetup info -c --noheadings -o name "$dev" 2>/dev/null)"
69f7ed96 49 [[ ${DM_NAME} ]] && break
480d772f
HH
50 done
51
1743473b
HH
52 [[ ${DM_NAME} ]] || continue
53
54 if ! [[ ${_activated[${DM_NAME}]} ]]; then
55 printf "%s" " rd.dm.uuid=${DM_NAME}"
56 _activated["${DM_NAME}"]=1
004fd055 57 fi
1743473b
HH
58 done
59}
60
61install() {
62 local _i
95d2dabc 63
1743473b 64 cmdline >> "${initdir}/etc/cmdline.d/90dmraid.conf"
95d2dabc 65
af119460
HH
66 inst_multiple dmraid
67 inst_multiple -o kpartx
24a38bc1 68 inst $(command -v partx) /sbin/partx
95d2dabc 69
95d2dabc
HH
70 inst "$moddir/dmraid.sh" /sbin/dmraid_scan
71
cce69be6 72 inst_rules 64-md-raid.rules
95d2dabc 73
c9143a63 74 inst_libdir_file "libdmraid-events*.so*"
760dcc6a 75
95d2dabc 76 inst_rules "$moddir/61-dmraid-imsm.rules"
7ef8ff9a 77 #inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup
95d2dabc 78 inst_hook pre-trigger 30 "$moddir/parse-dm.sh"
95d2dabc 79}