Skip to content

Commit

Permalink
first crack at adding a new configurable option to the windows instal…
Browse files Browse the repository at this point in the history
…ler for static mode

Signed-off-by: erikbaranowski <[email protected]>
  • Loading branch information
erikbaranowski committed Dec 11, 2023
1 parent e8fd587 commit da9cf03
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packaging/grafana-agent/windows/install_script.nsis
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ LicenseData LICENSE
Var EnableExporterCheck
Var EnableExporterValue
Var EnableExporterDialog
Var ExpandEnvCheck
Var ExpandEnvValue
Var PassedInParameters
Var Url
Var Username
Expand Down Expand Up @@ -58,6 +60,7 @@ Section "install"
ThisIsSilent:
${GetParameters} $PassedInParameters
${GetOptions} $PassedInParameters "/EnableExporter" $EnableExporterValue
${GetOptions} $PassedInParameters "/ExpandEnv" $ExpandEnvValue
${GetOptions} $PassedInParameters "/Url" $Url
${GetOptions} $PassedInParameters "/Username" $Username
${GetOptions} $PassedInParameters "/Password" $Password
Expand All @@ -81,6 +84,12 @@ Function enableWindowsExporter
${NSD_CreateCheckBox} 0 13u 100% 12u ""
Pop $EnableExporterCheck

${NSD_CreateLabel} 0 0 100% 12u "Expand Environment Variables"
Pop $0

${NSD_CreateCheckBox} 0 13u 100% 12u ""
Pop $ExpandEnvCheck

nsDialogs::Show
FunctionEnd

Expand All @@ -91,6 +100,13 @@ Function enableWindowsExporterLeave
${Else}
StrCpy $EnableExporterValue "false"
${EndIf}

${NSD_GetState} $ExpandEnvCheck $ExpandEnvValue
${If} $ExpandEnvValue == ${BST_CHECKED}
StrCpy $ExpandEnvValue "true"
${Else}
StrCpy $ExpandEnvValue "false"
${EndIf}
FunctionEnd

Function Install
Expand Down Expand Up @@ -128,7 +144,11 @@ Function Install
nsExec::ExecToLog 'sc create "Grafana Agent" binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\""'
Pop $0
# These separate create and config commands are needed, on the config the binpath is required
nsExec::ExecToLog 'sc config "Grafana Agent" start= auto binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\" -config.file=\"$INSTDIR\agent-config.yaml\""'
${If} $ExpandEnvValue == "true"
nsExec::ExecToLog 'sc config "Grafana Agent" start= auto binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\" -config.expand-env -config.file=\"$INSTDIR\agent-config.yaml\""'
${Else}
nsExec::ExecToLog 'sc config "Grafana Agent" start= auto binpath= "\"$INSTDIR\grafana-agent-windows-amd64.exe\" -config.file=\"$INSTDIR\agent-config.yaml\""'
${EndIf}
Pop $0
nsExec::ExecToLog `sc start "Grafana Agent"`
Pop $0
Expand Down

0 comments on commit da9cf03

Please sign in to comment.