Files
LOGAR/compilation/installer_client.nsi
T
me0nline c6d04f8896
CI Test Suite / Run Component Tests & Pipeline Verification (push) Successful in 1m42s
Release Binaries & Packages / Build & Release Standalone Binaries (Linux & Windows Cross-Compilation) (push) Successful in 5m40s
feat(release): v0.3.4.1 - fix installer UI text overlap and branding
2026-09-27 19:30:52 +02:00

230 lines
8.5 KiB
NSIS

!include "MUI2.nsh"
!include "LogicLib.nsh"
!include "nsDialogs.nsh"
Name "LOGAR Client"
OutFile "../dist/LOGAR-Client-Setup.exe"
InstallDir "$PROGRAMFILES64\LOGAR"
RequestExecutionLevel admin
BrandingText "LOGAR Centralized Log Aggregator && Forwarder"
VIProductVersion "0.3.4.1"
VIAddVersionKey "ProductName" "LOGAR Client"
VIAddVersionKey "CompanyName" "LOGAR"
VIAddVersionKey "LegalCopyright" "© 2026 LOGAR"
VIAddVersionKey "FileDescription" "LOGAR Windows Edge Log Forwarder Setup"
VIAddVersionKey "FileVersion" "0.3.4.1"
VIAddVersionKey "ProductVersion" "0.3.4.1"
# --- Visual Graphics & Branding ---
!define MUI_ICON "assets/logo.ico"
!define MUI_UNICON "assets/logo.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "assets/wizard_header.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "assets/wizard_sidebar.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "assets/wizard_sidebar.bmp"
Var DATADIR
Var CFGFILE
Var IS_UPDATE
Var CfgDialog
Var CfgFileInput
Var CfgBrowseBtn
# --- UI Pages ---
!define MUI_ABORTWARNING
# Welcome Page
!define MUI_WELCOMEPAGE_TITLE "Welcome to LOGAR Client Setup"
!define MUI_WELCOMEPAGE_TEXT "LOGAR Client provides secure, encrypted Windows Event Log forwarding with automatic certificate enrollment and state tracking.$\r$\n$\r$\nThis wizard will guide you through installing the forwarder service."
!insertmacro MUI_PAGE_WELCOME
# Directory Page 1: Installation Directory
!define MUI_PAGE_HEADER_TEXT "Choose Installation Location"
!define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install program binaries."
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpdate
!define MUI_DIRECTORYPAGE_VARIABLE $INSTDIR
!insertmacro MUI_PAGE_DIRECTORY
# Directory Page 2: Data Directory
!define MUI_PAGE_HEADER_TEXT "Choose Data & Storage Location"
!define MUI_PAGE_HEADER_SUBTEXT "Choose where state tracking, certificates, and configuration files should be stored."
!define MUI_DIRECTORYPAGE_TEXT_TOP "Choose the folder where LOGAR Client should store state tracking (client_state.json), configuration (client_config.json), and mTLS certificates.$\r$\n$\r$\nDefault is recommended for automatic background service access."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Data & Storage Folder"
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpdate
!define MUI_DIRECTORYPAGE_VARIABLE $DATADIR
!insertmacro MUI_PAGE_DIRECTORY
# Custom Page: Config File Selection
Page custom ConfigPageCreate ConfigPageLeave
# Instfiles Page
!insertmacro MUI_PAGE_INSTFILES
# Finish Page
!define MUI_FINISHPAGE_TITLE "Installation Complete"
!define MUI_FINISHPAGE_TEXT "LOGAR Client has been successfully installed and configured as an automated background service."
!insertmacro MUI_PAGE_FINISH
# Uninstaller Pages
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Function SkipIfUpdate
${If} $IS_UPDATE == "1"
Abort
${EndIf}
FunctionEnd
Function .onInit
SetShellVarContext all
StrCpy $DATADIR "$APPDATA\LOGAR"
StrCpy $CFGFILE ""
StrCpy $IS_UPDATE "0"
# 1. Mutual Exclusion Check: Deny installation if LOGAR Server is present
ReadRegStr $0 HKLM "Software\LOGAR\LOGAR-Server" "DataDir"
ReadRegStr $1 HKLM "Software\LOGAR\LOGAR-Server" "InstallDir"
${If} $0 != ""
${OrIf} $1 != ""
${OrIf} ${FileExists} "$PROGRAMFILES64\LOGAR-Server\Server.exe"
${OrIf} ${FileExists} "$PROGRAMFILES\LOGAR-Server\Server.exe"
MessageBox MB_ICONSTOP|MB_OK "LOGAR Server is already installed on this machine.$\r$\n$\r$\nLOGAR Client cannot be co-installed on a LOGAR Server host (LOGAR Server already provides built-in log collection).$\r$\n$\r$\nPlease uninstall LOGAR Server first if you wish to run a standalone forwarder client."
Abort
${EndIf}
# 2. Existing LOGAR Client Detection for In-Place Update Mode
ReadRegStr $0 HKLM "Software\LOGAR\LOGAR-Client" "DataDir"
ReadRegStr $1 HKLM "Software\LOGAR\LOGAR-Client" "InstallDir"
${If} $0 != ""
${OrIf} $1 != ""
${OrIf} ${FileExists} "$INSTDIR\Win_Client.exe"
StrCpy $IS_UPDATE "1"
${If} $0 != ""
StrCpy $DATADIR $0
${EndIf}
${If} $1 != ""
StrCpy $INSTDIR $1
${EndIf}
MessageBox MB_ICONINFORMATION|MB_OK "An existing installation of LOGAR Client was detected.$\r$\n$\r$\nSetup will perform an in-place update: program files will be updated while your existing configuration (client_config.json), state tracking, and certificates are preserved."
${EndIf}
FunctionEnd
Function ConfigPageCreate
${If} $IS_UPDATE == "1"
Abort
${EndIf}
nsDialogs::Create 1018
Pop $CfgDialog
${If} $CfgDialog == error
Abort
${EndIf}
!insertmacro MUI_HEADER_TEXT "Import Client Configuration (Optional)" "Choose a client_config.json profile exported from LOGAR Server."
${NSD_CreateLabel} 0 0 100% 48u "If you have exported a client_config.json profile bundle from your LOGAR Server dashboard, select it below to configure the forwarder immediately.$\r$\n$\r$\nLeave this field blank to configure later."
Pop $0
${NSD_CreateText} 0 54u 75% 14u "$CFGFILE"
Pop $CfgFileInput
${NSD_CreateButton} 78% 53u 22% 16u "Browse..."
Pop $CfgBrowseBtn
${NSD_OnClick} $CfgBrowseBtn OnBrowseCfg
nsDialogs::Show
FunctionEnd
Function OnBrowseCfg
nsDialogs::SelectFileDialog open "" "LOGAR Client Profiles (*.json)|*.json|All Files (*.*)|*.*"
Pop $0
${If} $0 != ""
StrCpy $CFGFILE $0
${NSD_SetText} $CfgFileInput $CFGFILE
${EndIf}
FunctionEnd
Function ConfigPageLeave
${NSD_GetText} $CfgFileInput $CFGFILE
FunctionEnd
Section "Install"
SetShellVarContext all
# Terminate any existing service or running processes before replacing files
ExecWait 'net stop LOGAR_Client'
ExecWait 'sc stop LOGAR_Client'
ExecWait 'taskkill /F /T /IM Win_Client.exe'
ExecWait 'taskkill /F /T /IM nssm.exe'
Sleep 500
SetOutPath "$INSTDIR"
File "../dist/Win_Client.exe"
File "../compilation/nssm.exe"
File /r "../dist/runtime"
CreateDirectory "$DATADIR"
ExecWait 'icacls "$DATADIR" /grant "*S-1-5-32-545:(OI)(CI)M" /T /Q'
# If client config file was selected and not updating existing config, copy to data directory
${If} $IS_UPDATE != "1"
${AndIf} $CFGFILE != ""
${AndIf} ${FileExists} "$CFGFILE"
CopyFiles /SILENT "$CFGFILE" "$DATADIR\client_config.json"
${EndIf}
# Install and configure service via NSSM
ExecWait '"$INSTDIR\nssm.exe" install LOGAR_Client "$INSTDIR\Win_Client.exe"'
ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Client AppDirectory "$INSTDIR"'
ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Client AppStdout "$DATADIR\client.log"'
ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Client AppStderr "$DATADIR\client_err.log"'
ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Client AppParameters "--config $\"$DATADIR\client_config.json$\" --interval 30"'
ExecWait '"$INSTDIR\nssm.exe" start LOGAR_Client'
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\LOGAR\LOGAR-Client" "InstallDir" "$INSTDIR"
WriteRegStr HKLM "Software\LOGAR\LOGAR-Client" "DataDir" "$DATADIR"
SectionEnd
Section "Uninstall"
SetShellVarContext all
ReadRegStr $DATADIR HKLM "Software\LOGAR\LOGAR-Client" "DataDir"
${If} $DATADIR == ""
StrCpy $DATADIR "$APPDATA\LOGAR"
${EndIf}
# 1. Stop and remove service
ExecWait 'net stop LOGAR_Client'
ExecWait 'sc stop LOGAR_Client'
${If} ${FileExists} "$INSTDIR\nssm.exe"
ExecWait '"$INSTDIR\nssm.exe" stop LOGAR_Client'
ExecWait '"$INSTDIR\nssm.exe" remove LOGAR_Client confirm'
${EndIf}
ExecWait 'sc delete LOGAR_Client'
# 2. Force terminate any lingering processes
ExecWait 'taskkill /F /T /IM Win_Client.exe'
ExecWait 'taskkill /F /T /IM nssm.exe'
ExecWait `powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "Get-CimInstance Win32_Process | Where-Object { $$_.ExecutablePath -like '$INSTDIR\*' } | ForEach-Object { Stop-Process -Id $$_.ProcessId -Force -ErrorAction SilentlyContinue }"`
Sleep 1200
# 3. Clean up all installation and data files
RMDir /r "$INSTDIR\runtime"
RMDir /r "$INSTDIR\certs"
Delete "$INSTDIR\client_config.json"
Delete "$INSTDIR\client_state.json"
Delete "$INSTDIR\*.log"
Delete "$INSTDIR\Win_Client.exe"
Delete "$INSTDIR\nssm.exe"
Delete "$INSTDIR\uninstall.exe"
RMDir /r "$INSTDIR"
RMDir /r "$DATADIR"
DeleteRegKey HKLM "Software\LOGAR\LOGAR-Client"
DeleteRegKey /ifempty HKLM "Software\LOGAR"
SectionEnd