Skip to content

Commit c744b64

Browse files
Update env vars in windows installer script
1 parent f6c6347 commit c744b64

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

internal/buildscripts/packaging/installer/install.ps1

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,38 @@ $arch = "amd64"
110110
$format = "msi"
111111
$service_name = "splunk-otel-collector"
112112
$signalfx_dl = "https://dl.signalfx.com"
113-
$installation_path = "\Program Files"
114-
$program_data_path = "\ProgramData\Splunk\OpenTelemetry Collector"
113+
try {
114+
Resolve-Path $env:PROGRAMFILES
115+
$installation_path = "${env:PROGRAMFILES}\Splunk\OpenTelemetry Collector"
116+
} catch {
117+
$installation_path = "\Program Files\Splunk\OpenTelemetry Collector"
118+
}
119+
try {
120+
Resolve-Path $env:PROGRAMDATA
121+
$program_data_path = "${env:PROGRAMDATA}\Splunk\OpenTelemetry Collector"
122+
} catch {
123+
$program_data_path = "\ProgramData\Splunk\OpenTelemetry Collector"
124+
}
115125
$old_config_path = "$program_data_path\config.yaml"
116126
$agent_config_path = "$program_data_path\agent_config.yaml"
117127
$gateway_config_path = "$program_data_path\gateway_config.yaml"
118128
$config_path = ""
119-
$tempdir = "\tmp\Splunk\OpenTelemetry Collector"
129+
try {
130+
Resolve-Path $env:TEMP
131+
$tempdir = "${env:TEMP}\Splunk\OpenTelemetry Collector"
132+
} catch {
133+
$tempdir = "\tmp\Splunk\OpenTelemetry Collector"
134+
}
120135
$regkey = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
121136

122-
$fluentd_msi_name = "td-agent-4.0.1-x64.msi"
137+
$fluentd_msi_name = "td-agent-4.1.0-x64.msi"
123138
$fluentd_dl_url = "https://packages.treasuredata.com/4/windows/$fluentd_msi_name"
124-
$fluentd_base_dir = "\opt\td-agent"
139+
try {
140+
Resolve-Path $env:SYSTEMDRIVE
141+
$fluentd_base_dir = "${env:SYSTEMDRIVE}\opt\td-agent"
142+
} catch {
143+
$fluentd_base_dir = "\opt\td-agent"
144+
}
125145
$fluentd_config_dir = "$fluentd_base_dir\etc\td-agent"
126146
$fluentd_config_path = "$fluentd_config_dir\td-agent.conf"
127147
$fluentd_service_name = "fluentdwinsvc"
@@ -365,7 +385,7 @@ if ($hec_token -eq "") {
365385
}
366386

367387
if ($bundle_dir -eq "") {
368-
$bundle_dir = "C:\Program Files\Splunk\OpenTelemetry Collector\agent-bundle"
388+
$bundle_dir = "$installation_path\agent-bundle"
369389
}
370390

371391
if ("$env:VERIFY_ACCESS_TOKEN" -ne "false") {
@@ -408,20 +428,20 @@ echo "- Done"
408428

409429
# copy the default configs to $program_data_path
410430
mkdir "$program_data_path" -ErrorAction Ignore
411-
if (!(Test-Path -Path "$agent_config_path") -And (Test-Path -Path "$installation_path\Splunk\OpenTelemetry Collector\agent_config.yaml")) {
431+
if (!(Test-Path -Path "$agent_config_path") -And (Test-Path -Path "$installation_path\agent_config.yaml")) {
412432
echo "$agent_config_path not found"
413433
echo "Copying default agent_config.yaml to $agent_config_path"
414-
Copy-Item "$installation_path\Splunk\OpenTelemetry Collector\agent_config.yaml" "$agent_config_path"
434+
Copy-Item "$installation_path\agent_config.yaml" "$agent_config_path"
415435
}
416-
if (!(Test-Path -Path "$gateway_config_path") -And (Test-Path -Path "$installation_path\Splunk\OpenTelemetry Collector\gateway_config.yaml")) {
436+
if (!(Test-Path -Path "$gateway_config_path") -And (Test-Path -Path "$installation_path\gateway_config.yaml")) {
417437
echo "$gateway_config_path not found"
418438
echo "Copying default gateway_config.yaml to $gateway_config_path"
419-
Copy-Item "$installation_path\Splunk\OpenTelemetry Collector\gateway_config.yaml" "$gateway_config_path"
439+
Copy-Item "$installation_path\gateway_config.yaml" "$gateway_config_path"
420440
}
421-
if (!(Test-Path -Path "$old_config_path") -And (Test-Path -Path "$installation_path\Splunk\OpenTelemetry Collector\config.yaml")) {
441+
if (!(Test-Path -Path "$old_config_path") -And (Test-Path -Path "$installation_path\config.yaml")) {
422442
echo "$old_config_path not found"
423443
echo "Copying default config.yaml to $old_config_path"
424-
Copy-Item "$installation_path\Splunk\OpenTelemetry Collector\config.yaml" "$old_config_path"
444+
Copy-Item "$installation_path\config.yaml" "$old_config_path"
425445
}
426446

427447
if (($mode -Eq "agent") -And (Test-Path -Path "$agent_config_path")) {
@@ -454,8 +474,8 @@ start_service -name "$service_name" -config_path "$config_path"
454474
echo "- Started"
455475

456476
if ($with_fluentd) {
457-
$default_fluentd_config = "$installation_path\Splunk\OpenTelemetry Collector\fluentd\td-agent.conf"
458-
$default_confd_dir = "$installation_path\Splunk\OpenTelemetry Collector\fluentd\conf.d"
477+
$default_fluentd_config = "$installation_path\fluentd\td-agent.conf"
478+
$default_confd_dir = "$installation_path\fluentd\conf.d"
459479

460480
# copy the default fluentd config to $fluentd_config_path if it does not already exist
461481
if (!(Test-Path -Path "$fluentd_config_path") -And (Test-Path -Path "$default_fluentd_config")) {
@@ -503,7 +523,8 @@ Make sure that your system's time is relatively accurate or else datapoints may
503523
The collector's main configuration file is located at $config_path,
504524
and the environment variables are stored in the $regkey registry key.
505525
506-
If the $config_path or any of the SPLUNK_* environment variables in $regkey are modified,
526+
If the $config_path configuration file or any of the
527+
SPLUNK_* environment variables in the $regkey registry key are modified,
507528
the collector service must be restarted to apply the changes by restarting the system or running the
508529
following PowerShell commands:
509530
PS> Stop-Service $service_name

0 commit comments

Comments
 (0)