fix: aws starter template compatability

web-rdp-cloud-fixes
Ben Potter 1 year ago committed by GitHub
parent de00f6334f
commit 9864408643
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -56,57 +56,62 @@ resource "coder_script" "windows-rdp" {
} }
function Install-DevolutionsGateway { function Install-DevolutionsGateway {
# Define the module name and version # Define the module name and version
$moduleName = "DevolutionsGateway" $moduleName = "DevolutionsGateway"
$moduleVersion = "2024.1.5" $moduleVersion = "2024.1.5"
# Install the module with the specified version for all users try {
# This requires administrator privileges # Try to import the module directly
Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force Import-Module $moduleName -ErrorAction Stop
} catch {
# Construct the module path for system-wide installation # If it fails, install and then import the module
$moduleBasePath = "C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules\$moduleName\$moduleVersion" Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -Confirm:$false -SkipPublisherCheck
$modulePath = Join-Path -Path $moduleBasePath -ChildPath "$moduleName.psd1"
# Construct the module path for system-wide installation
# Import the module using the full path $moduleBasePath = "C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules\$moduleName\$moduleVersion"
Import-Module $modulePath $modulePath = Join-Path -Path $moduleBasePath -ChildPath "$moduleName.psd1"
Install-DGatewayPackage
# Import the module using the full path
# Configure Devolutions Gateway Import-Module $modulePath
$Hostname = "localhost" }
$HttpListener = New-DGatewayListener 'http://*:7171' 'http://*:7171'
$WebApp = New-DGatewayWebAppConfig -Enabled $true -Authentication None Install-DGatewayPackage
$ConfigParams = @{
Hostname = $Hostname # Configure Devolutions Gateway
Listeners = @($HttpListener) $Hostname = "localhost"
WebApp = $WebApp $HttpListener = New-DGatewayListener 'http://*:7171' 'http://*:7171'
} $WebApp = New-DGatewayWebAppConfig -Enabled $true -Authentication None
Set-DGatewayConfig @ConfigParams $ConfigParams = @{
New-DGatewayProvisionerKeyPair -Force Hostname = $Hostname
Listeners = @($HttpListener)
# Configure and start the Windows service WebApp = $WebApp
Set-Service 'DevolutionsGateway' -StartupType 'Automatic' }
Start-Service 'DevolutionsGateway' Set-DGatewayConfig @ConfigParams
New-DGatewayProvisionerKeyPair -Force
# Configure and start the Windows service
Set-Service 'DevolutionsGateway' -StartupType 'Automatic'
Start-Service 'DevolutionsGateway'
} }
function Patch-Devolutions-HTML { function Patch-Devolutions-HTML {
$root = "C:\Program Files\Devolutions\Gateway\webapp\client" $root = "C:\Program Files\Devolutions\Gateway\webapp\client"
$devolutionsHtml = "$root\index.html" $devolutionsHtml = "$root\index.html"
$patch = '<script defer id="coder-patch" src="coder.js"></script>' $patch = '<script defer id="coder-patch" src="coder.js"></script>'
# Always copy the file in case we change it. # Always copy the file in case we change it.
@' @'
${templatefile("${path.module}/devolutions-patch.js", { ${templatefile("${path.module}/devolutions-patch.js", {
CODER_USERNAME : var.admin_username, CODER_USERNAME : var.admin_username,
CODER_PASSWORD : var.admin_password, CODER_PASSWORD : var.admin_password,
})} })}
'@ | Set-Content "$root\coder.js" '@ | Set-Content "$root\coder.js"
# Only inject the src if we have not before. # Only inject the src if we have not before.
$isPatched = Select-String -Path "$devolutionsHtml" -Pattern "$patch" -SimpleMatch $isPatched = Select-String -Path "$devolutionsHtml" -Pattern "$patch" -SimpleMatch
if ($isPatched -eq $null) { if ($isPatched -eq $null) {
(Get-Content $devolutionsHtml).Replace('</app-root>', "</app-root>$patch") | Set-Content $devolutionsHtml (Get-Content $devolutionsHtml).Replace('</app-root>', "</app-root>$patch") | Set-Content $devolutionsHtml
} }
} }
Set-AdminPassword -adminPassword "${var.admin_password}" Set-AdminPassword -adminPassword "${var.admin_password}"

Loading…
Cancel
Save