GeoNetAgent, LDAPWeb, server-audit, server-connection
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
1.3 KiB

# Apply Jalur B (hybrid cPanel transport) for all @geonet.co.id except support@
# SSOT: Mailcow/docs/notes/hybrid-migration-cpanel-mailcow.md
# Usage:
# .\Mailcow\scripts\Apply-JalurB-LDAPUsers.ps1 -DryRun
# .\Mailcow\scripts\Apply-JalurB-LDAPUsers.ps1
# .\Mailcow\scripts\Apply-JalurB-LDAPUsers.ps1 -Only "byprakoso@geonet.co.id,user2@geonet.co.id"
#
# Wajib PowerShell. SSH: ssh mailcow (key id_ed25519_mailcow).
param(
[switch]$DryRun,
[string]$Only = "",
[string]$RemoteHost = "mailcow"
)
$ErrorActionPreference = 'Stop'
$ScriptDir = $PSScriptRoot
$LocalSh = Join-Path $ScriptDir 'setup-jalur-b-batch.sh'
$RemoteSh = '/tmp/setup-jalur-b-batch.sh'
if (-not (Test-Path $LocalSh)) {
throw "Script not found: $LocalSh"
}
# LF-only for bash on Linux
$tempSh = Join-Path $env:TEMP 'setup-jalur-b-batch.sh'
$content = (Get-Content $LocalSh -Raw) -replace "`r", ""
[System.IO.File]::WriteAllText($tempSh, $content)
Write-Host "Upload $LocalSh -> ${RemoteHost}:$RemoteSh"
scp $tempSh "${RemoteHost}:${RemoteSh}"
$argsRemote = 'bash ' + $RemoteSh
if ($DryRun) { $argsRemote += ' --dry-run' }
if ($Only) { $argsRemote += " --only '$Only'" }
$argsRemote += '; rm -f ' + $RemoteSh
Write-Host "Run: ssh $RemoteHost `"$argsRemote`""
ssh $RemoteHost $argsRemote
Remove-Item $tempSh -Force -ErrorAction SilentlyContinue
Write-Host "Finished."