Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions 90zfsbootmenu/zfsbootmenu-exec.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash

export import_args
export spl_hostid
export force_import
export read_write
export menu_timeout
export root

# https://busybox.net/FAQ.html#job_control
exec setsid sh -c 'exec /bin/zfsbootmenu </dev/tty1 >/dev/tty1 2>&1'
exec setsid bash -c 'exec /bin/zfsbootmenu </dev/tty1 >/dev/tty1 2>&1'
23 changes: 19 additions & 4 deletions 90zfsbootmenu/zfsbootmenu-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,27 @@ find_online_pools() {
# returns: 0 on success, 1 on failure

import_pool() {
local pool
local pool import_args

pool="${1}"

# Import /never/ mounts filesystems
import_args=( "-N" )

# shellcheck disable=SC2154
if [ "${force_import}" ]; then
import_args+=( "-f" )
fi

# shellcheck disable=SC2154
if [ "${read_write}" ]; then
import_args+=( "-o" "readonly=on" )
else
import_args+=( "-o" "readonly=off" )
fi

# shellcheck disable=SC2086
status="$( zpool import ${import_args} ${pool} )"
status="$( zpool import "${import_args[@]}" ${pool} )"
ret=$?

return ${ret}
Expand Down Expand Up @@ -641,9 +657,8 @@ set_rw_pool() {
fi
fi

import_args="${import_args/readonly=on/readonly=off}"
if export_pool "${pool}" ; then
import_pool "${pool}"
read_write=yes import_pool "${pool}"
return $?
fi

Expand Down
8 changes: 4 additions & 4 deletions 90zfsbootmenu/zfsbootmenu-parse-commandline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ fi

# Force import pools only when explicitly told to do so
if getargbool 0 force_import ; then
# shellcheck disable=SC2034
force_import="yes"
info "ZFSBootMenu: Enabling force import of ZFS pools"
import_args="-o readonly=on -f -N"
else
import_args="-o readonly=on -N"
fi

# Import pools by default in read-write mode
if getargbool 0 read_write ; then
# shellcheck disable=SC2034
read_write="yes"
info "ZFSBootMenu: Enabling read-write ZFS pool import"
import_args="${import_args/readonly=on/readonly=off}"
fi

# Set a menu timeout, to allow immediate booting
Expand Down