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

Unified Windows installer + passing the version number to nsis phase #101

Merged
merged 2 commits into from
Nov 15, 2016
Merged
Changes from 1 commit
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
72 changes: 35 additions & 37 deletions dist/recipe.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
; Start

Name "Graylog Collector Sidecar"
!define VERSION "0.1.0"
!define MUI_FILE "savefile"
!define MUI_BRANDINGTEXT "Graylog Collector Sidecar v${VERSION}"
CRCCheck On
Expand All @@ -14,6 +13,7 @@
!include ReplaceInFile.nsh
!include FileFunc.nsh
!include WordFunc.nsh
!include x64.nsh

VIProductVersion "0.${VERSION}"
VIAddVersionKey "FileVersion" "${VERSION}"
Expand All @@ -23,11 +23,7 @@
;---------------------------------
;General

!ifndef win32
OutFile "pkg/collector_sidecar_installer_${VERSION}_x64.exe"
!else
OutFile "pkg/collector_sidecar_installer_${VERSION}_i386.exe"
!endif
OutFile "pkg/collector_sidecar_installer_${VERSION}_x86.exe"
ShowInstDetails "nevershow"
ShowUninstDetails "nevershow"
SetCompressor "bzip2"
Expand All @@ -42,21 +38,13 @@
Var Tags
Var Dialog
Var Label
Var Graylog_dir
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be called GraylogDir

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'm changing it ;-)


;Pages
;Page directory
Page custom nsDialogsPage nsDialogsPageLeave
Page instfiles

;--------------------------------
;Folder selection page

!ifndef win32
InstallDir "$PROGRAMFILES64\Graylog\collector-sidecar"
!else
InstallDir "$PROGRAMFILES32\Graylog\collector-sidecar"
!endif

;--------------------------------
;Modern UI Configuration

Expand All @@ -76,6 +64,17 @@
!insertmacro WordFind
!insertmacro WordFind2X

!macro Check_X64
${If} ${RunningX64}
SetRegView 64
Strcpy $Graylog_dir "$PROGRAMFILES64\Graylog"
${Else}
SetRegView 32
Strcpy $Graylog_dir "$PROGRAMFILES32\Graylog"
${EndIf}
Strcpy $INSTDIR "$Graylog_dir\collector-sidecar"
!macroend

;--------------------------------
;Data

Expand All @@ -85,26 +84,23 @@
;Installer Sections
Section "Install"

!ifndef win32
SetRegView 64
!else
SetRegView 32
!endif

;Add files
SetOutPath "$INSTDIR\generated"
SetOutPath "$INSTDIR"

!ifndef win32
File "../build/${VERSION}/windows/amd64/graylog-collector-sidecar.exe"
!else
File "../build/${VERSION}/windows/386/graylog-collector-sidecar.exe"
!endif
File "collectors/winlogbeat/windows/winlogbeat.exe"
File "collectors/filebeat/windows/filebeat.exe"
File /oname=collector_sidecar.yml "../collector_sidecar_windows.yml"
File "../COPYING"
File "graylog.ico"
File "graylog.ico"


${If} ${RunningX64}
File /oname=Graylog-collector-sidecar.exe "../build/${VERSION}/windows/amd64/graylog-collector-sidecar.exe"
${Else}
File /oname=Graylog-collector-sidecar.exe "../build/${VERSION}/windows/386/graylog-collector-sidecar.exe"
${EndIf}

WriteUninstaller "$INSTDIR\uninstall.exe"

Expand Down Expand Up @@ -139,6 +135,7 @@ SectionEnd

Section "Post"


; Update configuration
${GetParameters} $Params
${GetOptions} $Params "-SERVERURL=" $ParamServerUrl
Expand Down Expand Up @@ -180,12 +177,6 @@ SectionEnd
;Uninstaller Section
Section "Uninstall"

!ifndef win32
SetRegView 64
!else
SetRegView 32
!endif

;Uninstall system service
ExecWait '"$INSTDIR\graylog-collector-sidecar.exe" -service stop'
ExecWait '"$INSTDIR\graylog-collector-sidecar.exe" -service uninstall'
Expand All @@ -194,12 +185,9 @@ Section "Uninstall"
RMDir /r "$INSTDIR\*.*"

;Remove the installation directory
SetOutPath $TEMP
RMDir "$INSTDIR"
!ifndef win32
RMDir "$PROGRAMFILES64\graylog"
!else
RMDir "$PROGRAMFILES32\graylog"
!endif
RMDir $Graylog_dir

;Remove uninstall entries in the registry
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GraylogCollectorSidecar"
Expand All @@ -209,6 +197,16 @@ SectionEnd

;--------------------------------
;Functions

Function .onInit
!insertmacro Check_X64
FunctionEnd


Function un.oninit
!insertmacro Check_X64
FunctionEnd

Function .onInstSuccess
MessageBox MB_OK "You have successfully installed Graylog Collector Sidecar." /SD IDOK
FunctionEnd
Expand Down