1
1
$ProgressPreference = ' Continue'
2
+ $VerbosePreference = ' Continue'
2
3
$ErrorActionPreference = ' Stop'
3
4
Set-StrictMode - Version 2.0
4
5
@@ -38,7 +39,7 @@ $erlang_install_dir = Join-Path -Path $HOME -ChildPath 'erlang'
38
39
39
40
Write-Host ' [INFO] Downloading Erlang...'
40
41
41
- if (-Not (Test-Path $erlang_installer_path ))
42
+ if (-Not (Test-Path - LiteralPath $erlang_installer_path ))
42
43
{
43
44
Invoke-WebRequest - UseBasicParsing - Uri $erlang_download_url - OutFile $erlang_installer_path
44
45
}
@@ -54,26 +55,76 @@ $rabbitmq_installer_download_url = "https://github.com/rabbitmq/rabbitmq-server/
54
55
$rabbitmq_installer_path = Join-Path - Path $base_installers_dir - ChildPath " rabbitmq-server-$rabbitmq_ver .exe"
55
56
Write-Host " [INFO] rabbitmq installer path $rabbitmq_installer_path "
56
57
57
- $erlang_reg_path = ' HKLM:\SOFTWARE\Ericsson\Erlang'
58
- if (Test-Path ' HKLM:\SOFTWARE\WOW6432Node\' )
58
+ if (Test-Path - LiteralPath ' HKLM:\SOFTWARE\WOW6432Node\' )
59
59
{
60
- $erlang_reg_path = ' HKLM:\SOFTWARE\WOW6432Node\Ericsson\Erlang'
60
+ New-Variable - Name erlangRegKeyPath - Option Constant `
61
+ - Value ' HKLM:\SOFTWARE\WOW6432Node\Ericsson\Erlang'
62
+ }
63
+ else
64
+ {
65
+ New-Variable - Name erlangRegKeyPath - Option Constant `
66
+ - Value ' HKLM:\SOFTWARE\Ericsson\Erlang'
67
+ }
68
+
69
+ New-Variable - Name erlangRegKey - Option Constant `
70
+ - Value (Get-ChildItem $erlangRegKeyPath )
71
+
72
+ if ($erlangRegKey -eq $null ) {
73
+ Write-Error " Could not find Erlang installation registry key at $erlangRegKeyPath "
74
+ }
75
+
76
+ New-Variable - Name erlangErtsVersion - Option Constant `
77
+ - Value (Select-Object - InputObject $erlangRegKey - Last 1 ).PSChildName
78
+ Write-Verbose " erlangErtsVersion: $erlangErtsVersion "
79
+
80
+ New-Variable - Name erlangErtsRegKeyPath - Option Constant `
81
+ - Value " HKLM:\SOFTWARE\WOW6432Node\Ericsson\Erlang\$erlangErtsVersion "
82
+
83
+ New-Variable - Name erlangErtsRegKey - Option Constant `
84
+ - Value (Get-ItemProperty - LiteralPath HKLM:\SOFTWARE\WOW6432Node\Ericsson\Erlang\$erlangErtsVersion )
85
+
86
+ if ($erlangErtsRegKey -eq $null ) {
87
+ Write-Error " Could not find Erlang erts registry key at $erlangErtsRegKeyPath "
88
+ }
89
+
90
+ New-Variable - Name erlangProgramFilesPath - Option Constant `
91
+ - Value ($erlangErtsRegKey .' (default)' )
92
+
93
+ if (Test-Path - LiteralPath $erlangProgramFilesPath ) {
94
+ Write-Verbose " Erlang installation directory: '$erlangProgramFilesPath '"
95
+ }
96
+ else {
97
+ Write-Error ' Could not find Erlang installation directory!'
98
+ }
99
+
100
+ New-Variable - Name allowedExes - Option Constant - Value @ (' erl.exe' , ' epmd.exe' , ' werl.exe' )
101
+
102
+ New-Variable - Name exes - Option Constant - Value `
103
+ $ (Get-ChildItem - Filter ' *.exe' - Recurse - LiteralPath $erlangProgramFilesPath | Where-Object { $_.Name -in $allowedExes })
104
+
105
+ foreach ($exe in $exes ) {
106
+ $fwRuleName = " rabbitmq-allow-$ ( $exe.Name ) -$ ( Get-Random ) "
107
+ Write-Verbose " Updating or creating firewall rule for '$exe ' - fwRuleName: $fwRuleName "
108
+ if (! (Get-NetFirewallRule - ErrorAction ' SilentlyContinue' - Name $fwRuleName )) {
109
+ New-NetFirewallRule - Enabled True - Name $fwRuleName - DisplayName $fwRuleName - Direction In - Program $exe - Profile Any - Action Allow
110
+ }
111
+ else {
112
+ Set-NetFirewallRule - Enabled True - Name $fwRuleName - DisplayName $fwRuleName - Direction In - Program $exe - Profile Any - Action Allow
113
+ }
61
114
}
62
- $erlang_erts_version = Get-ChildItem - Path $erlang_reg_path - Name
63
- $erlang_home = (Get-ItemProperty - LiteralPath $erlang_reg_path \$erlang_erts_version ).' (default)'
64
115
65
- Write-Host " [INFO] Setting ERLANG_HOME to '$erlang_home '..."
66
- $env: ERLANG_HOME = $erlang_home
67
- [Environment ]::SetEnvironmentVariable(' ERLANG_HOME' , $erlang_home , ' Machine' )
68
- Add-Content - Verbose - LiteralPath $env: GITHUB_ENV - Value " ERLANG_HOME=$erlang_home "
116
+ Write-Host " [INFO] Setting ERLANG_HOME to '$erlangProgramFilesPath '..."
117
+ $env: ERLANG_HOME = $erlangProgramFilesPath
118
+ [Environment ]::SetEnvironmentVariable(' ERLANG_HOME' , $erlangProgramFilesPath , ' Machine' )
119
+ Add-Content - Verbose - LiteralPath $env: GITHUB_ENV - Value " ERLANG_HOME=$erlangProgramFilesPath "
69
120
70
121
Write-Host " [INFO] Setting RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS..."
71
122
$env: RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS = ' -rabbitmq_stream advertised_host localhost'
72
123
[Environment ]::SetEnvironmentVariable(' RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS' , ' -rabbitmq_stream advertised_host localhost' , ' Machine' )
73
124
74
125
Write-Host ' [INFO] Downloading RabbitMQ...'
75
126
76
- if (-Not (Test-Path $rabbitmq_installer_path ))
127
+ if (-Not (Test-Path - LiteralPath $rabbitmq_installer_path ))
77
128
{
78
129
Invoke-WebRequest - UseBasicParsing - Uri $rabbitmq_installer_download_url - OutFile $rabbitmq_installer_path
79
130
}
@@ -83,15 +134,15 @@ else
83
134
}
84
135
85
136
Write-Host " [INFO] Installer dir '$base_installers_dir ' contents:"
86
- Get-ChildItem - Verbose - Path $base_installers_dir
137
+ Get-ChildItem - Verbose - LiteralPath $base_installers_dir
87
138
88
139
$rabbitmq_conf_in_file = Join-Path - Path $ci_windows_dir - ChildPath ' rabbitmq.conf.in'
89
140
$rabbitmq_appdata_dir = Join-Path - Path $env: AppData - ChildPath ' RabbitMQ'
90
141
New-Item - Path $rabbitmq_appdata_dir - ItemType Directory
91
142
$rabbitmq_conf_file = Join-Path - Path $rabbitmq_appdata_dir - ChildPath ' rabbitmq.conf'
92
143
93
144
Write-Host " [INFO] Creating RabbitMQ configuration file in '$rabbitmq_appdata_dir '"
94
- Get-Content $rabbitmq_conf_in_file | % { $_ -replace ' @@CERTS_DIR@@' , $certs_dir } | % { $_ -replace ' \\' , ' /' } | Set-Content - Path $rabbitmq_conf_file
145
+ Get-Content $rabbitmq_conf_in_file | % { $_ -replace ' @@CERTS_DIR@@' , $certs_dir } | % { $_ -replace ' \\' , ' /' } | Set-Content - LiteralPath $rabbitmq_conf_file
95
146
Get-Content $rabbitmq_conf_file
96
147
97
148
Write-Host ' [INFO] Creating Erlang cookie files...'
@@ -114,9 +165,9 @@ Write-Host '[INFO] Installing and starting RabbitMQ...'
114
165
& $rabbitmq_installer_path ' /S' | Out-Null
115
166
(Get-Service - Name RabbitMQ).Status
116
167
117
- $rabbitmq_base_path = (Get-ItemProperty - Name Install_Dir - Path ' HKLM:\SOFTWARE\WOW6432Node\VMware, Inc.\RabbitMQ Server' ).Install_Dir
168
+ $rabbitmq_base_path = (Get-ItemProperty - Name Install_Dir - LiteralPath ' HKLM:\SOFTWARE\WOW6432Node\VMware, Inc.\RabbitMQ Server' ).Install_Dir
118
169
$regPath = ' HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RabbitMQ'
119
- if (Test-Path ' HKLM:\SOFTWARE\WOW6432Node\' )
170
+ if (Test-Path - LiteralPath ' HKLM:\SOFTWARE\WOW6432Node\' )
120
171
{
121
172
$regPath = ' HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\RabbitMQ'
122
173
}
@@ -138,7 +189,7 @@ $env:RABBITMQ_RABBITMQCTL_PATH = $rabbitmqctl_path
138
189
$epmd_running = $false
139
190
[int ]$count = 1
140
191
141
- $epmd_exe = Join-Path - Path $erlang_home - ChildPath " erts-$erlang_erts_version " | Join-Path - ChildPath ' bin' | Join-Path - ChildPath ' epmd.exe'
192
+ $epmd_exe = Join-Path - Path $erlangProgramFilesPath - ChildPath " erts-$erlangErtsVersion " | Join-Path - ChildPath ' bin' | Join-Path - ChildPath ' epmd.exe'
142
193
143
194
Write-Host " [INFO] Waiting for epmd ($epmd_exe ) to report that RabbitMQ has started..."
144
195
0 commit comments