Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support onprem and onpremise and support windows msi installer w silent exec #543

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ nightly-release: release
build: check_secrets cwagent-otel-collector amazon-cloudwatch-agent config-translator start-amazon-cloudwatch-agent amazon-cloudwatch-agent-config-wizard config-downloader

check_secrets::
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;
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;

create-version-file:
@echo Version: ${VERSION}
Expand Down
2 changes: 1 addition & 1 deletion cmd/config-translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func initFlags() {
var inputJsonFile = flag.String("input", "", "Please provide the path of input agent json config file")
var inputJsonDir = flag.String("input-dir", "", "Please provide the path of input agent json config directory.")
var inputTomlFile = flag.String("output", "", "Please provide the path of the output CWAgent config file")
var inputMode = flag.String("mode", "ec2", "Please provide the mode, i.e. ec2, onPremise, auto")
var inputMode = flag.String("mode", "ec2", "Please provide the mode, i.e. ec2, onPremise, onPrem, auto")
var inputConfig = flag.String("config", "", "Please provide the common-config file")
var multiConfig = flag.String("multi-config", "remove", "valid values: default, append, remove")
flag.Parse()
Expand Down
27 changes: 21 additions & 6 deletions integration/msi/tools/amazon-cloudwatch-agent.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>

<?define FixPermissionScriptAction=""powershell.exe" -ExecutionPolicy Bypass -File "[INSTALLDIR]permission.ps1"?>

<Product Id='*'
Name='Amazon CloudWatch Agent'
UpgradeCode='c537c936-91b3-4270-94d7-e128acfc3e86'
Expand All @@ -26,7 +24,13 @@
/>

<MediaTemplate EmbedCab='yes' />

<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<Feature Id='ProductFeature' Title="Amazon CloudWatch Agent" Level='1'>
<ComponentRef Id='StarterEXE' />
<ComponentRef Id='AgentEXE' />
Expand Down Expand Up @@ -200,11 +204,22 @@
<CreateFolder />
</Component>
</DirectoryRef>

<CustomAction Id="UpdateConfigPermission" Directory="INSTALLDIR" ExeCommand="$(var.FixPermissionScriptAction)" Execute="deferred" Return="check" Impersonate="no" />
<!-- Find and use powershell to run the command, because just running "powershell.exe" did not resolve (not in ENV path) when using "WixQuietExec".-->
<SetProperty Id="QtExecUpdateConfigPermission"
Sequence="execute"
Before ="QtExecUpdateConfigPermission"
Value='&quot;[POWERSHELLEXE]&quot; -ExecutionPolicy Bypass -File "[INSTALLDIR]permission.ps1" '
/>
<!-- Setup a silent execution contrainer around the command -->
<CustomAction Id="QtExecUpdateConfigPermission"
BinaryKey="WixCA"
DllEntry="WixQuietExec"
Execute="deferred"
Return="check"
Impersonate="no" />

<InstallExecuteSequence>
<Custom Action="UpdateConfigPermission" After="InstallFiles">NOT UPGRADINGPRODUCTCODE AND NOT (REMOVE~="ALL")</Custom>
<Custom Action="QtExecUpdateConfigPermission" After="InstallFiles">NOT UPGRADINGPRODUCTCODE AND NOT (REMOVE~="ALL")</Custom>
</InstallExecuteSequence>

<MajorUpgrade AllowDowngrades="yes"/>
Expand Down
5 changes: 3 additions & 2 deletions translator/config/mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package config

const (
ModeEC2 = "ec2"
ModeOnPrem = "onPremise"
ModeEC2 = "ec2"
ModeOnPrem = "onPrem"
ModeOnPremise = "onPremise"
)
2 changes: 1 addition & 1 deletion translator/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (ctx *Context) SetMode(mode string) {
switch mode {
case config.ModeEC2:
ctx.mode = config.ModeEC2
case config.ModeOnPrem:
case config.ModeOnPrem,config.ModeOnPremise:
ctx.mode = config.ModeOnPrem
default:
log.Panicf("Invalid mode %s. Valid mode values are %s and %s.", mode, config.ModeEC2, config.ModeOnPrem)
Expand Down