|
|
|
@ -60,9 +60,12 @@ resource "coder_script" "windows-rdp" {
|
|
|
|
|
$moduleName = "DevolutionsGateway"
|
|
|
|
|
$moduleVersion = "2024.1.5"
|
|
|
|
|
|
|
|
|
|
# Install the module with the specified version for all users
|
|
|
|
|
# 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
|
|
|
|
|
Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -Confirm:$false -SkipPublisherCheck
|
|
|
|
|
|
|
|
|
|
# Construct the module path for system-wide installation
|
|
|
|
|
$moduleBasePath = "C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules\$moduleName\$moduleVersion"
|
|
|
|
@ -70,6 +73,8 @@ resource "coder_script" "windows-rdp" {
|
|
|
|
|
|
|
|
|
|
# Import the module using the full path
|
|
|
|
|
Import-Module $modulePath
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Install-DGatewayPackage
|
|
|
|
|
|
|
|
|
|
# Configure Devolutions Gateway
|
|
|
|
@ -96,11 +101,11 @@ resource "coder_script" "windows-rdp" {
|
|
|
|
|
|
|
|
|
|
# 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_PASSWORD : var.admin_password,
|
|
|
|
|
})}
|
|
|
|
|
'@ | Set-Content "$root\coder.js"
|
|
|
|
|
})}
|
|
|
|
|
'@ | Set-Content "$root\coder.js"
|
|
|
|
|
|
|
|
|
|
# Only inject the src if we have not before.
|
|
|
|
|
$isPatched = Select-String -Path "$devolutionsHtml" -Pattern "$patch" -SimpleMatch
|
|
|
|
|