Currently get_ssh_size is not working as expected, it should return the
target's available space, but it will include df's header row string as
the result. Fix this issue by only use the last output line.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
mkdumprd | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/mkdumprd b/mkdumprd
index 4707fd9b..de4e9944 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -94,15 +94,14 @@ to_mount() {
#$1=dump target
#called from while loop and shouldn't read from stdin, so we're using "ssh
-n"
get_ssh_size() {
- local _opt _out
- _opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
- _out=$(ssh -q -n $_opt $1 "df -P $SAVE_PATH")
- [ $? -ne 0 ] && {
+ local _out
+
+ if ! _out=$(ssh -q -n -i "$SSH_KEY_LOCATION" -o BatchMode=yes -o
StrictHostKeyChecking=yes "$1" "df -P $SAVE_PATH"); then
perror_exit "checking remote ssh server available size failed."
- }
+ fi
#ssh output removed the line break, so print field NF-2
- echo -n "$_out" | awk '{avail=NF-2; print $avail}'
+ echo -n "$_out" | tail -1 | awk '{avail=NF-2; print $avail}'
}
#mkdir if save path does not exist on ssh dump target
--
2.31.1