04-ago: [videoclub] comando pelis (novedades castellano + comando listo + adultos efimeros 5min) + unidad NAS montada en sobremesa + lecciones
This commit is contained in:
49
vigilancia/montar_nas.ps1
Normal file
49
vigilancia/montar_nas.ps1
Normal file
@@ -0,0 +1,49 @@
|
||||
# montar_nas.ps1 - Monta la unidad Z: (share \video de la NAS Synology 192.168.50.31)
|
||||
# via tunel SSH encadenado: PC -> VPS(185.187.169.109) -> Pi(tunel inverso 1445) -> NAS
|
||||
#
|
||||
# Requisitos:
|
||||
# - Clave SSH del VPS en C:\Users\juanm\Documents\GitHub\contabo
|
||||
# - Servicio autossh-tunel en la Pi con -R 1445:192.168.50.31:445
|
||||
# - Credencial SMB guardada con: cmdkey /add:127.0.0.1 /user:jjminguez /pass:"<pass>"
|
||||
#
|
||||
# Uso: powershell -File montar_nas.ps1
|
||||
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
||||
function Test-Tunel {
|
||||
$c = Get-NetTCPConnection -LocalPort 445 -State Listen -ErrorAction SilentlyContinue
|
||||
return ($null -ne $c)
|
||||
}
|
||||
|
||||
function Test-Unidad {
|
||||
$d = Get-PSDrive -Name Z -ErrorAction SilentlyContinue
|
||||
return ($null -ne $d)
|
||||
}
|
||||
|
||||
# 1) Levantar tunel local (445 -> VPS:1445 -> Pi -> NAS:445)
|
||||
if (-not (Test-Tunel)) {
|
||||
Write-Host "[NAS] Levantando tunel 445 -> VPS:1445..."
|
||||
Start-Process -FilePath "ssh" -ArgumentList `
|
||||
"-i", "C:\Users\juanm\Documents\GitHub\contabo", `
|
||||
"-N", "-L", "445:127.0.0.1:1445", `
|
||||
"root@185.187.169.109", `
|
||||
"-o", "ExitOnForwardFailure=yes", `
|
||||
"-o", "ServerAliveInterval=30", `
|
||||
"-o", "ServerAliveCountMax=3" `
|
||||
-WindowStyle Hidden | Out-Null
|
||||
Start-Sleep -Seconds 5
|
||||
}
|
||||
|
||||
# 2) Montar unidad Z: apuntando al share video (via tunel local)
|
||||
if (-not (Test-Unidad)) {
|
||||
Write-Host "[NAS] Montando Z: -> \\127.0.0.1\video ..."
|
||||
net use Z: \\127.0.0.1\video /persistent:no | Out-Null
|
||||
}
|
||||
|
||||
# 3) Verificar
|
||||
if (Test-Unidad) {
|
||||
$n = (Get-ChildItem "Z:\" -ErrorAction SilentlyContinue | Measure-Object).Count
|
||||
Write-Host "[NAS] Unidad Z: montada OK ($n elementos)"
|
||||
} else {
|
||||
Write-Host "[NAS] ERROR: no se pudo montar Z:"
|
||||
}
|
||||
Reference in New Issue
Block a user