|
|
@@ -73,41 +73,57 @@ $srcPath = $extracted.FullName |
|
|
|
|
|
|
|
|
Log "Extracted to $srcPath" |
|
|
Log "Extracted to $srcPath" |
|
|
|
|
|
|
|
|
# Copy public/ folder contents to webroot (this is the IIS-served content) |
|
|
|
|
|
$publicSrc = Join-Path $srcPath "public" |
|
|
|
|
|
if (Test-Path $publicSrc) { |
|
|
|
|
|
# Copy all files from public/ to webroot root |
|
|
|
|
|
Copy-Item "$publicSrc\*" $WEBROOT -Recurse -Force |
|
|
|
|
|
Log "Copied public/ to webroot." |
|
|
|
|
|
} else { |
|
|
|
|
|
# If no public folder, copy everything |
|
|
|
|
|
Copy-Item "$srcPath\*" $WEBROOT -Recurse -Force |
|
|
|
|
|
Log "Copied all files to webroot." |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
# Deploy structure mirrors the repo layout: |
|
|
|
|
|
# IIS serves from $WEBROOT\public\ (Default.asp lives here) |
|
|
|
|
|
# core\, app\, db\ go alongside public\ so ../core/ includes resolve correctly |
|
|
|
|
|
|
|
|
|
|
|
$publicDst = Join-Path $WEBROOT "public" |
|
|
|
|
|
New-Item -ItemType Directory -Force -Path $publicDst | Out-Null |
|
|
|
|
|
|
|
|
# Copy core/, app/ alongside Default.asp (needed for ../core/ relative includes) |
|
|
|
|
|
foreach ($folder in @("core", "app", "db")) { |
|
|
|
|
|
|
|
|
foreach ($folder in @("public", "core", "app")) { |
|
|
$folderSrc = Join-Path $srcPath $folder |
|
|
$folderSrc = Join-Path $srcPath $folder |
|
|
$folderDst = Join-Path $WEBROOT $folder |
|
|
$folderDst = Join-Path $WEBROOT $folder |
|
|
if (Test-Path $folderSrc) { |
|
|
if (Test-Path $folderSrc) { |
|
|
if (Test-Path $folderDst) { Remove-Item $folderDst -Recurse -Force } |
|
|
if (Test-Path $folderDst) { Remove-Item $folderDst -Recurse -Force } |
|
|
Copy-Item $folderSrc $WEBROOT -Recurse -Force |
|
|
Copy-Item $folderSrc $WEBROOT -Recurse -Force |
|
|
Log "Copied $folder/ to webroot." |
|
|
|
|
|
|
|
|
Log "Copied $folder/." |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# Only update db/ if webdata.accdb doesn't exist yet (preserve live data) |
|
|
|
|
|
$dbSrc = Join-Path $srcPath "db" |
|
|
|
|
|
$dbDst = Join-Path $WEBROOT "db" |
|
|
|
|
|
if (Test-Path $dbSrc) { |
|
|
|
|
|
if (-not (Test-Path "$dbDst\webdata.accdb")) { |
|
|
|
|
|
if (Test-Path $dbDst) { Remove-Item $dbDst -Recurse -Force } |
|
|
|
|
|
Copy-Item $dbSrc $WEBROOT -Recurse -Force |
|
|
|
|
|
Log "Copied db/ (first deploy)." |
|
|
|
|
|
} else { |
|
|
|
|
|
# Only copy migration files, not the live database |
|
|
|
|
|
$migSrc = Join-Path $dbSrc "migrations" |
|
|
|
|
|
if (Test-Path $migSrc) { |
|
|
|
|
|
Copy-Item "$migSrc\*" "$dbDst\migrations\" -Recurse -Force |
|
|
|
|
|
Log "Updated db/migrations/." |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# Update web.config ConnectionString to point to correct DB path |
|
|
# Update web.config ConnectionString to point to correct DB path |
|
|
$webConfigPath = Join-Path $WEBROOT "web.config" |
|
|
|
|
|
|
|
|
$webConfigPath = Join-Path $publicDst "web.config" |
|
|
if (Test-Path $webConfigPath) { |
|
|
if (Test-Path $webConfigPath) { |
|
|
$wc = [System.IO.File]::ReadAllText($webConfigPath) |
|
|
$wc = [System.IO.File]::ReadAllText($webConfigPath) |
|
|
$newConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$WEBROOT\db\webdata.accdb;Persist Security Info=False;" |
|
|
$newConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$WEBROOT\db\webdata.accdb;Persist Security Info=False;" |
|
|
$wc = [regex]::Replace($wc, 'Provider=Microsoft\.ACE\.OLEDB[^"]+', $newConn) |
|
|
$wc = [regex]::Replace($wc, 'Provider=Microsoft\.ACE\.OLEDB[^"]+', $newConn) |
|
|
|
|
|
if ($wc -notmatch 'enableParentPaths') { |
|
|
|
|
|
$wc = $wc -replace '<system.webServer>', '<system.webServer><asp enableParentPaths="true" />' |
|
|
|
|
|
} |
|
|
[System.IO.File]::WriteAllText($webConfigPath, $wc) |
|
|
[System.IO.File]::WriteAllText($webConfigPath, $wc) |
|
|
Log "Updated web.config ConnectionString." |
|
|
|
|
|
|
|
|
Log "Updated web.config." |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# Grant IIS_IUSRS write access to db folder |
|
|
# Grant IIS_IUSRS write access to db folder |
|
|
$dbPath = Join-Path $WEBROOT "db" |
|
|
$dbPath = Join-Path $WEBROOT "db" |
|
|
|
|
|
New-Item -ItemType Directory -Force -Path $dbPath | Out-Null |
|
|
if (Test-Path $dbPath) { |
|
|
if (Test-Path $dbPath) { |
|
|
$acl = Get-Acl $dbPath |
|
|
$acl = Get-Acl $dbPath |
|
|
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow") |
|
|
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow") |
|
|
|