ASP Classic blog framework - BrainOrdure
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

84 řádky
3.7KB

  1. # aspblogbrainordure-setup.ps1
  2. # One-time setup: creates IIS site, app pool, and CI/CD scheduled task for ASPBlogBrainOrdure test site
  3. $SITENAME = "aspblogbrainordure-test"
  4. $APPPOOL = "aspblogbrainordure-test"
  5. $WEBROOT = "C:\inetpub\wwwroot\aspblogbrainordure-test"
  6. $PORT = 8960
  7. $SCRIPTS = "C:\Scripts"
  8. Import-Module WebAdministration
  9. Write-Host "=== ASPBlogBrainOrdure Test Site Setup ==="
  10. # Create directories
  11. New-Item -ItemType Directory -Force -Path $WEBROOT | Out-Null
  12. New-Item -ItemType Directory -Force -Path $SCRIPTS | Out-Null
  13. Write-Host "Directories created."
  14. # Create app pool (32-bit required for ACE OLEDB)
  15. if (-not (Get-WebConfiguration "system.applicationHost/applicationPools/add[@name='$APPPOOL']")) {
  16. New-WebAppPool -Name $APPPOOL
  17. Write-Host "App pool $APPPOOL created."
  18. } else {
  19. Write-Host "App pool $APPPOOL already exists."
  20. }
  21. Set-ItemProperty "IIS:\AppPools\$APPPOOL" managedRuntimeVersion "v4.0"
  22. Set-ItemProperty "IIS:\AppPools\$APPPOOL" enable32BitAppOnWin64 $true
  23. Set-ItemProperty "IIS:\AppPools\$APPPOOL" startMode "AlwaysRunning"
  24. Write-Host "App pool configured (32-bit, v4.0)."
  25. # Create IIS site
  26. $existingSite = Get-Website -Name $SITENAME -ErrorAction SilentlyContinue
  27. if ($existingSite) {
  28. Write-Host "Site $SITENAME already exists - skipping creation."
  29. } else {
  30. New-Website -Name $SITENAME -PhysicalPath $WEBROOT -Port $PORT -ApplicationPool $APPPOOL
  31. Write-Host "IIS site $SITENAME created on port $PORT."
  32. }
  33. # Enable Parent Paths for ASP
  34. Set-WebConfigurationProperty -Filter "system.webServer/asp" -PSPath "IIS:\Sites\$SITENAME" -Name "enableParentPaths" -Value $true
  35. Write-Host "Parent paths enabled."
  36. # Create a placeholder Default.asp so the site doesn't 500 before first deploy
  37. $placeholder = "<%Response.Write ""ASPBlogBrainOrdure - Awaiting first deploy..."" %>"
  38. [System.IO.File]::WriteAllText("$WEBROOT\Default.asp", $placeholder)
  39. Write-Host "Placeholder Default.asp created."
  40. # Copy the deploy script to Scripts folder
  41. $deployScriptSrc = Split-Path $PSScriptRoot -Parent
  42. $deployScript = "$SCRIPTS\deploy-aspblogbrainordure-test.ps1"
  43. # Write the deploy script inline (will be updated by CI/CD from repo)
  44. # For now, copy from the repo path passed in or the current location
  45. if (Test-Path "$PSScriptRoot\deploy-aspblogbrainordure-test.ps1") {
  46. Copy-Item "$PSScriptRoot\deploy-aspblogbrainordure-test.ps1" $deployScript -Force
  47. Write-Host "Deploy script copied to $deployScript."
  48. }
  49. # Register scheduled task (runs every 5 minutes)
  50. $taskName = "ASPBlogBrainOrdure-Test-Deploy"
  51. $existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
  52. if ($existing) {
  53. Unregister-ScheduledTask -TaskName $taskName -Confirm:$false
  54. Write-Host "Removed existing scheduled task."
  55. }
  56. $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NonInteractive -ExecutionPolicy Bypass -File `"$deployScript`""
  57. $trigger = New-ScheduledTaskTrigger -RepetitionInterval (New-TimeSpan -Minutes 5) -Once -At (Get-Date)
  58. $settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Minutes 10) -MultipleInstances IgnoreNew
  59. Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Settings $settings -RunLevel Highest -User "SYSTEM" | Out-Null
  60. Write-Host "Scheduled task '$taskName' created (every 5 min)."
  61. # Run first deploy immediately
  62. Write-Host "Running first deploy..."
  63. & powershell.exe -NonInteractive -ExecutionPolicy Bypass -File $deployScript
  64. Write-Host "First deploy complete."
  65. Write-Host ""
  66. Write-Host "=== Setup complete ==="
  67. Write-Host "Test site: http://win-rfvbip1nu8m:$PORT"
  68. Write-Host "Webroot: $WEBROOT"
  69. Write-Host "App Pool: $APPPOOL (32-bit, v4.0)"
  70. Write-Host "CI/CD: $taskName (every 5 min)"

Powered by TurnKey Linux.