uses System.Info;

var root := ApplicationInfo.CurrentDirectory.Before('\utils\') + '\';

function ReplaceMacros(s : String) : String;
begin
   Result := s.Replace('%TEMP%', root + 'temp')
              .Replace('%DATA%', root + 'data');
end;

var ini := ReplaceMacros(#'
   [Temp]
   Path=%TEMP%
   [Updates]
   CheckUpdates=N
   [Error.log]
   Path=%TEMP%
   ');

FileWrite(root + 'bin\Qubes.ini', ini);
FileWrite(root + 'bin\QubesExpress.ini', ini);

FileWrite(root + 'bin\server.cfg', ReplaceMacros(#'
   LogFilePath=%TEMP%
   '));

FileWrite(root + 'bin\SDBaliases.ini', ReplaceMacros(#'
   [Qubes]
   MIDDLEWARE=FDB
   USER_NAME=sysdba
   PASSWORD=shaka
   Server_name=localhost:%DATA%\qubes.fdb
   [QubesArchive]
   MIDDLEWARE=FDB
   USER_NAME=sysdba
   PASSWORD=shaka
   Server_name=localhost:%DATA%\qubesarchive.fdb
   '));


