Reorganize repo: compartmentalize scripts by client/project
Move 150+ scripts from root and scripts/ into client/project directories: - clients/dataforth/scripts/ (110 files: AD2, sync, SSH, DB, DOS scripts) - clients/bg-builders/scripts/ (14 files: Lesley mgmt, Exchange, termination) - clients/internal-infrastructure/scripts/ (10 files: GDAP, Gitea, backups) - projects/msp-tools/scripts/ (9 files: CIPP, MSP onboarding, Datto) - projects/gururmm-agent/scripts/ (3 files: API test, JWT, record counts) - clients/glaztech/scripts/ (1 file: CentraStage removal) Also reorganized: - VPN scripts → infrastructure/vpn-configs/ - Retrieved API/JS files → api/ - Forum posts → projects/community-forum/forum-posts/ - SSH docs → clients/internal-infrastructure/docs/ - NWTOC/CTONW docs → projects/wrightstown-smarthome/docs/ - ACG website files → projects/internal/acg-website-2025/ - Dataforth docs → clients/dataforth/docs/ - schema-retrieved.sql → docs/database/ Deleted 24 tmp_*.ps1 one-off debug scripts (preserved in git history). Root reduced from 220+ files to 62 items (docs + directories only). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
72
clients/dataforth/scripts/test-db-directly.ps1
Normal file
72
clients/dataforth/scripts/test-db-directly.ps1
Normal file
@@ -0,0 +1,72 @@
|
||||
# Test database directly to see if it's corrupted or locked
|
||||
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
|
||||
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
|
||||
|
||||
Write-Host "[OK] Mounting AD2 C$ share..." -ForegroundColor Green
|
||||
New-PSDrive -Name AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $cred -ErrorAction Stop | Out-Null
|
||||
|
||||
$dbPath = "AD2:\Shares\testdatadb\database\testdata.db"
|
||||
|
||||
Write-Host "[OK] Testing database file access..." -ForegroundColor Green
|
||||
|
||||
# Test 1: File exists and readable
|
||||
if (Test-Path $dbPath) {
|
||||
Write-Host " [OK] Database file exists" -ForegroundColor Green
|
||||
|
||||
$dbFile = Get-Item $dbPath
|
||||
Write-Host " [OK] Size: $([math]::Round($dbFile.Length/1MB,2)) MB" -ForegroundColor Cyan
|
||||
Write-Host " [OK] Modified: $($dbFile.LastWriteTime)" -ForegroundColor Cyan
|
||||
} else {
|
||||
Write-Host " [ERROR] Database file not found!" -ForegroundColor Red
|
||||
Remove-PSDrive -Name AD2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Test 2: Check file lock
|
||||
Write-Host "`n[OK] Checking if file is locked..." -ForegroundColor Green
|
||||
try {
|
||||
$stream = [System.IO.File]::Open($dbFile.FullName, 'Open', 'Read', 'ReadWrite')
|
||||
$stream.Close()
|
||||
Write-Host " [OK] File is not locked" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host " [WARNING] File may be locked by another process" -ForegroundColor Yellow
|
||||
Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Test 3: Check file header (SQLite magic bytes)
|
||||
Write-Host "`n[OK] Checking SQLite file header..." -ForegroundColor Green
|
||||
try {
|
||||
$bytes = [System.IO.File]::ReadAllBytes($dbFile.FullName) | Select-Object -First 16
|
||||
$header = [System.Text.Encoding]::ASCII.GetString($bytes)
|
||||
|
||||
if ($header.StartsWith("SQLite format 3")) {
|
||||
Write-Host " [OK] Valid SQLite database header detected" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " [ERROR] Invalid SQLite header! Database may be corrupted" -ForegroundColor Red
|
||||
Write-Host " Header bytes: $($bytes -join ' ')" -ForegroundColor Yellow
|
||||
}
|
||||
} catch {
|
||||
Write-Host " [ERROR] Cannot read database file: $($_.Exception.Message)" -ForegroundColor Red
|
||||
}
|
||||
|
||||
# Test 4: Check permissions
|
||||
Write-Host "`n[OK] Checking file permissions..." -ForegroundColor Green
|
||||
$acl = Get-Acl $dbPath
|
||||
Write-Host " Owner: $($acl.Owner)" -ForegroundColor Cyan
|
||||
Write-Host " Access Rules:" -ForegroundColor Cyan
|
||||
$acl.Access | ForEach-Object {
|
||||
Write-Host " $($_.IdentityReference): $($_.FileSystemRights) ($($_.AccessControlType))" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
# Test 5: Check if there are journal files
|
||||
Write-Host "`n[OK] Checking for journal files..." -ForegroundColor Green
|
||||
$journalFile = Get-Item "$($dbFile.DirectoryName)\testdata.db-journal" -ErrorAction SilentlyContinue
|
||||
if ($journalFile) {
|
||||
Write-Host " [FOUND] Journal file exists: $([math]::Round($journalFile.Length/1KB,2)) KB" -ForegroundColor Yellow
|
||||
Write-Host " [WARNING] This may indicate incomplete transaction or crash" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host " [OK] No journal file (clean state)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Remove-PSDrive -Name AD2 -ErrorAction SilentlyContinue
|
||||
Write-Host "`n[OK] Done" -ForegroundColor Green
|
||||
Reference in New Issue
Block a user