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