Some fixes for non woring sudo

This commit is contained in:
2026-09-02 00:18:04 +03:00
parent 96ae9abcb7
commit e7f3522671
2 changed files with 9 additions and 1 deletions
+4
View File
@@ -83,6 +83,10 @@ If this command fails, configure the remote account's `sudoers` entry for the
necessary `zfs` commands with `NOPASSWD` before running the migration. Do not necessary `zfs` commands with `NOPASSWD` before running the migration. Do not
put a password in the script or on its command line. put a password in the script or on its command line.
`REMOTE_HOST` must be a complete hostname or address, such as
`root@192.0.2.10` or `admin@new-server`. `root@` is invalid because it has no
host after the `@`.
Options: Options:
| Option | Description | | Option | Description |
+5 -1
View File
@@ -83,14 +83,18 @@ REMOTE_HOST="$2"
DESTINATION_ROOT="${3%/}" DESTINATION_ROOT="${3%/}"
SNAPSHOT_NAME="move-$(date +%Y%m%d-%H%M%S)" SNAPSHOT_NAME="move-$(date +%Y%m%d-%H%M%S)"
[[ "$REMOTE_HOST" != *@ ]] || die "REMOTE_HOST is missing a hostname; use user@server-name or server-name"
command -v zfs >/dev/null || die "zfs command was not found" command -v zfs >/dev/null || die "zfs command was not found"
command -v zpool >/dev/null || die "zpool command was not found" command -v zpool >/dev/null || die "zpool command was not found"
command -v ssh >/dev/null || die "ssh command was not found" command -v ssh >/dev/null || die "ssh command was not found"
zpool list -H -o name "$SOURCE_POOL" >/dev/null || die "source pool does not exist: $SOURCE_POOL" zpool list -H -o name "$SOURCE_POOL" >/dev/null || die "source pool does not exist: $SOURCE_POOL"
if ! $DRY_RUN; then if ! $DRY_RUN; then
ssh "${SSH_OPTIONS[@]}" "$REMOTE_HOST" true \
|| die "cannot authenticate to $REMOTE_HOST with SSH keys or an SSH agent"
ssh "${SSH_OPTIONS[@]}" "$REMOTE_HOST" 'sudo -n zfs list -H -o name -t filesystem >/dev/null' \ ssh "${SSH_OPTIONS[@]}" "$REMOTE_HOST" 'sudo -n zfs list -H -o name -t filesystem >/dev/null' \
|| die "cannot connect with non-interactive SSH or run 'sudo -n zfs' on $REMOTE_HOST" || die "$REMOTE_HOST accepts SSH, but cannot run 'sudo -n zfs'; configure passwordless sudo for zfs"
fi fi
map_destination() { map_destination() {