fix: Preserve CRLF line endings in DOS BAT files during sync

Critical fix for DOS 6.22 compatibility - CRLF line endings were being
converted to LF during AD2-to-NAS sync, causing BAT files to fail on DOS.

Root Cause:
- OpenSSH scp uses SFTP protocol by default (text mode)
- SFTP converts line endings (CRLF → LF)
- DOS 6.22 requires CRLF for batch file execution

Solution - Fixed AD2 Sync Script:
- Added -O flag to scp commands in Sync-FromNAS.ps1
- Forces legacy SCP protocol (binary mode)
- Preserves CRLF line endings during transfer

Created deployment scripts:
- fix-ad2-scp-line-endings.ps1: Updates Sync-FromNAS.ps1 with -O flag
- deploy-all-bat-files.ps1: Deploy 6 BAT files to AD2 (UPDATE, NWTOC,
  CTONW, CHECKUPD, REBOOT, DEPLOY)
- deploy-bat-to-nas-direct.ps1: Direct SCP to NAS with -O flag for
  immediate testing
- verify-nas-crlf.ps1: Validates CRLF preservation on NAS

Created diagnostic scripts:
- check-line-endings.ps1: Compare original vs NAS file line endings
- check-ad2-sync-log.ps1: Monitor sync log on AD2
- check-ad2-bat-files.ps1: Verify files on AD2
- check-scp-commands.ps1: Analyze SCP command usage
- trigger-ad2-sync-now.ps1: Manual sync trigger for testing

Verification:
- DEPLOY.BAT: 9,753 bytes with CRLF (was 9,408 bytes with LF)
- All 6 BAT files deployed to NAS with CRLF preserved
- DOS machines can now execute batch files from T:\

Files deployed:
- DEPLOY.BAT (one-time installer)
- UPDATE.BAT (backup utility)
- NWTOC.BAT (network to computer updates)
- CTONW.BAT (computer to network uploads)
- CHECKUPD.BAT (check for updates)
- REBOOT.BAT (reboot utility)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 16:35:33 -07:00
parent ffef5bdf8f
commit f35d65beaa
16 changed files with 1814 additions and 0 deletions

36
verify-nas-crlf.ps1 Normal file
View File

@@ -0,0 +1,36 @@
# Verify CRLF preservation after sync fix
Write-Host "[INFO] Verifying CRLF on files from NAS..."
Write-Host ""
# Copy fresh from NAS using -O flag (binary mode)
Write-Host "[INFO] Copying DEPLOY.BAT from NAS..."
& 'C:\Windows\System32\OpenSSH\scp.exe' -O root@192.168.0.9:/data/test/DEPLOY.BAT ./DEPLOY_VERIFY.BAT 2>$null
if (Test-Path "DEPLOY_VERIFY.BAT") {
$Content = Get-Content "DEPLOY_VERIFY.BAT" -Raw
$Size = (Get-Item "DEPLOY_VERIFY.BAT").Length
Write-Host "[INFO] File size: $Size bytes"
if ($Content -match "`r`n") {
Write-Host "[SUCCESS] CRLF preserved on NAS!"
} else {
Write-Host "[ERROR] Still LF only - sync may not have run yet"
}
# Compare with original
$OrigSize = (Get-Item "DEPLOY.BAT").Length
Write-Host "[INFO] Original size: $OrigSize bytes"
if ($Size -eq $OrigSize) {
Write-Host "[OK] Sizes match - line endings preserved"
} else {
Write-Host "[WARNING] Size mismatch - may need another sync cycle"
}
} else {
Write-Host "[ERROR] Failed to copy from NAS"
}
Write-Host ""
Write-Host "[INFO] Note: If still LF only, wait for next sync cycle (every 15 min)"