-
Notifications
You must be signed in to change notification settings - Fork 10
/
elasticsearch.iss
218 lines (193 loc) · 8.58 KB
/
elasticsearch.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
; elasticsearch for Windows Setup Script created by Rui Lopes (ruilopes.com).
;
; TODO do not override existing configuration files.
; TODO after uninstall, setup-helper.dll is left behind... figure out why its
; not being automatically deleted.
; TODO sign the setup?
; NB: Unizeto Certum has free certificates to open-source authors.
; See http://www.certum.eu/certum/cert,offer_software_publisher.xml
; See https://developer.mozilla.org/en/Signing_a_XPI
#define ServiceAccountName "elasticsearch"
#define ServiceName "elasticsearch"
#define JreVersion "8u181"
#define ESPath "vendor\elasticsearch-" + AppVersion
#ifdef _WIN64
#define Bits "64"
#define ArchitecturesInstallIn64BitMode "x64"
#define ArchitecturesAllowed "x64"
#else
#define Bits "32"
#define ArchitecturesInstallIn64BitMode
#define ArchitecturesAllowed "x86 x64"
#endif
[Setup]
ArchitecturesInstallIn64BitMode={#ArchitecturesInstallIn64BitMode}
ArchitecturesAllowed={#ArchitecturesAllowed}
AppID={{BBFE3D83-0850-4E17-8BCC-860945E4F485}
AppName=Elasticsearch
AppVersion={#AppVersion}
VersionInfoVersion={#VersionInfoVersion}
AppPublisher=rgl
AppPublisherURL=https://github.com/rgl/elasticsearch-setup
AppSupportURL=https://github.com/rgl/elasticsearch-setup
AppUpdatesURL=https://github.com/rgl/elasticsearch-setup
DefaultDirName={pf}\Elasticsearch
DefaultGroupName=Elasticsearch
OutputDir=.
OutputBaseFilename=elasticsearch-{#AppVersion}-jre-{#JreVersion}-setup-{#Bits}-bit
SetupIconFile=elasticsearch.ico
Compression=lzma2/max
SolidCompression=yes
WizardImageFile=wizard.bmp
WizardImageStretch=no
WizardSmallImageFile=wizard-small.bmp
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Dirs]
Name: "{app}\bin"
Name: "{app}\config"
Name: "{app}\config\scripts"
Name: "{app}\data"
Name: "{app}\logs"
Name: "{app}\plugins"
[Files]
Source: "setup-helper.dll"; DestDir: "{app}"
Source: "vendor\SetACL-2.2.0\SetACL.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall ignoreversion
Source: "{#ESPath}\bin\elasticsearchw-{#Bits}.exe"; DestDir: "{app}\bin"; DestName: "elasticsearchw.exe"
Source: "{#ESPath}\bin\elasticsearch-env.bat"; DestDir: "{app}\bin"
Source: "{#ESPath}\bin\elasticsearch-keystore.bat"; DestDir: "{app}\bin"
Source: "{#ESPath}\bin\elasticsearch-plugin.bat"; DestDir: "{app}\bin"
Source: "{#ESPath}\bin\elasticsearch-translog.bat"; DestDir: "{app}\bin"
Source: "{#ESPath}\lib\elasticsearch-cmd.cmd"; DestDir: "{app}\lib"
Source: "{#ESPath}\lib\elasticsearchw-update-{#Bits}.cmd"; DestDir: "{app}\lib"; DestName: "elasticsearchw-update.cmd"
Source: "{#ESPath}\lib\*.jar"; DestDir: "{app}\lib"
Source: "{#ESPath}\modules\*"; DestDir: "{app}\modules"; Flags: recursesubdirs createallsubdirs
Source: "{#ESPath}\config\elasticsearch.yml"; DestDir: "{app}\config"
Source: "{#ESPath}\config\log4j2.properties"; DestDir: "{app}\config"
Source: "{#ESPath}\README.textile"; DestDir: "{app}"; DestName: "README.txt"; Flags: isreadme
Source: "{#ESPath}\NOTICE.txt"; DestDir: "{app}"
Source: "{#ESPath}\LICENSE.txt"; DestDir: "{app}"
Source: "elasticsearchw-uninstall.cmd"; DestDir: "{app}\lib"
Source: "Elasticsearch Home.url"; DestDir: "{app}"
Source: "Elasticsearch Setup Home.url"; DestDir: "{app}"
Source: "Elasticsearch Guide.url"; DestDir: "{app}"
Source: "vendor\jre-{#Bits}\jre\*"; DestDir: "{app}\jre"; Flags: recursesubdirs createallsubdirs
[Icons]
Name: "{group}\Elasticsearch Home"; Filename: "{app}\Elasticsearch Home.url"
Name: "{group}\Elasticsearch Setup Home"; Filename: "{app}\Elasticsearch Setup Home.url"
Name: "{group}\Elasticsearch Guide"; Filename: "{app}\Elasticsearch Guide.url"
Name: "{group}\Elasticsearch Read Me"; Filename: "{app}\README.txt"
Name: "{group}\Elasticsearch License"; Filename: "{app}\LICENSE.txt"
Name: "{group}\Uninstall Elasticsearch"; Filename: "{uninstallexe}"
[Run]
Filename: "{tmp}\SetACL.exe"; Parameters: "-on config -ot file -actn setprot -op ""dacl:p_nc;sacl:p_nc"" -actn ace -ace ""n:Administrators;p:full"" -ace ""n:{#ServiceAccountName};p:read"""; WorkingDir: "{app}"; Flags: runhidden;
Filename: "{tmp}\SetACL.exe"; Parameters: "-on data -ot file -actn setprot -op ""dacl:p_nc;sacl:p_nc"" -actn ace -ace ""n:Administrators;p:full"" -ace ""n:{#ServiceAccountName};p:full"""; WorkingDir: "{app}"; Flags: runhidden;
Filename: "{tmp}\SetACL.exe"; Parameters: "-on logs -ot file -actn setprot -op ""dacl:p_nc;sacl:p_nc"" -actn ace -ace ""n:Administrators;p:full"" -ace ""n:{#ServiceAccountName};p:full"""; WorkingDir: "{app}"; Flags: runhidden;
Filename: "{app}\bin\elasticsearch-keystore.bat"; Parameters: "create"; WorkingDir: "{app}"; Flags: runhidden shellexec waituntilterminated;
Filename: "{tmp}\SetACL.exe"; Parameters: "-on config/elasticsearch.keystore -ot file -actn setprot -op ""dacl:p_nc;sacl:p_nc"" -actn ace -ace ""n:Administrators;p:full"" -ace ""n:{#ServiceAccountName};p:full"""; WorkingDir: "{app}"; Flags: runhidden;
Filename: "{app}\lib\elasticsearchw-update.cmd"; WorkingDir: "{app}"; Flags: runhidden shellexec waituntilterminated;
[UninstallRun]
Filename: "{app}\lib\elasticsearchw-uninstall.cmd"; WorkingDir: "{app}"; Flags: runhidden shellexec waituntilterminated;
[Code]
#include "service.pas"
#include "service-account.pas"
#include "java.pas"
#include "shortcut.pas"
const
SERVICE_ACCOUNT_NAME = '{#ServiceAccountName}';
SERVICE_ACCOUNT_DESCRIPTION = '{#ServiceName} Service';
SERVICE_NAME = '{#ServiceName}';
SERVICE_DISPLAY_NAME = '{#ServiceName}';
SERVICE_DESCRIPTION = 'Distributed Search Engine';
const
LM20_PWLEN = 14;
function GeneratePassword: string;
var
N: integer;
begin
for N := 1 to LM20_PWLEN do
begin
Result := Result + Chr(33 + Random(255 - 33));
end;
end;
function InitializeSetup(): boolean;
begin
//NB we now bundle JRE; so no need to check for this.
//Result := RequireJava('1.6');
//if not Result then
// Exit;
if IsServiceRunning(SERVICE_NAME) then
begin
MsgBox('Please stop the ' + SERVICE_NAME + ' service before running this install', mbError, MB_OK);
Result := false;
end
else
Result := true
end;
function InitializeUninstall(): boolean;
begin
if IsServiceRunning(SERVICE_NAME) then
begin
MsgBox('Please stop the ' + SERVICE_NAME + ' service before running this uninstall', mbError, MB_OK);
Result := false;
end
else
Result := true;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ServicePath: string;
Password: string;
Status: integer;
CmdPath: string;
IconPath: string;
WorkingDirectoryPath: string;
begin
case CurStep of
ssInstall:
begin
if ServiceAccountExists(SERVICE_ACCOUNT_NAME) <> 0 then
begin
Password := GeneratePassword;
Status := CreateServiceAccount(SERVICE_ACCOUNT_NAME, Password, SERVICE_ACCOUNT_DESCRIPTION);
if Status <> 0 then
begin
MsgBox('Failed to create service account for ' + SERVICE_ACCOUNT_NAME + ' (#' + IntToStr(Status) + ')' #13#13 'You need to create it manually.', mbError, MB_OK);
end;
end;
if IsServiceInstalled(SERVICE_NAME) then
Exit;
ServicePath := ExpandConstant('{app}\bin\elasticsearchw.exe //RS//' + SERVICE_NAME);
if not InstallService(ServicePath, SERVICE_NAME, SERVICE_DISPLAY_NAME, SERVICE_DESCRIPTION, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ACCOUNT_NAME, Password) then
begin
MsgBox('Failed to install the ' + SERVICE_NAME + ' service.' #13#13 'You need to install it manually.', mbError, MB_OK)
end
end;
ssPostInstall:
begin
CmdPath := ExpandConstant('{app}\lib\elasticsearch-cmd.cmd');
IconPath := ExpandConstant('{uninstallexe}');
WorkingDirectoryPath := ExpandConstant('{app}');
CreateShortcut(ExpandConstant('{app}\bin\Elasticsearch Command Prompt.lnk'), CmdPath, IconPath, WorkingDirectoryPath, True);
CreateShortcut(ExpandConstant('{group}\Elasticsearch Command Prompt.lnk'), CmdPath, IconPath, WorkingDirectoryPath, True);
end
end
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
Status: integer;
begin
case CurUninstallStep of
usPostUninstall:
begin
DeleteFile(ExpandConstant('{app}\bin\Elasticsearch Command Prompt.lnk'));
DeleteFile(ExpandConstant('{group}\Elasticsearch Command Prompt.lnk'));
// NB the service should already be uinstalled (by elasticsearchw-uninstall.cmd)
Status := DestroyServiceAccount(SERVICE_ACCOUNT_NAME);
if Status <> 0 then
begin
MsgBox('Failed to delete the service account for ' + SERVICE_ACCOUNT_NAME + ' (#' + IntToStr(Status) + ')' #13#13 'You need to delete it manually.', mbError, MB_OK);
end;
end
end
end;