Avoid here-documents in systemd mount generator
On some systems - openSUSE, for example - there is not yet a writeable temporary file system available, so bash bails out with an error, 'cannot create temp file for here-document: Read-only file system', on the here documents in zfs-mount-generator. The simple fix is to change these into a multi-line echo statement. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-By: Richard Laager <rlaager@wiktel.com> Reviewed-by: George Melikov <mail@gmelikov.ru> Signed-off-by: Lorenz Hüdepohl <dev@stellardeath.org> Closes #9802
This commit is contained in:
parent
67709516db
commit
028e3b3b1a
|
@ -104,8 +104,13 @@ process_line() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate the key-load .service unit
|
# 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]
|
[Unit]
|
||||||
Description=Load ZFS key for ${dataset}
|
Description=Load ZFS key for ${dataset}
|
||||||
|
@ -120,8 +125,7 @@ ${pathdep}
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
ExecStart=${keyloadcmd}
|
ExecStart=${keyloadcmd}
|
||||||
ExecStop=@sbindir@/zfs unload-key '${dataset}'
|
ExecStop=@sbindir@/zfs unload-key '${dataset}'" > "${dest_norm}/${keyloadunit}"
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
# Update the dependencies for the mount file to require the
|
# Update the dependencies for the mount file to require the
|
||||||
# key-loading unit.
|
# key-loading unit.
|
||||||
|
@ -235,8 +239,11 @@ EOF
|
||||||
|
|
||||||
# Create the .mount unit file.
|
# Create the .mount unit file.
|
||||||
# By ordering before zfs-mount.service, we avoid race conditions.
|
# 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]
|
[Unit]
|
||||||
SourcePath=${cachefile}
|
SourcePath=${cachefile}
|
||||||
|
@ -249,8 +256,7 @@ Wants=${wants}
|
||||||
Where=${p_mountpoint}
|
Where=${p_mountpoint}
|
||||||
What=${dataset}
|
What=${dataset}
|
||||||
Type=zfs
|
Type=zfs
|
||||||
Options=defaults${opts},zfsutil
|
Options=defaults${opts},zfsutil" > "${dest_norm}/${mountfile}"
|
||||||
EOF
|
|
||||||
|
|
||||||
# Finally, create the appropriate dependency
|
# Finally, create the appropriate dependency
|
||||||
ln -s "../${mountfile}" "${req_dir}"
|
ln -s "../${mountfile}" "${req_dir}"
|
||||||
|
|
Loading…
Reference in New Issue