!include "MUI2.nsh" !include "LogicLib.nsh" Name "LOGAR Server" OutFile "../dist/LOGAR-Server-Setup.exe" InstallDir "$PROGRAMFILES64\LOGAR-Server" RequestExecutionLevel admin BrandingText "LOGAR Enterprise SIEM & Log Ingestion" VIProductVersion "0.3.1.0" VIAddVersionKey "ProductName" "LOGAR Server" VIAddVersionKey "CompanyName" "LOGAR Security Systems" VIAddVersionKey "LegalCopyright" "© 2026 LOGAR Security Systems" VIAddVersionKey "FileDescription" "LOGAR Cloud Hub & TCP Ingestion Server Setup" VIAddVersionKey "FileVersion" "0.3.1.0" VIAddVersionKey "ProductVersion" "0.3.1.0" Var DATADIR Var LICFILE Var LicDialog Var LicFileInput Var LicBrowseBtn # --- UI Pages --- !define MUI_ABORTWARNING # Welcome Page !define MUI_WELCOMEPAGE_TITLE "Welcome to LOGAR Server Setup" !define MUI_WELCOMEPAGE_TEXT "LOGAR provides high-performance encrypted log ingestion, temporal analysis, and mTLS client enrollment.\r\n\r\nThis wizard will guide you through installing LOGAR Server and configuring it as an automated Windows 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_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 database, certificates, and configuration files should be stored." !define MUI_DIRECTORYPAGE_TEXT_TOP "Choose the folder where LOGAR Server should store its database (logar_state.db), configuration (server_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_DIRECTORYPAGE_VARIABLE $DATADIR !insertmacro MUI_PAGE_DIRECTORY # Custom Page: License File Selection Page custom LicensePageCreate LicensePageLeave # Instfiles Page !insertmacro MUI_PAGE_INSTFILES # Finish Page !define MUI_FINISHPAGE_TITLE "Installation Complete" !define MUI_FINISHPAGE_TEXT "LOGAR Server has been successfully installed and started as a background Windows service.\r\n\r\nWeb Hub Dashboard: http://localhost:8443\r\nTCP Ingestion Port: 9443" !insertmacro MUI_PAGE_FINISH # Uninstaller Pages !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE "English" Function .onInit SetShellVarContext all StrCpy $DATADIR "$APPDATA\LOGAR-Server" StrCpy $LICFILE "" FunctionEnd Function LicensePageCreate nsDialogs::Create 1018 Pop $LicDialog ${If} $LicDialog == error Abort ${EndIf} !insertmacro MUI_HEADER_TEXT "Enterprise License Activation (Optional)" "Choose a .lic license file to activate your server during installation." ${NSD_CreateLabel} 0 0 100% 30u "If you have received an activated .lic license file, select it below to activate the server immediately.$\r$\n$\r$\nLeave this field blank to use the default evaluation license." Pop $0 ${NSD_CreateText} 0 38u 75% 12u "$LICFILE" Pop $LicFileInput ${NSD_CreateButton} 78% 37u 22% 14u "Browse..." Pop $LicBrowseBtn ${NSD_OnClick} $LicBrowseBtn OnBrowseLic nsDialogs::Show Function Function OnBrowseLic nsDialogs::SelectFileDialog open "" "LOGAR License Files (*.lic)|*.lic|All Files (*.*)|*.*" Pop $0 ${If} $0 != "" StrCpy $LICFILE $0 ${NSD_SetText} $LicFileInput $LICFILE ${EndIf} Function Function LicensePageLeave ${NSD_GetText} $LicFileInput $LICFILE Function Section "Install" SetShellVarContext all SetOutPath "$INSTDIR" File "../dist/Server.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 license file was selected, import before starting service ${If} $LICFILE != "" ${AndIf} ${FileExists} "$LICFILE" ExecWait '"$INSTDIR\Server.exe" --config "$DATADIR\server_config.json" --import-lic "$LICFILE"' ${EndIf} # Install and configure service via NSSM ExecWait '"$INSTDIR\nssm.exe" install LOGAR_Server "$INSTDIR\Server.exe"' ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Server AppDirectory "$INSTDIR"' ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Server AppStdout "$DATADIR\server.log"' ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Server AppStderr "$DATADIR\server_err.log"' ExecWait '"$INSTDIR\nssm.exe" set LOGAR_Server AppParameters "--config \"$DATADIR\server_config.json\""' ExecWait '"$INSTDIR\nssm.exe" start LOGAR_Server' WriteUninstaller "$INSTDIR\uninstall.exe" WriteRegStr HKLM "Software\LOGAR\LOGAR-Server" "DataDir" "$DATADIR" SectionEnd Section "Uninstall" SetShellVarContext all ReadRegStr $DATADIR HKLM "Software\LOGAR\LOGAR-Server" "DataDir" ${If} $DATADIR == "" StrCpy $DATADIR "$APPDATA\LOGAR-Server" ${EndIf} ExecWait '"$INSTDIR\nssm.exe" stop LOGAR_Server' ExecWait '"$INSTDIR\nssm.exe" remove LOGAR_Server confirm' RMDir /r "$INSTDIR\runtime" RMDir /r "$INSTDIR\certs" Delete "$INSTDIR\server_config.json" Delete "$INSTDIR\logar_state.db" Delete "$INSTDIR\logar_state.db-*" Delete "$INSTDIR\*.log" Delete "$INSTDIR\Server.exe" Delete "$INSTDIR\nssm.exe" Delete "$INSTDIR\uninstall.exe" RMDir /r "$INSTDIR" RMDir /r "$DATADIR" DeleteRegKey HKLM "Software\LOGAR\LOGAR-Server" SectionEnd