Compare commits
2 Commits
v1.0.21
...
web-rdp-cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb075aa035 | ||
|
|
9864408643 |
@@ -56,57 +56,63 @@ 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
|
Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -Confirm:$false -SkipPublisherCheck
|
||||||
# This requires administrator privileges
|
|
||||||
Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force
|
try {
|
||||||
|
# Try to import the module directly
|
||||||
|
Import-Module $moduleName -ErrorAction Stop
|
||||||
|
} catch {
|
||||||
|
# If it fails, install and then import the module
|
||||||
|
|
||||||
# Construct the module path for system-wide installation
|
# Construct the module path for system-wide installation
|
||||||
$moduleBasePath = "C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules\$moduleName\$moduleVersion"
|
$moduleBasePath = "C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules\$moduleName\$moduleVersion"
|
||||||
$modulePath = Join-Path -Path $moduleBasePath -ChildPath "$moduleName.psd1"
|
$modulePath = Join-Path -Path $moduleBasePath -ChildPath "$moduleName.psd1"
|
||||||
|
|
||||||
# Import the module using the full path
|
# Import the module using the full path
|
||||||
Import-Module $modulePath
|
Import-Module $modulePath
|
||||||
Install-DGatewayPackage
|
}
|
||||||
|
|
||||||
# Configure Devolutions Gateway
|
Install-DGatewayPackage
|
||||||
$Hostname = "localhost"
|
|
||||||
$HttpListener = New-DGatewayListener 'http://*:7171' 'http://*:7171'
|
|
||||||
$WebApp = New-DGatewayWebAppConfig -Enabled $true -Authentication None
|
|
||||||
$ConfigParams = @{
|
|
||||||
Hostname = $Hostname
|
|
||||||
Listeners = @($HttpListener)
|
|
||||||
WebApp = $WebApp
|
|
||||||
}
|
|
||||||
Set-DGatewayConfig @ConfigParams
|
|
||||||
New-DGatewayProvisionerKeyPair -Force
|
|
||||||
|
|
||||||
# Configure and start the Windows service
|
# Configure Devolutions Gateway
|
||||||
Set-Service 'DevolutionsGateway' -StartupType 'Automatic'
|
$Hostname = "localhost"
|
||||||
Start-Service 'DevolutionsGateway'
|
$HttpListener = New-DGatewayListener 'http://*:7171' 'http://*:7171'
|
||||||
|
$WebApp = New-DGatewayWebAppConfig -Enabled $true -Authentication None
|
||||||
|
$ConfigParams = @{
|
||||||
|
Hostname = $Hostname
|
||||||
|
Listeners = @($HttpListener)
|
||||||
|
WebApp = $WebApp
|
||||||
|
}
|
||||||
|
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}"
|
||||||
|
|||||||
Reference in New Issue
Block a user