Ensure .ssh directory exists before copying SSH files from Nextcloud
This commit is contained in:
@@ -30,8 +30,15 @@ $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|||||||
$sshSourceDir = "C:\Users\$uid\Nextcloud\Documents\Important_Docs\.ssh"
|
$sshSourceDir = "C:\Users\$uid\Nextcloud\Documents\Important_Docs\.ssh"
|
||||||
$sshDestDir = "C:\Users\$uid\.ssh"
|
$sshDestDir = "C:\Users\$uid\.ssh"
|
||||||
if (Test-Path -Path $sshSourceDir) {
|
if (Test-Path -Path $sshSourceDir) {
|
||||||
Copy-Item -Path $sshSourceDir -Destination $sshDestDir -Recurse -Force
|
# Ensure the destination .ssh directory exists
|
||||||
Write-Host "Copied SSH directory from Nextcloud to: $sshDestDir"
|
if (-not (Test-Path -Path $sshDestDir)) {
|
||||||
|
New-Item -Path $sshDestDir -ItemType Directory -Force | Out-Null
|
||||||
|
Write-Host "Created .ssh directory at: $sshDestDir"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy the contents of the .ssh directory (not the directory itself)
|
||||||
|
Copy-Item -Path "$sshSourceDir\*" -Destination $sshDestDir -Recurse -Force
|
||||||
|
Write-Host "Copied SSH files from Nextcloud to: $sshDestDir"
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Important_Docs/.ssh directory not found at: $sshSourceDir. Skipping SSH key copy." -ForegroundColor Yellow
|
Write-Host "Important_Docs/.ssh directory not found at: $sshSourceDir. Skipping SSH key copy." -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user