source: ogAgent-Git/windows/ogagent.nsi @ 4d6db25

configure-ptt-chedecorare-oglive-methodsejecutarscript-b64fix-cfg2objfixes-winlgromero-filebeatmainmodulesnew-browserno-ptt-paramogadmcliogadmclient-statusogagent-jobsogagent-macosogcore1ogliveoglogoglog2override-moduleping1ping2ping3ping4py3-winpython3qndtestreport-progresstlsunification2unification3versionswindows-fixes
Last change on this file since 4d6db25 was 2e072d2, checked in by ramon <ramongomez@…>, 7 years ago

#718: Mejoras en OGAgent para Windows:

  • Obtener versión y edición de Windows.
  • Ampliar el tiempo de detección de la red a 5 min.
  • Deshabilitar la hibernación en la instalación del OGAgent.
  • Reinicio opcional en la desinstalación.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5553 a21b9725-9963-47de-94b9-378ad31fedc9

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