1 | # We need http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin
|
---|
2 | # Copy inside the two x86_xxxxx folders inside nsis plugins folder
|
---|
3 | Name "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
|
---|
40 | Var 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
|
---|
58 | BrandingText "OpenGnsys"
|
---|
59 | OutFile OGAgentSetup-${OGA_VERSION}.exe
|
---|
60 | InstallDir OGAgent
|
---|
61 | CRCCheck on
|
---|
62 | XPStyle on
|
---|
63 | ShowInstDetails hide
|
---|
64 | VIProductVersion "${VERSION}.0.0"
|
---|
65 | VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName "OGAgent"
|
---|
66 | VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion "${VERSION}"
|
---|
67 | VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName "${COMPANY}"
|
---|
68 | VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyWebsite "${URL}"
|
---|
69 | VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion "${VERSION}"
|
---|
70 | VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription "OpenGnsys Agent installer"
|
---|
71 | VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright "(c) 2015 Virtual Cable S.L.U."
|
---|
72 | InstallDirRegKey HKLM "${REGKEY}" Path
|
---|
73 | ShowUninstDetails show
|
---|
74 |
|
---|
75 | # Installer sections
|
---|
76 | Section -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
|
---|
83 | SectionEnd
|
---|
84 |
|
---|
85 | Section -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"
|
---|
120 | SectionEnd
|
---|
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}
|
---|
129 | next${UNSECTION_ID}:
|
---|
130 | !insertmacro UnselectSection "${UNSECTION_ID}"
|
---|
131 | done${UNSECTION_ID}:
|
---|
132 | Pop $R0
|
---|
133 | !macroend
|
---|
134 |
|
---|
135 | # Uninstaller sections
|
---|
136 | Section /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
|
---|
142 | SectionEnd
|
---|
143 |
|
---|
144 | Section -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:
|
---|
165 | SectionEnd
|
---|
166 |
|
---|
167 | # Installer functions
|
---|
168 | Function .onInit
|
---|
169 | InitPluginsDir
|
---|
170 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
171 |
|
---|
172 | !insertmacro MUI_LANGDLL_DISPLAY
|
---|
173 | !insertmacro MULTIUSER_INIT
|
---|
174 | FunctionEnd
|
---|
175 |
|
---|
176 | # Uninstaller functions
|
---|
177 | Function un.onInit
|
---|
178 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
179 | !insertmacro MUI_UNGETLANGUAGE
|
---|
180 | !insertmacro MULTIUSER_UNINIT
|
---|
181 | !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
|
---|
182 | FunctionEnd
|
---|
183 |
|
---|
184 | # Installer Language Strings
|
---|
185 | LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
|
---|
186 | LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)"
|
---|
187 | LangString ^UninstallLink ${LANG_FRENCH} "D�sinstaller $(^Name)"
|
---|
188 | LangString ^UninstallLink ${LANG_GERMAN} "deinstallieren $(^Name)"
|
---|
189 | LangString ^RebootMessage ${LANG_ENGLISH} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will need to reboot."
|
---|
190 | LangString ^RebootMessage ${LANG_SPANISH} "¿Reiniciar el sistema para completar el proceso?$\nNota: es necesario reiniciar para instalar un nuevo $(^Name)."
|
---|
191 | LangString ^RebootMessage ${LANG_FRENCH} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will ned to reboot."
|
---|
192 | LangString ^RebootMessage ${LANG_GERMAN} "Reboot the system to complete uninstall process?$\nNote: for a new $(^Name) installation, you will ned to reboot."
|
---|