[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] | 3 | Name "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
|
---|
[11f7a07] | 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
|
---|
| 45 | Var 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
|
---|
[9bfb4ee] | 63 | BrandingText "OpenGnsys"
|
---|
[11f7a07] | 64 | OutFile OGAgentSetup-${OGA_VERSION}.exe
|
---|
| 65 | InstallDir OGAgent
|
---|
| 66 | CRCCheck on
|
---|
| 67 | XPStyle on
|
---|
| 68 | ShowInstDetails hide
|
---|
| 69 | VIProductVersion "${VERSION}.0.0"
|
---|
| 70 | VIAddVersionKey /LANG=${LANG_ENGLISH} ProductName "OGAgent"
|
---|
| 71 | VIAddVersionKey /LANG=${LANG_ENGLISH} ProductVersion "${VERSION}"
|
---|
| 72 | VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyName "${COMPANY}"
|
---|
| 73 | VIAddVersionKey /LANG=${LANG_ENGLISH} CompanyWebsite "${URL}"
|
---|
| 74 | VIAddVersionKey /LANG=${LANG_ENGLISH} FileVersion "${VERSION}"
|
---|
[9bfb4ee] | 75 | VIAddVersionKey /LANG=${LANG_ENGLISH} FileDescription "OpenGnsys Agent installer"
|
---|
[11f7a07] | 76 | VIAddVersionKey /LANG=${LANG_ENGLISH} LegalCopyright "(c) 2015 Virtual Cable S.L.U."
|
---|
| 77 | InstallDirRegKey HKLM "${REGKEY}" Path
|
---|
| 78 | ShowUninstDetails show
|
---|
| 79 |
|
---|
| 80 | # Installer sections
|
---|
| 81 | Section -Main SEC0000
|
---|
| 82 | SetShellVarContext all
|
---|
| 83 | SetOutPath $INSTDIR
|
---|
| 84 | SetOverwrite on
|
---|
| 85 | File /r bin\*.*
|
---|
| 86 | File vcredist_x86.exe
|
---|
[f2af820] | 87 | File src\VERSION
|
---|
[11f7a07] | 88 | WriteRegStr HKLM "${REGKEY}\Components" Main 1
|
---|
| 89 | SectionEnd
|
---|
| 90 |
|
---|
| 91 | Section -post SEC0001
|
---|
| 92 | SetShellVarContext current
|
---|
| 93 | WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
|
---|
| 94 | SetOutPath $INSTDIR
|
---|
| 95 | WriteUninstaller $INSTDIR\OGAgentUninstaller.exe
|
---|
| 96 | SetOutPath $SMPROGRAMS\$StartMenuGroup
|
---|
| 97 | CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk" $INSTDIR\OGAgentUninstaller.exe
|
---|
| 98 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
|
---|
| 99 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
|
---|
| 100 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
|
---|
| 101 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
|
---|
| 102 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\OGAgentUninstaller.exe
|
---|
| 103 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\OGAgentUninstaller.exe
|
---|
| 104 | WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool $INSTDIR\OGAgentUser.exe
|
---|
| 105 | WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
|
---|
| 106 | WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
|
---|
| 107 | ExecWait '"$INSTDIR\vcredist_x86.exe" /passive /norestart'
|
---|
| 108 | # Add the application to the firewall exception list - All Networks - All IP Version - Enabled
|
---|
[9bfb4ee] | 109 | # SimpleFC::AddApplication "OpenGnsys Agent Service" "$INSTDIR\OGAgentService.exe" 0 2 "" 1
|
---|
[11f7a07] | 110 | # SimpleFC::AdvAddRule [name] [description] [protocol] [direction]
|
---|
| 111 | # [status] [profile] [action] [application] [service_name] [icmp_types_and_codes]
|
---|
| 112 | # [group] [local_ports] [remote_ports] [local_address] [remote_address]
|
---|
| 113 | #
|
---|
[9bfb4ee] | 114 | SimpleFC::AdvAddRule "OpenGnsys Agent Firewall rules" "Firewall rules for OpenGnsys Agent interaction with broker." "6" "1" \
|
---|
[11f7a07] | 115 | "1" "7" "1" "$INSTDIR\OGAgentService.exe" "" "" \
|
---|
| 116 | "" "" "" "" ""
|
---|
| 117 | Pop $0 ; return error(1)/success(0)
|
---|
[2e072d2] | 118 | # Disable fast boot on Windows 10, if registry key exists.
|
---|
| 119 | ReadRegDWORD $0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled
|
---|
| 120 | IfErrors 0 +2
|
---|
| 121 | WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Power" HiberbootEnabled 0
|
---|
[11f7a07] | 122 | # Install service
|
---|
| 123 | nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe --startup auto install" # Add service after installation
|
---|
| 124 | # Update recovery options
|
---|
| 125 | nsExec::Exec /OEM "$INSTDIR\OGAServiceHelper.exe"
|
---|
| 126 | SectionEnd
|
---|
| 127 |
|
---|
| 128 | # Macro for selecting uninstaller sections
|
---|
| 129 | !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
|
---|
| 130 | Push $R0
|
---|
| 131 | ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
|
---|
| 132 | StrCmp $R0 1 0 next${UNSECTION_ID}
|
---|
| 133 | !insertmacro SelectSection "${UNSECTION_ID}"
|
---|
| 134 | GoTo done${UNSECTION_ID}
|
---|
| 135 | next${UNSECTION_ID}:
|
---|
| 136 | !insertmacro UnselectSection "${UNSECTION_ID}"
|
---|
| 137 | done${UNSECTION_ID}:
|
---|
| 138 | Pop $R0
|
---|
| 139 | !macroend
|
---|
| 140 |
|
---|
| 141 | # Uninstaller sections
|
---|
| 142 | Section /o -un.Main UNSEC0000
|
---|
[f2af820] | 143 | nsExec::Exec "taskkill /F /IM OGAgentUser.exe /T"
|
---|
[11f7a07] | 144 | nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe stop" # Stops the service prior uninstall
|
---|
| 145 | nsExec::Exec /OEM "$INSTDIR\OGAgentService.exe remove" # Removes the service prior uninstall
|
---|
[f2af820] | 146 | nsExec::Exec "taskkill /F /IM OGAgentService.exe /T"
|
---|
[11f7a07] | 147 | Delete /REBOOTOK "$INSTDIR\*.*"
|
---|
| 148 | DeleteRegValue HKLM "${REGKEY}\Components" Main
|
---|
| 149 | DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" OGAgentTool
|
---|
| 150 | SectionEnd
|
---|
| 151 |
|
---|
| 152 | Section -un.post UNSEC0001
|
---|
| 153 | # Remove application from the firewall exception list
|
---|
| 154 | # SimpleFC::RemoveApplication "$INSTDIR\OGAgentService.exe"
|
---|
[9bfb4ee] | 155 | SimpleFC::AdvRemoveRule "OpenGnsys Agent Firewall rules"
|
---|
[11f7a07] | 156 | Pop $0 ; return error(1)/success(0)
|
---|
| 157 |
|
---|
| 158 | SetShellVarContext current
|
---|
[9bfb4ee] | 159 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
[11f7a07] | 160 | DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
|
---|
| 161 | Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^UninstallLink).lnk"
|
---|
| 162 | Delete /REBOOTOK $INSTDIR\OGAgentUninstaller.exe
|
---|
| 163 | DeleteRegValue HKLM "${REGKEY}" Path
|
---|
| 164 | DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
|
---|
| 165 | DeleteRegKey /IfEmpty HKLM "${REGKEY}"
|
---|
| 166 | RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
|
---|
| 167 | SetShellVarContext all
|
---|
[f2af820] | 168 | RmDir /r /REBOOTOK $INSTDIR
|
---|
[11f7a07] | 169 | SectionEnd
|
---|
| 170 |
|
---|
| 171 | # Installer functions
|
---|
| 172 | Function .onInit
|
---|
| 173 | InitPluginsDir
|
---|
[9bfb4ee] | 174 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
[11f7a07] | 175 |
|
---|
| 176 | !insertmacro MUI_LANGDLL_DISPLAY
|
---|
| 177 | !insertmacro MULTIUSER_INIT
|
---|
| 178 | FunctionEnd
|
---|
| 179 |
|
---|
| 180 | # Uninstaller functions
|
---|
| 181 | Function un.onInit
|
---|
[9bfb4ee] | 182 | StrCpy $StartMenuGroup "OpenGnsys Agent"
|
---|
[11f7a07] | 183 | !insertmacro MUI_UNGETLANGUAGE
|
---|
| 184 | !insertmacro MULTIUSER_UNINIT
|
---|
| 185 | !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
|
---|
| 186 | FunctionEnd
|
---|
| 187 |
|
---|
| 188 | # Installer Language Strings
|
---|
| 189 | LangString ^UninstallLink ${LANG_ENGLISH} "Uninstall $(^Name)"
|
---|
| 190 | LangString ^UninstallLink ${LANG_SPANISH} "Desinstalar $(^Name)"
|
---|
| 191 | LangString ^UninstallLink ${LANG_FRENCH} "D�sinstaller $(^Name)"
|
---|
| 192 | LangString ^UninstallLink ${LANG_GERMAN} "deinstallieren $(^Name)"
|
---|