copyLocalFile takes in a full source filepath and a destination directory. The destination directory will be created in full if it does not exist, the file will be copied, and then the read and execute permissions set.
(sourceFilepath, destinationDirectory string)
| 451 | // copyLocalFile takes in a full source filepath and a destination directory. |
| 452 | // The destination directory will be created in full if it does not exist, the file will be copied, and then the read and execute permissions set. |
| 453 | func copyLocalFile(sourceFilepath, destinationDirectory string) error { |
| 454 | |
| 455 | // make destination directory if it doesn't exist |
| 456 | err := runCmd("mkdir", "-p", destinationDirectory) |
| 457 | if err != nil { |
| 458 | return err |
| 459 | } |
| 460 | |
| 461 | // copy the file |
| 462 | err = runCmd("cp", sourceFilepath, destinationDirectory) |
| 463 | if err != nil { |
| 464 | return err |
| 465 | } |
| 466 | |
| 467 | // make the file we just copied readable and executable (required for Couchbase server to use the certs) |
| 468 | return runCmd("chmod", "-R", "a+rwx", filepath.Join(destinationDirectory, filepath.Base(sourceFilepath))) |
| 469 | |
| 470 | } |
| 471 | |
| 472 | // runCmd runs a command and returns error if the command fails |
| 473 | func runCmd(arg ...string) error { |
no test coverage detected