views:

146

answers:

1

Hello,

During installation proces user has ability to install number of some service instances (Service1- ServiceN). All th difference between this services - content of configuration files(actually there is only one executable in /Product_Root/run wich is called with different command-line params).Configuration files situated in ProductRoot/ServiceX/conf.

Folders structure looks like :

/Product_Root
----/bin
----/doc
----/Service1
---------/conf
----/Service2
---------/conf
...
----/ServiceN
---------/conf

In ProductRoot/ServiceX/conf situated, for example, service.properties file with next contents:

#...
ServiceRoot = <%ROOT_DIRECTORY%>
ListenPort = <%PORT%>
#...

Also in /Product_Root/bin shuld be present scripts for each service startup For example :

/Product_Root/bin/Service1.run.cmd
/Product_Root/bin/Service2.run.cmd
...
/Product_Root/bin/ServiceN.run.cmd
...

Scipt file structure is:

service.exe ../<%SERVICE_NAME%>/conf/service.properties

All values (like <%SERVICE_NAME%>,<%PORT%> etc.) are set by user during setup process for each Service. Amount of services is also set by user and may vary between 1 (by default) and 20-30.

In case of single service - there is no problem.

Files being copied, directories created using

[Files]
Source: {#FilesPath}\bin\*.*; DestDir: {app}\{#FileLocationPrefix}\bin; Flags: ignoreversion restartreplace
Source: {#АilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}\{code:GetServiceName}\conf; Flags: ignoreversion recursesubdirs createallsubdirs restartreplace; 

[Dirs]
Name: {app}\{#FileLocationPrefix}{code:GetServiceName}\conf

After in ssPostInstall step wildcards replace performed in copied files.

Question.

is it possible using Inno Setup + ISTool to do the same in case of number of services?

E.g. something like that :

[Files]
#for (i = 0; i < ServiceCount(); ++i) 
Source: {#АilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}\{code:GetServiceName| i}\conf; Flags: ignoreversion recursesubdirs createallsubdirs

where i — is actually configuration number. I.e. is it possible to use information received from user during installation process in [File], [Dirs] etc. sections for multiple copying of the same files in different directories? For copying single file in number of files with different names set by user during install process?

Or I just going in the wrong direction?

A: 

So, currently I've done this in such way. Comments are welcome. For creating and copying all files:

#define MaxFEInstances 20
...
#sub CreateConf
Source: {#FilesPath}\conf\*.*; DestDir: {app}\{#FileLocationPrefix}{code:GetServiceName|{#counter}}\conf; Flags: ignoreversion recursesubdirs createallsubdirs restartreplace; Check: InstanceSetupRequired({#counter}); Components: main
#endsub
#for {counter = 0; counter < MaxInstances; ++counter} CreateConf
enter code here
...
function InstanceSetupRequired(InstanceNum: Integer): Boolean;
begin
  Result := InstanceNum < Instances;
end;

For separate files it looks pretty same.

blackhearted