Explorar o código

Allow v-restore-user to restore backup from FTP and SFTP

Before this fix, sftpc() function had two 'else' blocks... so it was broken code... and script was unable to download file from SFTP
dpeca %!s(int64=9) %!d(string=hai) anos
pai
achega
b57c4dcd7b
Modificáronse 1 ficheiros con 10 adicións e 4 borrados
  1. 10 4
      bin/v-restore-user

+ 10 - 4
bin/v-restore-user

@@ -62,7 +62,11 @@ ftp_download() {
     if [ -z "$PORT" ]; then
     if [ -z "$PORT" ]; then
         PORT='21'
         PORT='21'
     fi
     fi
-    ftpc "cd $BPATH" "get $1"
+    if [ -z $BPATH ]; then
+        ftpc "get $1"
+    else
+        ftpc "cd $BPATH" "get $1"
+    fi
 }
 }
 
 
 # sftp command function
 # sftp command function
@@ -99,8 +103,6 @@ sftpc() {
                     set arg [lindex \$argv \$count]
                     set arg [lindex \$argv \$count]
                     send "\$arg\r"
                     send "\$arg\r"
                     incr count
                     incr count
-                } else {
-                    incr count
                 } else {
                 } else {
                     send "exit\r"
                     send "exit\r"
                     set output "Disconnected."
                     set output "Disconnected."
@@ -131,7 +133,11 @@ sftp_download() {
         PORT='22'
         PORT='22'
     fi
     fi
     cd $BACKUP
     cd $BACKUP
-    sftpc "cd $BPATH" "get $1" > /dev/null 2>&1
+    if [ -z $BPATH ]; then
+        sftpc "get $1" > /dev/null 2>&1
+    else
+        sftpc "cd $BPATH" "get $1" > /dev/null 2>&1
+    fi
 
 
 }
 }