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