2017-08-14 20:56:04 +03:00
|
|
|
#!/bin/bash
|
2011-07-04 21:25:31 +04:00
|
|
|
|
|
|
|
check() {
|
2011-07-25 00:46:16 +04:00
|
|
|
# We depend on udev-rules being loaded
|
2015-02-15 22:28:42 +03:00
|
|
|
[ "${1}" = "-d" ] && return 0
|
2011-07-04 21:25:31 +04:00
|
|
|
|
2011-07-25 00:46:16 +04:00
|
|
|
# Verify the zfs tool chain
|
2017-12-18 01:14:07 +03:00
|
|
|
for tool in "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs" ; do
|
2016-04-24 14:35:44 +03:00
|
|
|
test -x "$tool" || return 1
|
|
|
|
done
|
|
|
|
# Verify grep exists
|
|
|
|
which grep >/dev/null 2>&1 || return 1
|
2011-07-04 21:25:31 +04:00
|
|
|
|
2011-07-25 00:46:16 +04:00
|
|
|
return 0
|
2011-07-04 21:25:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
depends() {
|
2011-07-25 00:46:16 +04:00
|
|
|
echo udev-rules
|
|
|
|
return 0
|
2011-07-04 21:25:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
installkernel() {
|
2011-07-25 00:46:16 +04:00
|
|
|
instmods zfs
|
|
|
|
instmods zcommon
|
|
|
|
instmods znvpair
|
|
|
|
instmods zavl
|
|
|
|
instmods zunicode
|
2017-09-12 23:15:11 +03:00
|
|
|
instmods icp
|
2011-07-25 00:46:16 +04:00
|
|
|
instmods spl
|
|
|
|
instmods zlib_deflate
|
|
|
|
instmods zlib_inflate
|
2011-07-04 21:25:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
install() {
|
2011-08-10 01:39:47 +04:00
|
|
|
inst_rules @udevruledir@/90-zfs.rules
|
2013-03-20 22:25:50 +04:00
|
|
|
inst_rules @udevruledir@/69-vdev.rules
|
2011-08-10 01:39:47 +04:00
|
|
|
inst_rules @udevruledir@/60-zvol.rules
|
2016-04-24 14:35:44 +03:00
|
|
|
dracut_install hostid
|
|
|
|
dracut_install grep
|
2011-08-10 01:39:47 +04:00
|
|
|
dracut_install @sbindir@/zfs
|
|
|
|
dracut_install @sbindir@/zpool
|
2016-09-21 23:35:16 +03:00
|
|
|
# Workaround for zfsonlinux/zfs#4749 by ensuring libgcc_s.so(.1) is included
|
|
|
|
if [[ -n "$(ldd @sbindir@/zpool | grep -F 'libgcc_s.so')" ]]; then
|
|
|
|
# Dracut will have already tracked and included it
|
|
|
|
:;
|
|
|
|
elif command -v gcc-config 2>&1 1>/dev/null; then
|
|
|
|
# On systems with gcc-config (Gentoo, Funtoo, etc.):
|
|
|
|
# Use the current profile to resolve the appropriate path
|
2016-09-01 19:15:10 +03:00
|
|
|
dracut_install "/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1"
|
2017-10-10 00:34:26 +03:00
|
|
|
elif [[ -n "$(ls /usr/lib/libgcc_s.so* 2>/dev/null)" ]]; then
|
|
|
|
# Try a simple path first
|
|
|
|
dracut_install /usr/lib/libgcc_s.so*
|
2016-09-01 19:15:10 +03:00
|
|
|
else
|
2016-09-21 23:35:16 +03:00
|
|
|
# Fallback: Guess the path and include all matches
|
|
|
|
dracut_install /usr/lib/gcc/*/*/libgcc_s.so*
|
2016-09-01 19:15:10 +03:00
|
|
|
fi
|
2017-12-18 01:14:07 +03:00
|
|
|
dracut_install @mounthelperdir@/mount.zfs
|
2013-01-29 22:53:19 +04:00
|
|
|
dracut_install @udevdir@/vdev_id
|
2017-08-04 21:14:48 +03:00
|
|
|
dracut_install awk
|
|
|
|
dracut_install head
|
2011-08-10 01:39:47 +04:00
|
|
|
dracut_install @udevdir@/zvol_id
|
2015-02-15 22:28:42 +03:00
|
|
|
inst_hook cmdline 95 "${moddir}/parse-zfs.sh"
|
2016-03-31 02:59:15 +03:00
|
|
|
if [ -n "$systemdutildir" ] ; then
|
|
|
|
inst_script "${moddir}/zfs-generator.sh" "$systemdutildir"/system-generators/dracut-zfs-generator
|
|
|
|
fi
|
2018-01-18 21:20:34 +03:00
|
|
|
inst_hook pre-mount 90 "${moddir}/zfs-load-key.sh"
|
2016-04-24 14:35:44 +03:00
|
|
|
inst_hook mount 98 "${moddir}/mount-zfs.sh"
|
2016-10-17 21:51:15 +03:00
|
|
|
inst_hook cleanup 99 "${moddir}/zfs-needshutdown.sh"
|
2016-10-16 06:30:53 +03:00
|
|
|
inst_hook shutdown 20 "${moddir}/export-zfs.sh"
|
2011-09-30 21:33:26 +04:00
|
|
|
|
2015-02-15 22:28:42 +03:00
|
|
|
inst_simple "${moddir}/zfs-lib.sh" "/lib/dracut-zfs-lib.sh"
|
2013-03-20 22:25:50 +04:00
|
|
|
if [ -e @sysconfdir@/zfs/zpool.cache ]; then
|
|
|
|
inst @sysconfdir@/zfs/zpool.cache
|
2016-03-31 02:59:15 +03:00
|
|
|
type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/zpool.cache
|
2013-03-20 22:25:50 +04:00
|
|
|
fi
|
|
|
|
|
2015-02-16 06:08:04 +03:00
|
|
|
if [ -e @sysconfdir@/zfs/vdev_id.conf ]; then
|
|
|
|
inst @sysconfdir@/zfs/vdev_id.conf
|
2016-03-31 02:59:15 +03:00
|
|
|
type mark_hostonly >/dev/null 2>&1 && mark_hostonly @sysconfdir@/zfs/vdev_id.conf
|
2015-02-16 06:08:04 +03:00
|
|
|
fi
|
|
|
|
|
2011-09-30 21:33:26 +04:00
|
|
|
# Synchronize initramfs and system hostid
|
|
|
|
AA=`hostid | cut -b 1,2`
|
|
|
|
BB=`hostid | cut -b 3,4`
|
|
|
|
CC=`hostid | cut -b 5,6`
|
|
|
|
DD=`hostid | cut -b 7,8`
|
2015-02-15 22:28:42 +03:00
|
|
|
printf "\x${DD}\x${CC}\x${BB}\x${AA}" > "${initdir}/etc/hostid"
|
2016-03-31 02:59:15 +03:00
|
|
|
|
|
|
|
if dracut_module_included "systemd"; then
|
|
|
|
mkdir -p "${initdir}/$systemdsystemunitdir/initrd.target.wants"
|
|
|
|
for _item in scan cache ; do
|
|
|
|
dracut_install @systemdunitdir@/zfs-import-$_item.service
|
|
|
|
if ! [ -L "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service ]; then
|
|
|
|
ln -s ../zfs-import-$_item.service "${initdir}/$systemdsystemunitdir/initrd.target.wants"/zfs-import-$_item.service
|
|
|
|
type mark_hostonly >/dev/null 2>&1 && mark_hostonly @systemdunitdir@/zfs-import-$_item.service
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2011-07-04 21:25:31 +04:00
|
|
|
}
|