Skip to content

Commit 6119858

Browse files
authored
support onprem and onpremise and support windows msi installer w silent exec (#543)
* support onprem and onpremise and support windows msi installer w silent exec
1 parent f457325 commit 6119858

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ nightly-release: release
5858
build: check_secrets cwagent-otel-collector amazon-cloudwatch-agent config-translator start-amazon-cloudwatch-agent amazon-cloudwatch-agent-config-wizard config-downloader
5959

6060
check_secrets::
61-
if grep --exclude-dir=build --exclude-dir=vendor -E "(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}|(\"|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)(\"|')?\\s*(:|=>|=)\\s*(\"|')?[A-Za-z0-9/\\+=]{40}(\"|')?" -Rn .; then echo "check_secrets failed"; exit 1; fi;
61+
if grep --exclude-dir=build --exclude-dir=vendor -exclude=integration/msi/tools/amazon-cloudwatch-agent.wxs -E "(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}|(\"|')?(AWS|aws|Aws)?_?(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)(\"|')?\\s*(:|=>|=)\\s*(\"|')?[A-Za-z0-9/\\+=]{40}(\"|')?" -Rn .; then echo "check_secrets failed"; exit 1; fi;
6262

6363
create-version-file:
6464
@echo Version: ${VERSION}

cmd/config-translator/translator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func initFlags() {
2828
var inputJsonFile = flag.String("input", "", "Please provide the path of input agent json config file")
2929
var inputJsonDir = flag.String("input-dir", "", "Please provide the path of input agent json config directory.")
3030
var inputTomlFile = flag.String("output", "", "Please provide the path of the output CWAgent config file")
31-
var inputMode = flag.String("mode", "ec2", "Please provide the mode, i.e. ec2, onPremise, auto")
31+
var inputMode = flag.String("mode", "ec2", "Please provide the mode, i.e. ec2, onPremise, onPrem, auto")
3232
var inputConfig = flag.String("config", "", "Please provide the common-config file")
3333
var multiConfig = flag.String("multi-config", "remove", "valid values: default, append, remove")
3434
flag.Parse()

integration/msi/tools/amazon-cloudwatch-agent.wxs

+21-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
33
xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
44

5-
<?define FixPermissionScriptAction=""powershell.exe" -ExecutionPolicy Bypass -File "[INSTALLDIR]permission.ps1"?>
6-
75
<Product Id='*'
86
Name='Amazon CloudWatch Agent'
97
UpgradeCode='c537c936-91b3-4270-94d7-e128acfc3e86'
@@ -26,7 +24,13 @@
2624
/>
2725

2826
<MediaTemplate EmbedCab='yes' />
29-
27+
<Property Id="POWERSHELLEXE">
28+
<RegistrySearch Id="POWERSHELLEXE"
29+
Type="raw"
30+
Root="HKLM"
31+
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
32+
Name="Path" />
33+
</Property>
3034
<Feature Id='ProductFeature' Title="Amazon CloudWatch Agent" Level='1'>
3135
<ComponentRef Id='StarterEXE' />
3236
<ComponentRef Id='AgentEXE' />
@@ -200,11 +204,22 @@
200204
<CreateFolder />
201205
</Component>
202206
</DirectoryRef>
203-
204-
<CustomAction Id="UpdateConfigPermission" Directory="INSTALLDIR" ExeCommand="$(var.FixPermissionScriptAction)" Execute="deferred" Return="check" Impersonate="no" />
207+
<!-- Find and use powershell to run the command, because just running "powershell.exe" did not resolve (not in ENV path) when using "WixQuietExec".-->
208+
<SetProperty Id="QtExecUpdateConfigPermission"
209+
Sequence="execute"
210+
Before ="QtExecUpdateConfigPermission"
211+
Value='&quot;[POWERSHELLEXE]&quot; -ExecutionPolicy Bypass -File "[INSTALLDIR]permission.ps1" '
212+
/>
213+
<!-- Setup a silent execution contrainer around the command -->
214+
<CustomAction Id="QtExecUpdateConfigPermission"
215+
BinaryKey="WixCA"
216+
DllEntry="WixQuietExec"
217+
Execute="deferred"
218+
Return="check"
219+
Impersonate="no" />
205220

206221
<InstallExecuteSequence>
207-
<Custom Action="UpdateConfigPermission" After="InstallFiles">NOT UPGRADINGPRODUCTCODE AND NOT (REMOVE~="ALL")</Custom>
222+
<Custom Action="QtExecUpdateConfigPermission" After="InstallFiles">NOT UPGRADINGPRODUCTCODE AND NOT (REMOVE~="ALL")</Custom>
208223
</InstallExecuteSequence>
209224

210225
<MajorUpgrade AllowDowngrades="yes"/>

translator/config/mode.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package config
55

66
const (
7-
ModeEC2 = "ec2"
8-
ModeOnPrem = "onPremise"
7+
ModeEC2 = "ec2"
8+
ModeOnPrem = "onPrem"
9+
ModeOnPremise = "onPremise"
910
)

translator/context/context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (ctx *Context) SetMode(mode string) {
110110
switch mode {
111111
case config.ModeEC2:
112112
ctx.mode = config.ModeEC2
113-
case config.ModeOnPrem:
113+
case config.ModeOnPrem,config.ModeOnPremise:
114114
ctx.mode = config.ModeOnPrem
115115
default:
116116
log.Panicf("Invalid mode %s. Valid mode values are %s and %s.", mode, config.ModeEC2, config.ModeOnPrem)

0 commit comments

Comments
 (0)