Compare commits

...

4 Commits

View File

@@ -107,8 +107,9 @@ function zpool_drive_id () {
} }
function set_zpool_password () { function set_zpool_password () {
printf -- '%s\n' 'password' > '/etc/zfs/'"${zpool_name}"'.key' # No newline at the end
chmod '000' '/etc/zfs/'"${zpool_name}"'.key' printf -- '%s' 'password' > '/etc/zfs/'"${zpool_name}"'.key'
chmod '600' '/etc/zfs/'"${zpool_name}"'.key'
} }
function import_pool () { function import_pool () {
@@ -250,8 +251,10 @@ function set_locale () {
} }
function add_zfs_hook_to_initramfs () { function add_zfs_hook_to_initramfs () {
# Add zfs hook, remove fsck hook from initramfs # Add zfs hook, remove fsck hook from initramfs. Also add plain text key
# file into initramfs since it's living inside an encrypted pool anyway.
sed -ri \ sed -ri \
-e 's'$'\x1''^(FILES=)[^\r\n\f]*'$'\x1''\1(/etc/zfs/'"${zpool_name}"'.key)'$'\x1''g' \
-e 's'$'\x1''(HOOKS=)(.*?[\(| ])(filesystems)([\)| ][^\r\n\f]*)'$'\x1''\1\2zfs \3\4'$'\x1''g' \ -e 's'$'\x1''(HOOKS=)(.*?[\(| ])(filesystems)([\)| ][^\r\n\f]*)'$'\x1''\1\2zfs \3\4'$'\x1''g' \
-e 's'$'\x1''((\()(fsck)(\)))'$'\x1''\2\4'$'\x1''g' \ -e 's'$'\x1''((\()(fsck)(\)))'$'\x1''\2\4'$'\x1''g' \
-e 's'$'\x1''(([[:space:]]+)(fsck)|(fsck)([[:space:]]+))'$'\x1'''$'\x1''g' \ -e 's'$'\x1''(([[:space:]]+)(fsck)|(fsck)([[:space:]]+))'$'\x1'''$'\x1''g' \
@@ -269,7 +272,7 @@ function set_initramfs_build_list () {
} }
function add_zfs_files_to_new_os () { function add_zfs_files_to_new_os () {
for zfs_file in '/etc/hostid' '/etc/zfs/zpool.cache' '/etc/zfs/zpool.key'; do for zfs_file in '/etc/hostid' '/etc/zfs/zpool.cache' '/etc/zfs/'"${zpool_name}"'.key'; do
rsync -av --itemize-changes {'','/mnt'}"${zfs_file}" rsync -av --itemize-changes {'','/mnt'}"${zfs_file}"
done done
} }