653af699fc95fa47f4522df685b4fc1a703c9602
[cdm-server.git] / src / main / installer / win32 / setup.nsi
1 # Auto-generated by EclipseNSIS Script Wizard
2 # 28.10.2010 13:58:54
3
4 Name "EDIT CDM-Server"
5
6 # General Symbol Definitions
7 !define REGKEY "SOFTWARE\$(^Name)"
8 !define VERSION 2.5
9 !define COMPANY "EDIT - European Distributed Institute of Taxonomy"
10 !define EDIT_PLATFORM "EDIT Platform for Cybertaxonomy"
11 !define URL http://wp5.e-taxonomy.eu/
12 !define URL-EDIT http://www.e-taxonomy.eu/
13
14 # Included files
15 !include Sections.nsh
16
17 # Files and Folders
18 !define OUT_FOLDER "..\..\..\..\dist"
19 !define JAR_FILE_NAME "cdm-server-${VERSION}.jar"
20 !define JAR_FILE "..\..\..\..\target\${JAR_FILE_NAME}"
21
22 # Reserved Files
23 ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
24
25 # Variables
26 Var StartMenuGroup
27
28 # Installer pages
29 Page license
30 Page directory
31 Page custom StartMenuGroupSelect "" ": Start Menu Folder"
32 Page instfiles
33
34 # Installer attributes
35 OutFile "${OUT_FOLDER}\EDIT CDM-Server-${VERSION}.exe"
36 InstallDir "$PROGRAMFILES\EDIT CDM-Server"
37 CRCCheck on
38 XPStyle on
39 Icon "${NSISDIR}\Contrib\Graphics\Icons\classic-install.ico"
40 ShowInstDetails show
41 AutoCloseWindow false
42 LicenseData ..\..\..\..\LICENSE.TXT
43 VIProductVersion 2.5.0.0
44 VIAddVersionKey ProductName "$(^Name)"
45 VIAddVersionKey ProductVersion "${VERSION}"
46 VIAddVersionKey CompanyName "${COMPANY}"
47 VIAddVersionKey CompanyWebsite "${URL}"
48 VIAddVersionKey FileVersion "${VERSION}"
49 VIAddVersionKey FileDescription ""
50 VIAddVersionKey LegalCopyright ""
51 InstallDirRegKey HKLM "${REGKEY}" Path
52 UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\classic-uninstall.ico"
53 ShowUninstDetails show
54
55 # Installer sections
56 Section -Main SEC0000
57 SetOutPath $INSTDIR
58 SetOverwrite on
59 File /r /x .svn /x *.log /x *.jar program-folder\*
60 SetOutPath "$INSTDIR\lib"
61 File ${JAR_FILE}
62 WriteRegStr HKLM "${REGKEY}\Components" Main 1
63 SectionEnd
64
65 Section -post SEC0001
66 WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
67 WriteRegStr HKLM "${REGKEY}" StartMenuGroup $StartMenuGroup
68 SetOutPath $INSTDIR
69 WriteUninstaller $INSTDIR\uninstall.exe
70 SetOutPath $SMPROGRAMS\$StartMenuGroup
71 CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
72 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
73 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
74 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
75 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
76 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
77 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
78 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
79 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
80
81 ExecWait '"$INSTDIR\CDMServer.exe" --install "$INSTDIR\etc\CDMServer.conf$\"'
82 ExecWait '"$INSTDIR\CDMServer.exe" --start "$INSTDIR\etc\CDMServer.conf$\"'
83 SectionEnd
84
85 Section -AdditionalIcons SEC0003
86 SetOutPath $INSTDIR
87 WriteIniStr "$INSTDIR\${EDIT_PLATFORM}.url" "InternetShortcut" "URL" "${URL}"
88 WriteIniStr "$INSTDIR\${COMPANY}.url" "InternetShortcut" "URL" "${URL-EDIT}"
89 CreateDirectory "$SMPROGRAMS\$(^Name)"
90 CreateShortCut "$SMPROGRAMS\$(^Name)\${EDIT_PLATFORM}.lnk" "$INSTDIR\${EDIT_PLATFORM}.url"
91 CreateShortCut "$SMPROGRAMS\$(^Name)\${COMPANY}.lnk" "$INSTDIR\${COMPANY}.url"
92 CreateShortCut "$SMPROGRAMS\$(^Name)\Uninstall $(^Name).lnk" "$INSTDIR\uninstall.exe"
93 CreateShortCut "$SMPROGRAMS\$(^Name)\Start $(^Name).lnk" "$INSTDIR\start-service.bat"
94 CreateShortCut "$SMPROGRAMS\$(^Name)\Stop $(^Name).lnk" "$INSTDIR\stop-service.bat"
95 SectionEnd
96
97 # Macro for selecting uninstaller sections
98 !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
99 Push $R0
100 ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
101 StrCmp $R0 1 0 next${UNSECTION_ID}
102 !insertmacro SelectSection "${UNSECTION_ID}"
103 GoTo done${UNSECTION_ID}
104 next${UNSECTION_ID}:
105 !insertmacro UnselectSection "${UNSECTION_ID}"
106 done${UNSECTION_ID}:
107 Pop $R0
108 !macroend
109
110 # Uninstaller sections
111 Section /o -un.Main UNSEC0000
112 ExecWait '"$INSTDIR\CDMServer.exe" --remove "$INSTDIR\etc\CDMServer.conf$\"'
113 RmDir /r /REBOOTOK $INSTDIR
114 DeleteRegValue HKLM "${REGKEY}\Components" Main
115 SectionEnd
116
117 Section -un.post UNSEC0001
118 DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
119 Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
120 Delete /REBOOTOK $INSTDIR\uninstall.exe
121 DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
122 DeleteRegValue HKLM "${REGKEY}" Path
123 DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
124 DeleteRegKey /IfEmpty HKLM "${REGKEY}"
125 RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
126 RmDir /REBOOTOK $INSTDIR
127 SectionEnd
128
129 # Installer functions
130 Function StartMenuGroupSelect
131 Push $R1
132 StartMenu::Select /autoadd /text "Select the Start Menu folder in which to create the program's shortcuts:" /lastused $StartMenuGroup "$(^Name)"
133 Pop $R1
134 StrCmp $R1 success success
135 StrCmp $R1 cancel done
136 MessageBox MB_OK $R1
137 Goto done
138 success:
139 Pop $StartMenuGroup
140 done:
141 Pop $R1
142 FunctionEnd
143
144 Function .onInstSuccess
145
146 FunctionEnd
147
148 Function .onInit
149 InitPluginsDir
150 FunctionEnd
151
152 # Uninstaller functions
153 Function un.onInit
154 ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
155 ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup
156 !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
157 FunctionEnd
158