Kiln » Kiln Storage Service Read More
Clone URL:  
BackendInstaller.iss
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#define MyAppName "Kiln Storage Service" #define MyAppVerName "Kiln Storage Service 2.5" #define MyAppPublisher "Fog Creek Software" #define MyAppURL "http://www.fogcreek.com/kiln/" [Setup] AppId={{D8A180A5-0409-46FC-9B73-3776F60BFB31} AppName={#MyAppName} AppVerName={#MyAppVerName} AppPublisher={#MyAppPublisher} AppPublisherURL={#MyAppURL} AppSupportURL={#MyAppURL} AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} VersionInfoCopyright=Copyright 2009-2010 {#MyAppPublisher} VersionInfoCompany={#MyAppPublisher} PrivilegesRequired=admin WizardImageFile=installer.bmp AllowNoIcons=yes OutputBaseFilename=KilnStorageSetup MinVersion=0,5.02 Compression=lzma SolidCompression=yes LicenseFile=..\LICENSE [Languages] Name: english; MessagesFile: compiler:Default.isl [Messages] FinishedLabel=Setup has finished installing [name] on your computer. WelcomeLabel2=This will install [name/ver] on your computer. [Files] Source: RepoDirectoryMigrator\RepoDirectoryMigrator\bin\x86\Release\RepoDirectoryMigrator.exe; DestDir: {tmp}; Flags: ignoreversion Source: ctags.exe; DestDir: {app}; Flags: ignoreversion Source: ..\kiln\dist\library.zip; DestDir: {app}; Flags: ignoreversion Source: ..\kiln\dist\backend.exe; DestDir: {app}; Flags: ignoreversion Source: ..\kiln\redis-server.exe; DestDir: {app}; Flags: ignoreversion Source: ..\kiln\dist\source.zip; DestDir: {app}; Flags: ignoreversion Source: ..\kiln\dist\opengrok.jar; DestDir: {app}\opengrok; Flags: ignoreversion Source: ..\kiln\dist\lib\*; DestDir: {app}\opengrok\lib; Flags: recursesubdirs replacesameversion; Excludes: .hg*,*~ Source: ..\kiln\client.crt; DestDir: {app}; Flags: ignoreversion Source: ..\kiln\client.key; DestDir: {app}; Flags: ignoreversion [Icons] Name: {group}\{cm:UninstallProgram,{#MyAppName}}; Filename: {uninstallexe} [UninstallRun] Filename: {app}\backend.exe; Parameters: stop; StatusMsg: Stopping Kiln Storage Service; Flags: runhidden Filename: {app}\backend.exe; Parameters: remove; StatusMsg: Removing Kiln Storage Service; Flags: runhidden [Code] var RemoteConnectionPage: TInputOptionWizardPage; StorageLocationPage: TInputDirWizardPage; PortNumberPage: TInputQueryWizardPage; LocalOnly: Boolean; StorageLocation: String; Port: Cardinal; JavaVersion: String; StoppedOldService: Boolean; const REG_KEY = 'Software\Fog Creek Software\Kiln'; OG_KEY = 'Software\Fog Creek Software\Kiln\OpenGrok'; DAEMON_KEY = 'Software\Fog Creek Software\Kiln\Daemon'; JAR = 'Jar'; BACKEND_IP = 'KilnBackendIP'; BACKEND_PORT = 'KilnBackendPort'; REPOSITORY_ROOT = 'KilnRepositoryRoot'; DELIBERATELY_PUBLIC = 'KilnDeliberatelyPublic'; MINIREDIS_DB = 'MiniredisDB'; DATA_DIR = 'DataDir'; INDEX_THREADS = 'IndexThreads'; QUEUE_THREADS = 'QueueThreads'; NINDEX_THREADS = 1; NQUEUE_THREADS = 1; DAEMON_HOST = 'host'; DAEMON_PORT = 'port'; DAEMON_DB = 'db'; DAEMON_SSL_KEY = 'ssl_key'; DAEMON_SSL_CERT = 'ssl_cert'; JAVA_KEY = 'Software\JavaSoft\Java Runtime Environment'; JAVA_VERSION = 'CurrentVersion'; JAVA = 'Java'; CONFIG_UPDATE = 'ConfigUpdate'; JAVA_HOME = 'JavaHome'; CTAGS = 'CTags'; procedure InitializeWizard; var storageLoc, ip: String; defaultPort, deliberatelyPublic: Cardinal; allowAll: Boolean; idx: Integer; nextPageParent: Integer; param: String; begin StoppedOldService := False; LocalOnly := False; for idx := 0 to ParamCount do begin param := ParamStr(idx); if param = '/localonly' then LocalOnly := True; if Copy(param, 0, 9) = '/storage=' then StorageLocation := Copy(param, 10, Length(param)); if Copy(param, 0, 6) = '/port=' then Port := StrToInt(Copy(param, 7, Length(param))); end; nextPageParent := wpWelcome; if (CompareStr(StorageLocation, '') = 0) then begin StorageLocationPage := CreateInputDirPage(nextPageParent, 'Select Mercurial Repository Storage Location', 'Where should Mercurial repositories be stored?', 'Mercurial repositories will be stored in the following folder.'#13#10#13#10 + 'To continue, click next. If you would like to select a different folder, click Browse.', False, 'New Folder'); StorageLocationPage.Add(''); if not RegQueryStringValue(HKEY_LOCAL_MACHINE, REG_KEY, REPOSITORY_ROOT, storageLoc) then storageLoc:= 'C:\KilnRepositories'; StorageLocationPage.Values[0] := storageLoc; nextPageParent := StorageLocationPage.ID; end; if not LocalOnly then begin RemoteConnectionPage := CreateInputOptionPage(nextPageParent, 'Configure Remote Connections', 'Allow remote connections to this backend?', 'By default, this storage node will only service requests from the Kiln website running on this machine. Unless ' + 'you have installed the Kiln website on another machine, leave this default. If, on the other hand, you ' + 'installed the Kiln website on a different machine, you will have to allow remote connections to this storage ' + 'node.'#13#10#13#10 + 'To continue, click Next.', True, False); RemoteConnectionPage.Add('Allow only the local copy of Kiln website to use this storage node (recommended)'); RemoteConnectionPage.Add('Allow remotely installed copies of Kiln on other machines to use this storage node'); if RegQueryStringValue(HKEY_LOCAL_MACHINE, REG_KEY, BACKEND_IP, ip) then begin if not RegQueryDWordValue(HKEY_LOCAL_MACHINE, REG_KEY, DELIBERATELY_PUBLIC, deliberatelyPublic) then deliberatelyPublic := 0; if (ip = '0.0.0.0') and (deliberatelyPublic = 1) then allowAll := True else allowAll := False; end; RemoteConnectionPage.Values[0] := not allowAll; RemoteConnectionPage.Values[1] := allowAll; nextPageParent := RemoteConnectionPage.ID; end; if Port = 0 then begin PortNumberPage := CreateInputQueryPage(nextPageParent, 'Configure Connection Port', 'Which port should this Kiln Storage Node run on?', 'Please select which port this Storage Node should run on. On most systems, you will not need to change this value.'#13#10#13#10 + 'To continue, click Next.') PortNumberPage.Add('Port:', False); if not RegQueryDWordValue(HKEY_LOCAL_MACHINE, REG_KEY, BACKEND_PORT, defaultPort) then defaultPort := 56783; PortNumberPage.Values[0] := IntToStr(defaultPort); end; end; procedure FinishInstall; var ip: String; ogStorageLocation: String; MiniredisDBLocation: String; ResultCode: Integer; deliberatelyPublic: Cardinal; JavaLoc: String; ret: Boolean; begin if (CompareStr(StorageLocation, '') = 0) then StorageLocation := StorageLocationPage.Values[0]; if Port = 0 then Port := StrToInt(PortNumberPage.Values[0]); if LocalOnly or RemoteConnectionPage.Values[0] then begin ip := '127.0.0.1'; deliberatelyPublic := 0; end else begin ip := '0.0.0.0'; deliberatelyPublic := 1; end; ogStorageLocation := StorageLocation + '\opengrokdata'; MiniredisDBLocation := StorageLocation + '\miniredis.db'; if not DirExists(StorageLocation) then CreateDir(StorageLocation); if not DirExists(ogStorageLocation) then CreateDir(ogStorageLocation); if IsWin64 then ret := RegQueryStringValue(HKLM64, JAVA_KEY + '\' + JavaVersion, JAVA_HOME, JavaLoc) else ret := RegQueryStringValue(HKEY_LOCAL_MACHINE, JAVA_KEY + '\' + JavaVersion, JAVA_HOME, JavaLoc); JavaLoc := JavaLoc + '\bin\java.exe' RegWriteStringValue(HKEY_LOCAL_MACHINE, REG_KEY, REPOSITORY_ROOT, StorageLocation); RegWriteDWordValue(HKEY_LOCAL_MACHINE, REG_KEY, BACKEND_PORT, Port); RegWriteStringValue(HKEY_LOCAL_MACHINE, REG_KEY, BACKEND_IP, ip); RegWriteDWordValue(HKEY_LOCAL_MACHINE, REG_KEY, DELIBERATELY_PUBLIC, deliberatelyPublic); RegWriteStringValue(HKEY_LOCAL_MACHINE, REG_KEY, MINIREDIS_DB, MiniredisDBLocation); RegWriteStringValue(HKEY_LOCAL_MACHINE, OG_KEY, JAR, ExpandConstant('{app}\opengrok\opengrok.jar')); RegWriteStringValue(HKEY_LOCAL_MACHINE, OG_KEY, DATA_DIR, ogStorageLocation); RegWriteStringValue(HKEY_LOCAL_MACHINE, OG_KEY, CONFIG_UPDATE, 'localhost:2424'); RegWriteStringValue(HKEY_LOCAL_MACHINE, OG_KEY, JAVA, JavaLoc); RegWriteStringValue(HKEY_LOCAL_MACHINE, OG_KEY, CTAGS, ExpandConstant('{app}\ctags.exe')); RegWriteStringValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_HOST, 'localhost'); RegWriteDWordValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_PORT, Port + 1); RegWriteDWordValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_DB, 0); RegWriteDWordValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, INDEX_THREADS, NINDEX_THREADS); RegWriteDWordValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, QUEUE_THREADS, NQUEUE_THREADS); RegWriteStringValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_SSL_KEY, ExpandConstant('{app}\client.key')); RegWriteStringValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_SSL_CERT, ExpandConstant('{app}\client.crt')); if Exec(ExpandConstant('{tmp}\RepoDirectoryMigrator.exe'), '', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin if ResultCode <> 0 then RaiseException('Failed to migrate repositories to new directory structure!'); end; if Exec(ExpandConstant('{app}\backend.exe'), '--startup auto install', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin if ResultCode <> 0 then RaiseException('Failed to install service!'); end; if Exec(ExpandConstant('{app}\backend.exe'), 'start', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then begin if ResultCode <> 0 then RaiseException('Failed to start service!'); end; end; procedure DeinitializeSetup(); var BackendPath: String; ResultCode: Integer; begin if StoppedOldService then begin BackendPath := ExpandConstant('{app}\backend.exe'); Exec(BackendPath, 'start', '', SW_HIDE, ewNoWait, ResultCode); end; end; procedure HaltBackend; var BackendPath: String; ResultCode: Integer; begin BackendPath := ExpandConstant('{app}\backend.exe'); if FileExists(BackendPath) then begin StoppedOldService := True; Exec(BackendPath, 'stop', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); end; Sleep(3000) end; procedure CurStepChanged(CurStep: TSetupStep); begin if CurStep = ssInstall then HaltBackend else if CurStep = ssPostInstall then FinishInstall; end; procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); begin if (CurUninstallStep = usUninstall) then begin RegDeleteValue(HKEY_LOCAL_MACHINE, REG_KEY, REPOSITORY_ROOT); RegDeleteValue(HKEY_LOCAL_MACHINE, REG_KEY, BACKEND_PORT); RegDeleteValue(HKEY_LOCAL_MACHINE, REG_KEY, BACKEND_IP); RegDeleteValue(HKEY_LOCAL_MACHINE, REG_KEY, DELIBERATELY_PUBLIC); RegDeleteValue(HKEY_LOCAL_MACHINE, OG_KEY, JAR); RegDeleteValue(HKEY_LOCAL_MACHINE, OG_KEY, DATA_DIR); RegDeleteValue(HKEY_LOCAL_MACHINE, OG_KEY, CONFIG_UPDATE); RegDeleteValue(HKEY_LOCAL_MACHINE, OG_KEY, JAVA); RegDeleteValue(HKEY_LOCAL_MACHINE, OG_KEY, CTAGS); RegDeleteValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_HOST); RegDeleteValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_PORT); RegDeleteValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_DB); RegDeleteValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, INDEX_THREADS); RegDeleteValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, QUEUE_THREADS); RegDeleteValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_SSL_KEY); RegDeleteValue(HKEY_LOCAL_MACHINE, DAEMON_KEY, DAEMON_SSL_CERT); end; end; function NextButtonClick(CurPageID: Integer) : Boolean; var version: String; ret: Boolean; begin if CurPageID = wpWelcome then begin if IsWin64 then ret := RegQueryStringValue(HKLM64, JAVA_KEY, JAVA_VERSION, version) else ret := RegQueryStringValue(HKEY_LOCAL_MACHINE, JAVA_KEY, JAVA_VERSION, version); if ret then JavaVersion := version else begin MsgBox('The Kiln Storage Service requires the Java Runtime Environment (JRE) be installed. Please install the JRE for your platform from the Oracle website.', mbInformation, MB_OK); Abort(); end; end; Result := True end;