source: ogAgent-Git/windows/ogagent.nsi

main 4.0.0
Last change on this file was 833a0dc, checked in by Natalia Serrano <natalia.serrano@…>, 10 months ago

refs #468 remove some whitespace

This is a pretty much dumb commit just to make a ref to the ticket #468,
because the changes proposed to fix #464 also work on linux.

  • Property mode set to 100644
File size: 9.3 KB
RevLine 
[11f7a07]1# We need http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin
2# Copy inside the two x86_xxxxx folders inside nsis plugins folder
[9bfb4ee]3Name "OpenGnsys Agent"
[11f7a07]4
[2617b6d]5# OpenGnsys Agent version
[2e072d2]6!define /file OGA_VERSION "src\VERSION"
[2617b6d]7!define /file OGA_WINVERSION "windows\VERSION"
[11f7a07]8
9# General Symbol Definitions
10!define REGKEY "SOFTWARE\OGAgent"
[2617b6d]11!if ${OGA_VERSION} == ${OGA_WINVERSION}
12  !define VERSION ${OGA_WINVERSION}.0
13!else
14  !define VERSION ${OGA_WINVERSION}.1
15!endif
[9bfb4ee]16!define COMPANY "OpenGnsys Project"
[2e072d2]17!define URL https://opengnsys.es
[b18cd9b]18!define CONFIGFILE "cfg\ogagent.cfg"
[11f7a07]19
20# MultiUser Symbol Definitions
21!define MULTIUSER_EXECUTIONLEVEL Admin
22!define MULTIUSER_INSTALLMODE_COMMANDLINE
23!define MULTIUSER_INSTALLMODE_INSTDIR OGAgent
24!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REGKEY}"
25!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path"
26
27# MUI Symbol Definitions
28!define MUI_ICON "src\img\oga.ico"
29!define MUI_FINISHPAGE_NOAUTOCLOSE
30!define MUI_UNICON "src\img\oga.ico"
31!define MUI_UNFINISHPAGE_NOAUTOCLOSE
32!define MUI_LANGDLL_REGISTRY_ROOT HKLM
33!define MUI_LANGDLL_REGISTRY_KEY ${REGKEY}
34!define MUI_LANGDLL_REGISTRY_VALUENAME InstallerLanguage
35
36# Included files
37!include MultiUser.nsh
38!include Sections.nsh
39!include MUI2.nsh
[b18cd9b]40!include nsDialogs.nsh
41!include LogicLib.nsh
42!include Filefunc.nsh
[11f7a07]43
44# Reserved Files
45!insertmacro MUI_RESERVEFILE_LANGDLL
46
47# Variables
48Var StartMenuGroup
[b18cd9b]49Var SERVERIP
50Var SERVERIP_VALUE
[11f7a07]51
52# Installer pages
53!insertmacro MUI_PAGE_WELCOME
54!insertmacro MUI_PAGE_LICENSE src\license.txt
[9732c07]55Page custom "ParamsPage" "ParamsPageLeave"
[11f7a07]56!insertmacro MUI_PAGE_DIRECTORY
57!insertmacro MUI_PAGE_INSTFILES
58!insertmacro MUI_PAGE_FINISH
59!insertmacro MUI_UNPAGE_CONFIRM
60!insertmacro MUI_UNPAGE_INSTFILES
61
62# Installer languages
63!insertmacro MUI_LANGUAGE English
64!insertmacro MUI_LANGUAGE Spanish
65!insertmacro MUI_LANGUAGE French
66!insertmacro MUI_LANGUAGE German
67
68# Installer attributes
[9bfb4ee]69BrandingText "OpenGnsys"
[11f7a07]70OutFile OGAgentSetup-${OGA_VERSION}.exe
71InstallDir OGAgent
72CRCCheck on
73XPStyle on
74ShowInstDetails hide
75VIProductVersion "${VERSION}.0.0"
76VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName "OGAgent"
77VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion "${VERSION}"
78VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName "${COMPANY}"
79VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyWebsite "${URL}"
80VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion "${VERSION}"
[9bfb4ee]81VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription "OpenGnsys Agent installer"
[11f7a07]82VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright "(c) 2015 Virtual Cable S.L.U."
83InstallDirRegKey HKLM "${REGKEY}" Path
84ShowUninstDetails show
85
86# Installer sections
87Section -Main SEC0000
88    SetShellVarContext all
89    SetOutPath $INSTDIR
90    SetOverwrite on
[d7a7a1f]91    File /r src\dist\OGAgent\*.*
[10fab78]92    File windows\VC_redist.x64.exe
[f2af820]93    File src\VERSION
[11f7a07]94    WriteRegStr HKLM "${REGKEY}\Components" Main 1
95SectionEnd
96
97Section -post SEC0001
[ad5af0b]98    WriteIniStr $INSTDIR\${CONFIGFILE} "opengnsys" "remote" "https://$SERVERIP_VALUE/opengnsys/rest"
[11f7a07]99    SetShellVarContext current
100    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
101    SetOutPath $INSTDIR
102    WriteUninstaller $INSTDIR\OGAgentUninstaller.exe
103    SetOutPath $SMPROGRAMS\$StartMenuGroup
104    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" $INSTDIR\OGAgentUninstaller.exe
105    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
106    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
107    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
108    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
109    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\OGAgentUninstaller.exe
110    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\OGAgentUninstaller.exe
111    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool $INSTDIR\OGAgentUser.exe
112    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
113    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
[d7a7a1f]114    ExecWait '"$INSTDIR\VC_redist.x64.exe" /passive /norestart'
[11f7a07]115    # Add the application to the firewall exception list - All Networks - All IP Version - Enabled
[9bfb4ee]116    # SimpleFC::AddApplication "OpenGnsys Agent Service" "$INSTDIR\OGAgentService.exe" 0 2 "" 1
[833a0dc]117    # SimpleFC::AdvAddRule [name] [description] [protocol] [direction]
118    #  [status] [profile] [action] [application] [service_name] [icmp_types_and_codes]
[11f7a07]119    #  [group] [local_ports] [remote_ports] [local_address] [remote_address]
120    #
[9bfb4ee]121    SimpleFC::AdvAddRule "OpenGnsys Agent Firewall rules" "Firewall rules for OpenGnsys Agent interaction with broker." "6" "1" \
[11f7a07]122      "1" "7" "1" "$INSTDIR\OGAgentService.exe" "" "" \
[833a0dc]123      "" "" "" "" ""
[11f7a07]124    Pop $0 ; return error(1)/success(0)
[2e072d2]125    # Disable fast boot on Windows 10, if registry key exists.
126    ReadRegDWORD $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled
127    IfErrors 0 +2
128    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled 0
[11f7a07]129    # Install service
130    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe --startup auto install" # Add service after installation
[ad5af0b]131    Exec "net start ogagent"
132    Exec "$INSTDIR\OGAgentUser.exe"
[11f7a07]133SectionEnd
134
135# Macro for selecting uninstaller sections
136!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
137    Push $R0
138    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
139    StrCmp $R0 1 0 next${UNSECTION_ID}
140    !insertmacro SelectSection "${UNSECTION_ID}"
141    GoTo done${UNSECTION_ID}
142next${UNSECTION_ID}:
143    !insertmacro UnselectSection "${UNSECTION_ID}"
144done${UNSECTION_ID}:
145    Pop $R0
146!macroend
147
148# Uninstaller sections
149Section /o -un.Main UNSEC0000
[f2af820]150    nsExec::Exec "taskkill /F /IM OGAgentUser.exe /T"
[11f7a07]151    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe stop" # Stops the service prior uninstall
[833a0dc]152    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe remove" # Removes the service prior uninstall
[f2af820]153    nsExec::Exec "taskkill /F /IM OGAgentService.exe /T"
[11f7a07]154    Delete /REBOOTOK "$INSTDIR\*.*"
155    DeleteRegValue HKLM "${REGKEY}\Components" Main
156    DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool
157SectionEnd
158
159Section -un.post UNSEC0001
160    # Remove application from the firewall exception list
161    # SimpleFC::RemoveApplication "$INSTDIR\OGAgentService.exe"
[9bfb4ee]162    SimpleFC::AdvRemoveRule "OpenGnsys Agent Firewall rules"
[11f7a07]163    Pop $0 ; return error(1)/success(0)
164
165    SetShellVarContext current
[9bfb4ee]166    StrCpy $StartMenuGroup "OpenGnsys Agent"
[11f7a07]167    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
168    Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
169    Delete /REBOOTOK $INSTDIR\OGAgentUninstaller.exe
170    DeleteRegValue HKLM "${REGKEY}" Path
171    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
172    DeleteRegKey /IfEmpty HKLM "${REGKEY}"
173    RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
174    SetShellVarContext all
[f2af820]175    RmDir /r /REBOOTOK $INSTDIR
[11f7a07]176SectionEnd
177
178# Installer functions
179Function .onInit
180    InitPluginsDir
[ad5af0b]181    Call GetParameters
[9bfb4ee]182    StrCpy $StartMenuGroup "OpenGnsys Agent"
[833a0dc]183
[11f7a07]184    !insertmacro MUI_LANGDLL_DISPLAY
185    !insertmacro MULTIUSER_INIT
186FunctionEnd
187
188# Uninstaller functions
189Function un.onInit
[9bfb4ee]190    StrCpy $StartMenuGroup "OpenGnsys Agent"
[11f7a07]191    !insertmacro MUI_UNGETLANGUAGE
192    !insertmacro MULTIUSER_UNINIT
193    !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
194FunctionEnd
195
[ad5af0b]196# Parameters dialog box
[b18cd9b]197Function ParamsPage
[9732c07]198    !insertmacro MUI_HEADER_TEXT "$(PARAMS_TITLE)" ""
199    nsDialogs::Create /NOUNLOAD 1018
[b18cd9b]200    Pop $0
201    ${If} $0 == error
202        Abort
203    ${EndIf}
[9732c07]204    ${NSD_CreateLabel} 0 0 100% 12u "$(SERVER_LABEL):"
[b18cd9b]205    Pop $0
206    ${NSD_CreateText} 10% 20u 80% 12u "$SERVERIP_VALUE"
207    Pop $SERVERIP
208    nsDialogs::Show
209FunctionEnd
210
[ad5af0b]211# Get parameters from the dialog
[b18cd9b]212Function ParamsPageLeave
213    ${NSD_GetText} $SERVERIP $SERVERIP_VALUE
214FunctionEnd
215
[ad5af0b]216# Assign input parameters or default values to variables
217Function GetParameters
218    ${GetOptions} $CMDLINE "/server" $SERVERIP_VALUE
219    ${If} $SERVERIP_VALUE == ""
220        StrCpy $SERVERIP_VALUE "192.168.2.10"
221    ${EndIf}
222FunctionEnd
223
[11f7a07]224# Installer Language Strings
[9732c07]225LangString PARAMS_TITLE ${LANG_ENGLISH} "Setup parameters"
226LangString PARAMS_TITLE ${LANG_SPANISH} "Parametros de configuracion"
227LangString PARAMS_TITLE ${LANG_FRENCH} "Parametres de configuration"
228LangString PARAMS_TITLE ${LANG_GERMAN} "Setup-Parameter"
229LangString SERVER_LABEL ${LANG_ENGLISH} "OpenGnsys Server IP Address"
230LangString SERVER_LABEL ${LANG_SPANISH} "Direccion IP del Servidor OpenGnsys"
231LangString SERVER_LABEL ${LANG_FRENCH} "Adresse IP du Serveur OpenGnsys"
232LangString SERVER_LABEL ${LANG_GERMAN} "OpenGnsys-Server-IP-Adresse"
[11f7a07]233LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
234LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)"
235LangString ^UninstallLink ${LANG_FRENCH} "D�sinstaller $(^Name)"
236LangString ^UninstallLink ${LANG_GERMAN} "deinstallieren $(^Name)"
Note: See TracBrowser for help on using the repository browser.