source: admin/Sources/Clients/ogagent/windows/ogagent.nsi @ 062ea34

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacion
Last change on this file since 062ea34 was 12e1eef, checked in by Ramón M. Gómez <ramongomez@…>, 6 years ago

#913: Adapting commit 0fcdc63 from master branch.

  • Property mode set to 100644
File size: 8.4 KB
Line 
1# We need http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin
2# Copy inside the two x86_xxxxx folders inside nsis plugins folder
3Name "OpenGnsys Agent"
4
5# OpenGnsys Agent version
6!define /file OGA_VERSION "src\VERSION"
7!define /file OGA_WINVERSION "windows\VERSION"
8
9# General Symbol Definitions
10!define REGKEY "SOFTWARE\OGAgent"
11!if ${OGA_VERSION} == ${OGA_WINVERSION}
12  !define VERSION ${OGA_WINVERSION}.0
13!else
14  !define VERSION ${OGA_WINVERSION}.1
15!endif
16!define COMPANY "OpenGnsys Project"
17!define URL https://opengnsys.es
18
19# MultiUser Symbol Definitions
20!define MULTIUSER_EXECUTIONLEVEL Admin
21#!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
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
40
41# Reserved Files
42!insertmacro MUI_RESERVEFILE_LANGDLL
43
44# Variables
45Var StartMenuGroup
46
47# Installer pages
48!insertmacro MUI_PAGE_WELCOME
49!insertmacro MUI_PAGE_LICENSE src\license.txt
50!insertmacro MUI_PAGE_DIRECTORY
51!insertmacro MUI_PAGE_INSTFILES
52!insertmacro MUI_PAGE_FINISH
53!insertmacro MUI_UNPAGE_CONFIRM
54!insertmacro MUI_UNPAGE_INSTFILES
55
56# Installer languages
57!insertmacro MUI_LANGUAGE English
58!insertmacro MUI_LANGUAGE Spanish
59!insertmacro MUI_LANGUAGE French
60!insertmacro MUI_LANGUAGE German
61
62# Installer attributes
63BrandingText "OpenGnsys"
64OutFile OGAgentSetup-${OGA_VERSION}.exe
65InstallDir OGAgent
66CRCCheck on
67XPStyle on
68ShowInstDetails hide
69VIProductVersion "${VERSION}.0.0"
70VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName "OGAgent"
71VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion "${VERSION}"
72VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName "${COMPANY}"
73VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyWebsite "${URL}"
74VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion "${VERSION}"
75VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription "OpenGnsys Agent installer"
76VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright "(c) 2015 Virtual Cable S.L.U."
77InstallDirRegKey HKLM "${REGKEY}" Path
78ShowUninstDetails show
79
80# Installer sections
81Section -Main SEC0000
82    SetShellVarContext all
83    SetOutPath $INSTDIR
84    SetOverwrite on
85    File /r bin\*.*
86    File vcredist_x86.exe
87    WriteRegStr HKLM "${REGKEY}\Components" Main 1
88SectionEnd
89
90Section -post SEC0001
91    SetShellVarContext current
92    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
93    SetOutPath $INSTDIR
94    WriteUninstaller $INSTDIR\OGAgentUninstaller.exe
95    SetOutPath $SMPROGRAMS\$StartMenuGroup
96    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" $INSTDIR\OGAgentUninstaller.exe
97    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
98    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
99    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
100    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
101    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\OGAgentUninstaller.exe
102    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\OGAgentUninstaller.exe
103    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool $INSTDIR\OGAgentUser.exe
104    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
105    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
106    ExecWait '"$INSTDIR\vcredist_x86.exe" /passive /norestart'
107    # Add the application to the firewall exception list - All Networks - All IP Version - Enabled
108    # SimpleFC::AddApplication "OpenGnsys Agent Service" "$INSTDIR\OGAgentService.exe" 0 2 "" 1
109    # SimpleFC::AdvAddRule [name] [description] [protocol] [direction]
110    #  [status] [profile] [action] [application] [service_name] [icmp_types_and_codes]
111    #  [group] [local_ports] [remote_ports] [local_address] [remote_address]
112    #
113    SimpleFC::AdvAddRule "OpenGnsys Agent Firewall rules" "Firewall rules for OpenGnsys Agent interaction with broker." "6" "1" \
114      "1" "7" "1" "$INSTDIR\OGAgentService.exe" "" "" \
115      "" "" "" "" ""   
116    Pop $0 ; return error(1)/success(0)
117    # Disable fast boot on Windows 10, if registry key exists.
118    ReadRegDWORD $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled
119    IfErrors 0 +2
120    WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled 0
121    # Install service
122    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe --startup auto install" # Add service after installation
123    # Update recovery options
124    nsExec::Exec /OEM "$INSTDIR\OGAServiceHelper.exe"
125SectionEnd
126
127# Macro for selecting uninstaller sections
128!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
129    Push $R0
130    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
131    StrCmp $R0 1 0 next${UNSECTION_ID}
132    !insertmacro SelectSection "${UNSECTION_ID}"
133    GoTo done${UNSECTION_ID}
134next${UNSECTION_ID}:
135    !insertmacro UnselectSection "${UNSECTION_ID}"
136done${UNSECTION_ID}:
137    Pop $R0
138!macroend
139
140# Uninstaller sections
141Section /o -un.Main UNSEC0000
142    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe stop" # Stops the service prior uninstall
143    nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe remove" # Removes the service prior uninstall
144    Delete /REBOOTOK "$INSTDIR\*.*"
145    DeleteRegValue HKLM "${REGKEY}\Components" Main
146    DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool
147SectionEnd
148
149Section -un.post UNSEC0001
150    # Remove application from the firewall exception list
151    # SimpleFC::RemoveApplication "$INSTDIR\OGAgentService.exe"
152    SimpleFC::AdvRemoveRule "OpenGnsys Agent Firewall rules"
153    Pop $0 ; return error(1)/success(0)
154
155    SetShellVarContext current
156    StrCpy $StartMenuGroup "OpenGnsys Agent"
157    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
158    Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
159    Delete /REBOOTOK $INSTDIR\OGAgentUninstaller.exe
160    DeleteRegValue HKLM "${REGKEY}" Path
161    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
162    DeleteRegKey /IfEmpty HKLM "${REGKEY}"
163    RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
164    SetShellVarContext all
165    RmDir /REBOOTOK $INSTDIR
166    SetRebootFlag true
167    MessageBox MB_YESNO "$(^RebootMessage)" IDNO donotreboot
168        Reboot # Reboot is needed after uninstalling, so new installs works fine
169    donotreboot:
170SectionEnd
171
172# Installer functions
173Function .onInit
174    InitPluginsDir
175    StrCpy $StartMenuGroup "OpenGnsys Agent"
176   
177    !insertmacro MUI_LANGDLL_DISPLAY
178    !insertmacro MULTIUSER_INIT
179FunctionEnd
180
181# Uninstaller functions
182Function un.onInit
183    StrCpy $StartMenuGroup "OpenGnsys Agent"
184    !insertmacro MUI_UNGETLANGUAGE
185    !insertmacro MULTIUSER_UNINIT
186    !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
187FunctionEnd
188
189# Installer Language Strings
190LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
191LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)"
192LangString ^UninstallLink ${LANG_FRENCH} "D�sinstaller $(^Name)"
193LangString ^UninstallLink ${LANG_GERMAN} "deinstallieren $(^Name)"
194LangString ^RebootMessage ${LANG_ENGLISH} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will need to reboot."
195LangString ^RebootMessage ${LANG_SPANISH} "¿Reiniciar el sistema para completar el proceso?$\nNota: es necesario reiniciar para instalar un nuevo $(^Name)."
196LangString ^RebootMessage ${LANG_FRENCH} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will ned to reboot."
197LangString ^RebootMessage ${LANG_GERMAN} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will ned to reboot."
Note: See TracBrowser for help on using the repository browser.