|
#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;
|
Loading...