-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackerInstaller.iss
More file actions
106 lines (91 loc) · 3.12 KB
/
BackerInstaller.iss
File metadata and controls
106 lines (91 loc) · 3.12 KB
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
; Backer Installer Script
[Setup]
AppName=Backer
AppVersion=1.0
DefaultDirName={commonpf}\Backer
DefaultGroupName=Backer
OutputDir=output
OutputBaseFilename=BackerInstaller
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin
[Files]
; Service binary (publish output from BackerAgent)
Source: "BackerAgent\bin\Release\net9.0\win-x64\publish\*"; \
DestDir: "{app}\service"; \
Flags: ignoreversion recursesubdirs
; Deploy a default appsettings.json into ProgramData\Backer
Source: "BackerAgent\bin\Release\net9.0\win-x64\publish\appsettings.json"; \
DestDir: "{commonappdata}\Backer"; \
Flags: ignoreversion
; Control app binary (publish output from YourBacker - cross-platform Avalonia app)
Source: "YourBacker\bin\Release\net9.0\win-x64\publish\*"; \
DestDir: "{app}\control"; \
Flags: ignoreversion recursesubdirs
; Rclone tool
Source: "contrib\rclone.exe"; DestDir: "{app}\contrib"; Flags: ignoreversion
[Dirs]
Name: "{app}\service"
Name: "{app}\control"
Name: "{app}\contrib"
[Icons]
Name: "{group}\YourBacker"; Filename: "{app}\control\YourBacker.exe"
Name: "{group}\Uninstall Backer"; Filename: "{uninstallexe}"
[Run]
Filename: "{app}\control\YourBacker.exe"; Description: "Launch YourBacker"; Flags: nowait postinstall skipifsilent
[Registry]
Root: HKLM; Subkey: "Software\Microsoft\Windows\CurrentVersion\Run"; \
ValueType: string; ValueName: "YourBacker"; \
ValueData: """{app}\control\YourBacker.exe"""; Flags: uninsdeletevalue
[UninstallRun]
Filename: "sc.exe"; Parameters: "stop BackerAgent"; StatusMsg: "Stopping Windows Service..."; RunOnceId: "StopService"
Filename: "sc.exe"; Parameters: "delete BackerAgent"; StatusMsg: "Removing Windows Service..."; RunOnceId: "DeleteService"
[Code]
procedure UpdateAppSettings(
AppSettingsFile: string;
RclonePath: string);
var
EscapedPath: string;
Json: TStringList;
i: Integer;
begin
if FileExists(AppSettingsFile) then
begin
Json := TStringList.Create;
try
Json.LoadFromFile(AppSettingsFile);
// Escape backslashes for valid JSON
EscapedPath := RclonePath;
StringChangeEx(EscapedPath, '\', '\\', True);
for i := 0 to Json.Count - 1 do
begin
if Pos('"RClonePath"', Json[i]) > 0 then
begin
Json[i] := ' "RClonePath": "' + EscapedPath + '",';
Break;
end;
end;
Json.SaveToFile(AppSettingsFile);
finally
Json.Free;
end;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
begin
if CurStep = ssPostInstall then
begin
UpdateAppSettings(
ExpandConstant('{commonappdata}\Backer\appsettings.json'),
ExpandConstant('{app}\contrib\rclone.exe'));
UpdateAppSettings(
ExpandConstant('{app}\service\appsettings.json'),
ExpandConstant('{app}\contrib\rclone.exe'));
Exec(ExpandConstant('sc.exe'),
'create BackerAgent binPath= "' + ExpandConstant('{app}\service\BackerAgent.exe') + '" start= auto',
'', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Exec(ExpandConstant('sc.exe'), 'start BackerAgent', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
end;