; ; $Id$ ; ; (c)2015-2016 The clazzes.org project. ; ; NSIS Installation Script for the osgi-runner service. ; ; Author: Wolfgang Glas ; ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "@PROJECT_NAME@" !define PRODUCT_VERSION "@PROJECT_VERSION@" !define PRODUCT_PUBLISHER "The Clazzes.org Project" !define PRODUCT_WEB_SITE "http://www.clazzes.org" !define PRODUCT_PATH_REGKEY "Software\osgi-runner" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\osgi-runner.exe" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" !define ARCHITECTURE "@ARCHITECTURE@" !define BINDIR "/usr/@ARCHTRIPLET@/bin" Unicode true ; Use LZMA compression, because nsis-2.46-1 as of ubuntu lucid fails to compress ; osgi-3.5.1.v20090827.jar, see https://bugs.launchpad.net/bugs/585442 SetCompressor LZMA SetCompressorDictSize 32 SetCompress Auto SetDatablockOptimize On ; MUI 1.67 compatible ------ !include "MUI.nsh" !include "TextFunc.nsh" !include "WordFunc.nsh" !include "Sections.nsh" !insertmacro LineFind !insertmacro WordReplace ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" ; Language Selection Dialog Settings !define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" !define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language" ; Welcome page !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}-setup-${ARCHITECTURE}.exe" InstallDir "$@PROGRAMFILES@\osgi-runner" ShowInstDetails show ShowUnInstDetails show var INSTMODE var LOGGING var JAVA_HOME var JAVA_VERSION Section "-OSGi Runner" ;SEC00 SetOutPath "$INSTDIR" File /oname=osgi-runner.exe "@ARCH_DIST_SUBDIR@prunsrv.exe" File /oname=osgi-runnerw.exe "prunmgr.exe" File "../InstallOsgiService.bat" File "../UninstallOsgiService.bat" File "../MigrateKeysProperties.bat" CreateShortCut "$INSTDIR\tail-osgi-log.lnk" powershell.exe `-command "& '.\ps1\tail-osgi-log.ps1'"` CreateShortCut "$INSTDIR\osgi-shell.lnk" powershell.exe `-command "& '.\ps1\osgi-shell.ps1'"` SetOutPath "$INSTDIR\ps1" File /r "@DIST_DIR@/win32/ps1/*.ps1" SetOutPath "$INSTDIR\lib" File /r "@DIST_DIR@/downloads/lib/*" SetOutPath "$INSTDIR\bundle1" File /r "@DIST_DIR@/downloads/bundle1/*" SetOutPath "$INSTDIR\bundle2" File /r "@DIST_DIR@/downloads/bundle2/pax-logging-api-*.jar" SetOutPath "$INSTDIR\bundle3" File /r "@DIST_DIR@/downloads/bundle3/*" SetOutPath "$INSTDIR\bundle4" File /r "@DIST_DIR@/downloads/bundle4/*" SetOutPath "$INSTDIR\bundle5" File /r "@DIST_DIR@/downloads/bundle5/*" ; ; Do not overwrite configuration files, which have not been deleted. ; Install changed config files as *.new and print a remark. ; SetOutPath "$INSTDIR\etc" !include "./install-config.nsi" SetOutPath "$INSTDIR\log" File "../README" SetOutPath "$INSTDIR\cache" File "../README" SetOutPath "$INSTDIR\var" File "../README" SetOutPath "$INSTDIR\deploy" File "../README" SetOutPath "$INSTDIR\drivers" File "../README-DRIVERS" SetOutPath "$INSTDIR\java" File "./Aes256Test.class" SetOutPath "$INSTDIR\java\java8" File "@DIST_DIR@/java/java8/local_policy.jar" SetOutPath "$INSTDIR\etc\sshd.d" File "../README-SSHD" WriteRegStr HKLM "${PRODUCT_PATH_REGKEY}" "instdir" "$INSTDIR" WriteRegStr HKLM "${PRODUCT_PATH_REGKEY}" "logging" "$LOGGING" ; Log4j SEC01 and log4j2 SEC02 removed ; Always Log4J2 as of OSGIRUN-46 SetOutPath "$INSTDIR\bundle2" File /r "@DIST_DIR@/downloads/bundle2-log4j2/pax-logging-log4j2-*.jar" File /r "@DIST_DIR@/downloads/bundle2-logstash/pax-logstash-plugin-*.jar" ; Do not overwrite configuration files, which have not been deleted. ; Install changed config files as *.new and print a remark. ; SetOutPath "$INSTDIR\etc" !include "./install-config-log4j2.nsi" ; always include pax all logging templates SetOutPath "$INSTDIR\etc\adm.d" File "/oname=org.ops4j.pax.logging.cfg.log4j2_filesonly.new" "/home/cl/sources/osgi_clazzes/trunk/osgi-runner-pkg/win32/target/etc/osgi-runner/adm.d/org.ops4j.pax.logging.log4j2-cfg" File "/oname=org.ops4j.pax.logging.cfg.log4j2_files+gelf.new" "/home/cl/sources/osgi_clazzes/trunk/osgi-runner-pkg/win32/target/etc/osgi-runner/adm.d/org.ops4j.pax.logging.log4j2-gelf-cfg" IfFileExists "$INSTDIR\etc\karaf.d" 0 install_service IfFileExists "$INSTDIR\etc\karaf.d\host.key" 0 +2 Rename "$INSTDIR\etc\karaf.d\host.key" "$INSTDIR\etc\sshd.d\host.key" IfFileExists "$INSTDIR\etc\karaf.d\keys.properties" 0 +2 ExecWait '"$INSTDIR\MigrateKeysProperties.bat" "$JAVA_HOME"' Rename "$INSTDIR\etc\karaf.d" "$INSTDIR\etc\karaf.d.save" install_service: ExecWait '"$INSTDIR\InstallOsgiService.bat" auto' SectionEnd Function .onInit SetRegView @REGVIEW@ !insertmacro MUI_LANGDLL_DISPLAY StrCpy $JAVA_VERSION "8" ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\Java Runtime Environment\1.8" "JavaHome" IfErrors 0 JRE17Found StrCpy $JAVA_VERSION "11" ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\JRE\11" "JavaHome" IfErrors 0 JRE17Found ; osgi-runner doesn't work in Java 17 yet ;StrCpy $JAVA_VERSION "17" ;ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\JRE\17" "JavaHome" ;IfErrors 0 JRE17Found StrCpy $JAVA_VERSION "8" ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\Java Development Kit\1.8" "JavaHome" IfErrors 0 JRE17Found StrCpy $JAVA_VERSION "11" ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\JDK\11" "JavaHome" IfErrors 0 JRE17Found ; osgi-runner doesn't work in Java 17 yet ;StrCpy $JAVA_VERSION "17" ;ReadRegStr $JAVA_HOME HKLM "SOFTWARE\JavaSoft\JDK\17" "JavaHome" ;IfErrors 0 JRE17Found MessageBox MB_OK "Couldn't find a Java Runtime or JDK 1.8, 11 installed. Setup will exit now." Quit JRE17Found: ReadRegStr $LOGGING HKLM "${PRODUCT_PATH_REGKEY}" "logging" ; osgi-runner already installed ? ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" IfErrors fromscratch 0 MessageBox MB_OKCANCEL "There is another version of osgi-runner currently installed. Run Uninstaller $0 now?" IDOK +2 IDCANCEL +1 Abort "Installation aborted by the user." ReadRegStr $INSTDIR HKLM "${PRODUCT_PATH_REGKEY}" "instdir" ExecWait '$0 _?=$INSTDIR' StrCpy $INSTMODE "update" goto goon2 fromscratch: StrCpy $INSTMODE "install" goon2: ; remove some registry keys which interfere badly, when osgi-runner and/or the JRE is updated. ; We do this here after running the uninstaller, so we even erase the regkeys when ; older installers were installed before SetRegView 32 DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Jvm" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Classpath" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Options" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Log" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Start" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Stop" SetRegView @REGVIEW@ FunctionEnd Section -AdditionalIcons SetOutPath $INSTDIR WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" SectionEnd Section -Post StrCmp $JAVA_VERSION "8" java8_jce jce_ok java8_jce: ExecWait '"$JAVA_HOME\bin\javaw.exe" -cp "$INSTDIR\java" Aes256Test' $0 StrCmp $0 "0" jce_ok MessageBox MB_ICONQUESTION|MB_YESNO "Java in $JAVA_HOME is not enabled for AES-256, install unlimited JCE policy now?" IDNO jce_ok CopyFiles "$INSTDIR\java\java8\local_policy.jar" "$JAVA_HOME\lib\security" jce_ok: WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\osgi-runner.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\osgi-runner.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SetAutoClose false SectionEnd Function un.onUninstSuccess ; HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit SetRegView @REGVIEW@ !insertmacro MUI_UNGETLANGUAGE MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd Section Uninstall ExecWait '"$INSTDIR\UninstallOsgiService.bat"' Delete "$INSTDIR\${PRODUCT_NAME}.url" Delete "$INSTDIR\uninst.exe" Delete "$INSTDIR\osgi-runner.exe" Delete "$INSTDIR\osgi-runnerw.exe" Delete "$INSTDIR\InstallOsgiService.bat" Delete "$INSTDIR\UninstallOsgiService.bat" Delete "$INSTDIR\MigrateKeysProperties.bat" Delete "$INSTDIR\tail-osgi-log.lnk" Delete "$INSTDIR\osgi-shell.lnk" Delete "$INSTDIR\ps1\tail-osgi-log.ps1" Delete "$INSTDIR\ps1\osgi-shell.ps1" RMDir "$INSTDIR\ps1" RMDir /r "$INSTDIR\lib" RMDir /r "$INSTDIR\bundle1" RMDir /r "$INSTDIR\bundle2" RMDir /r "$INSTDIR\bundle3" RMDir /r "$INSTDIR\bundle4" RMDir /r "$INSTDIR\bundle5" Delete "$INSTDIR\deploy\README" RMDir "$INSTDIR\deploy" Delete "$INSTDIR\drivers\README-DRIVERS" RMDir "$INSTDIR\drivers" ; This will mot likely fail, if host.key and/or authorized_keys is present in sshd.d Delete "$INSTDIR\etc\sshd.d\README-SSHD" RMDir "$INSTDIR\etc\sshd.d" RMDir /r "$INSTDIR\cache" RMDir /r "$INSTDIR\java" Delete "$INSTDIR\var\README" RMDir "$INSTDIR\var" Delete "$INSTDIR\log\README" Delete "$INSTDIR\log\osgi-runner.*.log" Delete "$INSTDIR\log\stdout.log" Delete "$INSTDIR\log\stderr.log" RMDir "$INSTDIR\log" Delete "$INSTDIR\etc\adm.d\*.new" Delete "$INSTDIR\etc\adm.d\*.template" Delete "$INSTDIR\etc\conf.d\*.new" ; ; Only delete files, which have not been changed as per MD5 checksum. ; !include "./remove-config.nsi" RMDir "$INSTDIR\etc\conf.d" RMDir "$INSTDIR\etc\adm.d" RMDir "$INSTDIR\etc\htpasswd.d" RMDir "$INSTDIR\etc" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" DeleteRegKey HKLM "${PRODUCT_PATH_REGKEY}" SetRegView 32 DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Jvm" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Classpath" DeleteRegValue HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Java" "Options" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Log" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Start" DeleteRegKey HKLM "Software\Apache Software Foundation\Procrun 2.0\osgi-runner\Parameters\Stop" SetRegView @REGVIEW@ SetAutoClose true SectionEnd