Changed method for setting up run command.

This commit is contained in:
Otho 2023-01-16 22:04:39 -05:00
parent 7651cf44ec
commit ab3edb1d51
Signed by: Otho
GPG Key ID: 16C720CD3BBE21D9

View File

@ -98,18 +98,15 @@ list_remote_datasets() {
*) zroot="$zroot/" ;; *) zroot="$zroot/" ;;
esac esac
fi fi
if [ $BG_TEST_MODE = "TRUE" ]; then run_cmd="
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr\ sh -c 'for dataset in $SEND_DATASETS; do
"sh -c 'for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2` dataset=`echo \\$dataset|cut -d: -f2`
zfs list -H $zroot\$dataset; zfs list -H $zroot\$dataset;
done'" done'"
if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
else else
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
"sh -c 'for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs list -H $zroot\$dataset;
done';"
fi fi
done < sendnodes.tmp done < sendnodes.tmp
} }
@ -154,18 +151,17 @@ zfs_allow_mirrors()
*) zroot="$zroot/" ;; *) zroot="$zroot/" ;;
esac esac
fi fi
run_cmd="
for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done
"
if [ $BG_TEST_MODE = "TRUE" ]; then if [ $BG_TEST_MODE = "TRUE" ]; then
echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ echo ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
"for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
else else
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr $run_cmd
"for dataset in $SEND_DATASETS; do
dataset=`echo \\$dataset|cut -d: -f2`
zfs allow -u $user $MIRROR_PERMS $zroot\$dataset
done"
fi fi
done < sendnodes.tmp done < sendnodes.tmp
} }
@ -197,17 +193,17 @@ send_latest()
dataset=`echo $dataset|cut -d: -f1` dataset=`echo $dataset|cut -d: -f1`
debug "Processing $dataset (remote $remote_dataset)." debug "Processing $dataset (remote $remote_dataset)."
origin_snapshot=`get_latest_snapshot $dataset` origin_snapshot=`get_latest_snapshot $dataset`
if [ $BG_TEST_MODE = "TRUE" ]; then run_cmd="
echo zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot \| \
pv -qL ${speed:-$DEF_SPEED} \| \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
else
zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot | zfs send $ZFS_SEND_OPTS $dataset@$origin_snapshot |
pv -qL ${speed:-$DEF_SPEED} | pv -qL ${speed:-$DEF_SPEED} |
ssh $SSH_SEND_OPTS -o port=$ssh_port \ ssh $SSH_SEND_OPTS -o port=$ssh_port \
$user@$addr \ $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
"
if [ $BG_TEST_MODE = "TRUE" ]; then
echo $run_cmd
else
$run_cmd
fi fi
done done
done < sendnodes.tmp done < sendnodes.tmp
@ -228,20 +224,18 @@ send_increment()
dataset=`echo $dataset|cut -d: -f1` dataset=`echo $dataset|cut -d: -f1`
origin_snapshot=`get_latest_snapshot` origin_snapshot=`get_latest_snapshot`
remote_snapshot=`get_latest_remote_snapshot` remote_snapshot=`get_latest_remote_snapshot`
if [ $BG_TEST_MODE = "TRUE" ]; then run_cmd="
echo zfs send $ZFS_SEND_OPTS \
-i $dataset@$remote_snapshot \
$dataset@$origin_snapshot \| \
pv -qL ${speed:-$DEF_SPEED} \| \
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
else
zfs send $ZFS_SEND_OPTS \ zfs send $ZFS_SEND_OPTS \
-i $dataset@$remote_snapshot \ -i $dataset@$remote_snapshot \
$dataset@$origin_snapshot | $dataset@$origin_snapshot |
pv -qL ${speed:-$DEF_SPEED} | pv -qL ${speed:-$DEF_SPEED} |
ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \ ssh $SSH_SEND_OPTS -o port=$ssh_port $user@$addr \
zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset zfs recv $ZFS_RECV_OPTS $zroot$remote_dataset
"
if [ $BG_TEST_MODE = "TRUE" ]; then
echo $run_cmd
else
$run_cmd
fi fi
done done
done < sendnodes.tmp done < sendnodes.tmp