]>
Commit | Line | Data |
---|---|---|
fde4ce99 ZB |
1 | #!/bin/sh |
2 | ||
3 | check() { | |
1ef5e829 | 4 | # We depend on udev-rules being loaded |
e10b0808 | 5 | [ "${1}" = "-d" ] && return 0 |
fde4ce99 | 6 | |
1ef5e829 | 7 | # Verify the zfs tool chain |
cae5b340 AX |
8 | for tool in "@sbindir@/zpool" "@sbindir@/zfs" "@sbindir@/mount.zfs" ; do |
9 | test -x "$tool" || return 1 | |
10 | done | |
11 | # Verify grep exists | |
12 | which grep >/dev/null 2>&1 || return 1 | |
fde4ce99 | 13 | |
1ef5e829 | 14 | return 0 |
fde4ce99 ZB |
15 | } |
16 | ||
17 | depends() { | |
1ef5e829 ZB |
18 | echo udev-rules |
19 | return 0 | |
fde4ce99 ZB |
20 | } |
21 | ||
22 | installkernel() { | |
1ef5e829 ZB |
23 | instmods zfs |
24 | instmods zcommon | |
25 | instmods znvpair | |
26 | instmods zavl | |
27 | instmods zunicode | |
28 | instmods spl | |
29 | instmods zlib_deflate | |
30 | instmods zlib_inflate | |
fde4ce99 ZB |
31 | } |
32 | ||
33 | install() { | |
f0102d6e | 34 | inst_rules @udevruledir@/90-zfs.rules |
b9676003 | 35 | inst_rules @udevruledir@/69-vdev.rules |
f0102d6e | 36 | inst_rules @udevruledir@/60-zvol.rules |
cae5b340 AX |
37 | dracut_install hostid |
38 | dracut_install grep | |
f0102d6e KF |
39 | dracut_install @sbindir@/zfs |
40 | dracut_install @sbindir@/zpool | |
cae5b340 AX |
41 | # Workaround for zfsonlinux/zfs#4749 by ensuring libgcc_s.so(.1) is included |
42 | if [[ -n "$(ldd @sbindir@/zpool | grep -F 'libgcc_s.so')" ]]; then | |
43 | # Dracut will have already tracked and included it | |
44 | :; | |
45 | elif command -v gcc-config 2>&1 1>/dev/null; then | |
46 | # On systems with gcc-config (Gentoo, Funtoo, etc.): | |
47 | # Use the current profile to resolve the appropriate path | |
48 | dracut_install "/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1" | |
49 | else | |
50 | # Fallback: Guess the path and include all matches | |
51 | dracut_install /usr/lib/gcc/*/*/libgcc_s.so* | |
52 | fi | |
53 | dracut_install @sbindir@/mount.zfs | |
dbf763b3 | 54 | dracut_install @udevdir@/vdev_id |
ea04106b AX |
55 | dracut_install awk |
56 | dracut_install head | |
cae5b340 | 57 | dracut_install @udevdir@/zvol_id |
e10b0808 | 58 | inst_hook cmdline 95 "${moddir}/parse-zfs.sh" |
cae5b340 AX |
59 | if [ -n "$systemdutildir" ] ; then |
60 | inst_script "${moddir}/zfs-generator.sh" "$systemdutildir"/system-generators/dracut-zfs-generator | |
61 | fi | |
e10b0808 | 62 | inst_hook mount 98 "${moddir}/mount-zfs.sh" |
cae5b340 AX |
63 | inst_hook cleanup 99 "${moddir}/zfs-needshutdown.sh" |
64 | inst_hook shutdown 20 "${moddir}/export-zfs.sh" | |
e8753fb4 | 65 | |
e10b0808 | 66 | inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh" |
b9676003 BB |
67 | if [ -e @sysconfdir@/zfs/zpool.cache ]; then |
68 | inst @sysconfdir@/zfs/zpool.cache | |
cae5b340 | 69 | type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/zpool.cache |
b9676003 BB |
70 | fi |
71 | ||
ea04106b AX |
72 | if [ -e @sysconfdir@/zfs/vdev_id.conf ]; then |
73 | inst @sysconfdir@/zfs/vdev_id.conf | |
cae5b340 | 74 | type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/vdev_id.conf |
ea04106b AX |
75 | fi |
76 | ||
e8753fb4 | 77 | # Synchronize initramfs and system hostid |
e8753fb4 BB |
78 | AA=`hostid | cut -b 1,2` |
79 | BB=`hostid | cut -b 3,4` | |
80 | CC=`hostid | cut -b 5,6` | |
81 | DD=`hostid | cut -b 7,8` | |
e10b0808 | 82 | printf "\x${DD}\x${CC}\x${BB}\x${AA}" > "${initdir}/etc/hostid" |
cae5b340 AX |
83 | |
84 | if dracut_module_included "systemd"; then | |
85 | mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants" | |
86 | for _item in scan cache ; do | |
87 | dracut_install @systemdunitdir@/zfs-import-$_item.service | |
88 | if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service ]; then | |
89 | ln -s ../zfs-import-$_item.service "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service | |
90 | type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service | |
91 | fi | |
92 | done | |
93 | fi | |
fde4ce99 | 94 | } |