Commit 0054748e authored by Yuanle Song's avatar Yuanle Song
Browse files

do not specify ssh config file if it doesn't exist.

parent 0ada5c66
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -65,5 +65,14 @@ let toMingwPath (windowsPath: string) =
        windowsPath
  result

// Convert Mingw64 path to windows path.
let toWinPath (mingwPath: string) =
  if mingwPath.StartsWith("/cygdrive/") then
    let driveLetter = mingwPath.Substring("/cygdrive/".Length, 1).ToUpper()
    let rest = mingwPath.Substring("/cygdrive/".Length + 1)
    driveLetter + ":" + rest.Replace('/', '\\')
  else
    null

let ensureDir (path: string) = if path.EndsWith "/" then path else path + "/"
let ensureWinDir (path: string) = if path.EndsWith "\\" then path else path + "\\"
+6 −1
Original line number Diff line number Diff line
@@ -180,7 +180,12 @@ let main argv =
    let sshExeFile = mbackupProgramDir + "rsync-w64/usr/bin/ssh.exe"
    let sshConfigFile = userHome + ".ssh/config"
    let sshPrivateKeyFile = results.GetResult(Ssh_Key, defaultValue = userHome + ".ssh/id_rsa") |> toMingwPath
    let rsyncCmd = List.append rsyncCmd [sprintf "-e \"'%s' -F %s -i %s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\"" sshExeFile sshConfigFile sshPrivateKeyFile]
    let sshConfigFileOption =
      if File.Exists(toWinPath sshConfigFile) then
        " -F " + sshConfigFile
      else
        ""
    let rsyncCmd = List.append rsyncCmd [sprintf "-e \"'%s'%s -i %s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\"" sshExeFile sshConfigFileOption sshPrivateKeyFile]

    // precedence: command line argument > environment variable > config file
    let normalizeTarget target =
+8 −0
Original line number Diff line number Diff line
@@ -27,6 +27,14 @@ let TesttoMingwPath () =
    Assert.That("/cygdrive/D/foo", Is.EqualTo(toMingwPath "/D/foo"))
    Assert.That("/var/log", Is.EqualTo(toMingwPath "/var/log"))

[<Test>]
let TesttoWinPath () =
    Assert.That("C:\\abc\\def", Is.EqualTo(toWinPath "/cygdrive/c/abc/def"))
    Assert.That("C:\\abc\\def\\", Is.EqualTo(toWinPath "/cygdrive/c/abc/def/"))
    Assert.That("C:\\", Is.EqualTo(toWinPath "/cygdrive/c/"))
    Assert.That("D:\\", Is.EqualTo(toWinPath "/cygdrive/d/"))
    Assert.That(null, Is.EqualTo(toWinPath "/etc/foo/"))

let mysprintf fmt = sprintf fmt

[<Test>]
+15 −0
Original line number Diff line number Diff line
@@ -194,6 +194,21 @@ Both local.list and local.exclude.
  - mbackup.msi works on B75I3 host.
  - try mbackup.msi on win 10 VM.
    how to require dotnet core 3.0 in .wxs file?
    search: wix NetFxExtension symbol for .net core 3
    asp.net mvc - Wix package ID for .NET core runtime 1.0.3 - Stack Overflow
    https://stackoverflow.com/questions/42908913/wix-package-id-for-net-core-runtime-1-0-3
    requires dotnet core 3 runtime on target node.
    backup to local dir works.
    backup to remote ssh node...
    - problems
      - 2019-11-14T10:50:13 ERROR Read/write file failed: System.Private.CoreLib Could not find a part of the path 'C:\Users\IEUser\AppData\Local\mbackup\mbackup.list'.
        Does the dir exist? no. Create it at runtime.
        fixed.
      - backup to remote ssh node.
        Warning: Identity file /cygdrive/c/Users/IEUser/.ssh/id_rsa not accessible: No such file or directory.
        Can't open user config file /cygdrive/c/Users/IEUser/.ssh/config: No such file or directory
        DONE do not specify config file if it doesn't exist.
        TODO fail fast if ssh key doesn't exist. mbackup will only support key based auth.

- problems
  - each file require it's own <Component> tag.