Bläddra i källkod

Fix deploy script: preserve public/ subfolder structure for IIS

pull/5/head
Nano 6 dagar sedan
förälder
incheckning
081630155c
2 ändrade filer med 33 tillägg och 17 borttagningar
  1. +1
    -1
      ci/aspblogbrainordure-setup.ps1
  2. +32
    -16
      ci/deploy-aspblogbrainordure-test.ps1

+ 1
- 1
ci/aspblogbrainordure-setup.ps1 Visa fil

@@ -31,7 +31,7 @@ Write-Host "App pool configured (32-bit, v4.0)."
# Create IIS site
$existingSite = Get-Website -Name $SITENAME -ErrorAction SilentlyContinue
if ($existingSite) {
Write-Host "Site $SITENAME already exists skipping creation."
Write-Host "Site $SITENAME already exists - skipping creation."
} else {
New-Website -Name $SITENAME -PhysicalPath $WEBROOT -Port $PORT -ApplicationPool $APPPOOL
Write-Host "IIS site $SITENAME created on port $PORT."


+ 32
- 16
ci/deploy-aspblogbrainordure-test.ps1 Visa fil

@@ -73,41 +73,57 @@ $srcPath = $extracted.FullName

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
$folderDst = Join-Path $WEBROOT $folder
if (Test-Path $folderSrc) {
if (Test-Path $folderDst) { Remove-Item $folderDst -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
$webConfigPath = Join-Path $WEBROOT "web.config"
$webConfigPath = Join-Path $publicDst "web.config"
if (Test-Path $webConfigPath) {
$wc = [System.IO.File]::ReadAllText($webConfigPath)
$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)
if ($wc -notmatch 'enableParentPaths') {
$wc = $wc -replace '<system.webServer>', '<system.webServer><asp enableParentPaths="true" />'
}
[System.IO.File]::WriteAllText($webConfigPath, $wc)
Log "Updated web.config ConnectionString."
Log "Updated web.config."
}

# Grant IIS_IUSRS write access to db folder
$dbPath = Join-Path $WEBROOT "db"
New-Item -ItemType Directory -Force -Path $dbPath | Out-Null
if (Test-Path $dbPath) {
$acl = Get-Acl $dbPath
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow")


Laddar…
Avbryt
Spara

Powered by TurnKey Linux.