fi
# Generate the key-load .service unit
- cat > "${dest_norm}/${keyloadunit}" << EOF
-# Automatically generated by zfs-mount-generator
+ #
+ # Note: It is tempting to use a `<<EOF` style here-document for this, but
+ # bash requires a writable /tmp or $TMPDIR for that. This is not always
+ # available early during boot.
+ #
+ echo \
+"# Automatically generated by zfs-mount-generator
[Unit]
Description=Load ZFS key for ${dataset}
Type=oneshot
RemainAfterExit=yes
ExecStart=${keyloadcmd}
-ExecStop=@sbindir@/zfs unload-key '${dataset}'
-EOF
+ExecStop=@sbindir@/zfs unload-key '${dataset}'" > "${dest_norm}/${keyloadunit}"
fi
# Update the dependencies for the mount file to require the
# key-loading unit.
# Create the .mount unit file.
# By ordering before zfs-mount.service, we avoid race conditions.
- cat > "${dest_norm}/${mountfile}" << EOF
-# Automatically generated by zfs-mount-generator
+ #
+ # (Do not use `<<EOF`-style here-documents for this, see warning above)
+ #
+ echo \
+"# Automatically generated by zfs-mount-generator
[Unit]
SourcePath=${cachefile}
Where=${p_mountpoint}
What=${dataset}
Type=zfs
-Options=defaults${opts},zfsutil
-EOF
+Options=defaults${opts},zfsutil" > "${dest_norm}/${mountfile}"
# Finally, create the appropriate dependency
ln -s "../${mountfile}" "${req_dir}"