-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathelog.nsi
executable file
·260 lines (203 loc) · 7.48 KB
/
elog.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
; elog.nsi
;
; This script will install the elog system
;
; The name of the installer
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
;--------------------------------
;General
Name "ELOG"
; The file to write
OutFile "elog${VERSION}.exe"
; Overwrite setting
SetOverwrite on
; The default installation directory
InstallDir $PROGRAMFILES\ELOG
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM SOFTWARE\ELOG "Install_Dir"
; The text to prompt the user to enter a directory
ComponentText "This will install the ELOG electronic logbook server on your computer. Select which optional things you want installed."
; The text to prompt the user to enter a directory
DirText "Choose a directory to install in to:"
;--------------------------------
;Pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "COPYING"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
!define MUI_ABORTWARNING
;----------------------------------------------
; Main system
Section "ELOG system (required)" SecSystem
; root directory
SetOutPath $INSTDIR
File COPYING
File README
; stop service to replace elogd.exe
ExecWait 'net stop "ELOG server"'
ExecWait 'net stop elogd'
Sleep 2000
File nt\release\elogd.exe
File nt\release\elog.exe
File nt\release\elconv.exe
File \windows\system32\libeay32.dll
File \windows\system32\ssleay32.dll
File nt\msvcr90.dll
File nt\msvcr100.dll
File nt\msvcr110.dll
; doc directory
SetOutPath $INSTDIR\doc
File doc\*.*
; script directory
SetOutPath $INSTDIR\scripts
File /r scripts\*.*
; resources directory
SetOutPath $INSTDIR\resources
File resources\eloghelp_english.html
; ssl directory
SetOutPath $INSTDIR\ssl
File ssl\*.*
; src directory
SetOutPath $INSTDIR\src
File src\*.c
File \mxml\mxml.c
File \mxml\mxml.h
File \mxml\strlcpy.c
File \mxml\strlcpy.h
; config file
SetOutPath $INSTDIR
IfFileExists $INSTDIR\elogd.cfg 0 cfgNotExist
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to overwrite your existing elogd.cfg?" IDNO cfgNotOverwrite
cfgNotExist:
File elogd.cfg ; overwrite file
cfgNotOverwrite:
; themes
SetOutPath $INSTDIR\themes\default
File themes\default\*.css
File themes\default\*.png
File themes\default\*.ico
File themes\default\*.png
SetOutPath $INSTDIR\themes\default\icons
File themes\default\icons\*.*
; demo logbook
IfFileExists $INSTDIR\logbooks\demo\2001\011108a.log 0 logbNotExist
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to overwrite your existing demo logbook?" IDNO logbNotOverwrite
logbNotExist:
SetOutPath $INSTDIR\logbooks\demo\2001
File logbooks\demo\2001\*
logbNotOverwrite:
SetOutPath $INSTDIR
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\ELOG "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ELOG" "DisplayName" "ELOG electronic logbook (remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ELOG" "UninstallString" '"$INSTDIR\uninst_elog.exe"'
WriteUninstaller "uninst_elog.exe"
SectionEnd
; optional section
Section "Multi-language support" SecLang
SetOutPath $INSTDIR\resources
File resources\*.*
SectionEnd
; optional section
Section "Start Menu Shortcuts" SecStart
SetOutPath $INSTDIR
CreateDirectory "$SMPROGRAMS\ELOG"
CreateDirectory "$SMPROGRAMS\ELOG\ELOG Server"
CreateShortCut "$SMPROGRAMS\ELOG\ELOG Server\Start ELOG server manually.lnk" "$INSTDIR\elogd.exe" "" "$INSTDIR\themes\default\favicon.ico"
CreateShortCut "$SMPROGRAMS\ELOG\ELOG Server\Register ELOG server service.lnk" "$INSTDIR\elogd.exe" "-install" "$INSTDIR\themes\default\favicon.ico"
CreateShortCut "$SMPROGRAMS\ELOG\ELOG Server\Unregister ELOG server service.lnk" "$INSTDIR\elogd.exe" "-remove" "$INSTDIR\themes\default\favicon.ico"
Delete "$SMPROGRAMS\ELOG\Demo Logbook (requires running server).lnk"
WriteINIStr "$SMPROGRAMS\ELOG\Demo Logbook (requires running server).url" \
"InternetShortcut" "URL" "http://localhost:8080/demo/"
CreateShortCut "$SMPROGRAMS\ELOG\ELOG Documentation.lnk" "$INSTDIR\doc\index.html"
CreateShortCut "$SMPROGRAMS\ELOG\Uninstall ELOG.lnk" "$INSTDIR\uninst_elog.exe" "" "$INSTDIR\uninst_elog.exe" 0
SectionEnd
; optional section
Section "Register ELOG Server Service" SecService
; WriteRegExpandStr HKLM SYSTEM\CurrentControlSet\Services\elogd ImagePath '"$INSTDIR\elogd.exe" -D -c "$INSTDIR\elogd.cfg"'
ExecWait "$INSTDIR\elogd.exe -install"
SectionEnd
; display readme file
Function .onInstSuccess
MessageBox MB_YESNO|MB_ICONQUESTION \
"Setup has completed. View readme file now?" \
IDNO NoReadme
ExecShell open '$INSTDIR\doc\index.html'
NoReadme:
FunctionEnd
; uninstall stuff
UninstallText "This will uninstall ELOG."
; special uninstall section.
Section "Uninstall"
; remove service
ExecWait "$INSTDIR\elogd.exe -remove"
; remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\ELOG"
DeleteRegKey HKLM SOFTWARE\ELOG
; remove files
Delete $INSTDIR\COPYING
Delete $INSTDIR\README
Delete $INSTDIR\elog.exe
Delete $INSTDIR\elogd.exe
Delete $INSTDIR\elconv.exe
Delete $INSTDIR\elogd.cfg
Delete $INSTDIR\eloghelp_*.html
Delete $INSTDIR\eloglang.*
Delete $INSTDIR\doc\*
RMDir $INSTDIR\doc
Delete $INSTDIR\scripts\*
RMDir $INSTDIR\scripts
Delete $INSTDIR\resources\*
RMDir $INSTDIR\resources
Delete $INSTDIR\src\*
RMDir $INSTDIR\src
Delete $INSTDIR\themes\default\icons\*.*
RMDir $INSTDIR\themes\default\icons
Delete $INSTDIR\themes\default\*.*
RMDir $INSTDIR\themes\default
RMDir $INSTDIR\themes
Delete $INSTDIR\logbooks\demo\*.*
RMDir $INSTDIR\logbooks\demo
RMDir $INSTDIR\logbooks
; MUST REMOVE UNINSTALLER, too
Delete $INSTDIR\uninst_elog.exe
; remove shortcuts, if any.
Delete "$SMPROGRAMS\ELOG\ELOG Server\*.*"
RMDir "$SMPROGRAMS\ELOG\ELOG Server"
Delete "$SMPROGRAMS\ELOG\*.*"
RMDir "$SMPROGRAMS\ELOG"
; remove directories used.
RMDir "$INSTDIR"
; if $INSTDIR was removed, skip these next ones
IfFileExists $INSTDIR 0 Removed
MessageBox MB_YESNO|MB_ICONQUESTION \
"Remove all files in your ELOG directory? (If you have anything\
you created that you want to keep, click No)" IDNO Removed
Delete $INSTDIR\*.* ; this would be skipped if the user hits no
RMDir /r $INSTDIR
IfFileExists $INSTDIR 0 Removed
MessageBox MB_OK|MB_ICONEXCLAMATION \
"Note: $INSTDIR could not be removed."
Removed:
SectionEnd
;--------------------------------
;Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecSystem} "Installs ELOG system, documentation, source code and an example logbook"
!insertmacro MUI_DESCRIPTION_TEXT ${SecLang} "Installs support for different languages which can be switched during runtime"
!insertmacro MUI_DESCRIPTION_TEXT ${SecStart} "Installs start menu shortcuts for ELOG"
!insertmacro MUI_DESCRIPTION_TEXT ${SecService} "Installs ELOG server as a Windows Service, so that it gets started automatically when Windows boots"
!insertmacro MUI_FUNCTION_DESCRIPTION_END
; eof