-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.iss
More file actions
207 lines (180 loc) · 6.83 KB
/
setup.iss
File metadata and controls
207 lines (180 loc) · 6.83 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
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
; ThingConnect Pulse - Inno Setup Installation Script
; Implements installer conventions documented in docs/installer-map.md
#define AppName "ThingConnect Pulse"
#define AppVersion "1.0.0"
#define AppPublisher "ThingConnect"
#define AppURL "https://thingconnect.io/pulse"
#define AppExeName "ThingConnect.Pulse.Server.exe"
#define ServiceName "ThingConnectPulseSvc"
#define ServiceDisplayName "ThingConnect Pulse Server"
#define ServiceDescription "Network availability monitoring system for manufacturing sites"
[Setup]
AppId={{B8E8F8A0-8B8A-4B8A-8B8A-8B8A8B8A8B8A}
AppName={#AppName}
AppVersion={#AppVersion}
AppVerName={#AppName} {#AppVersion}
AppPublisher={#AppPublisher}
AppPublisherURL={#AppURL}
AppSupportURL={#AppURL}/issues
AppUpdatesURL={#AppURL}/releases
DefaultDirName={autopf}\ThingConnect.Pulse
DefaultGroupName={#AppName}
DisableProgramGroupPage=yes
OutputDir=installer
OutputBaseFilename=ThingConnect.Pulse.Setup {#AppVersion}
Compression=lzma
SolidCompression=yes
WizardStyle=modern
PrivilegesRequired=admin
DisableDirPage=no
DisableReadyPage=no
; Windows version requirements
MinVersion=10.0.17763
ArchitecturesAllowed=x64
; Enable installation logging
SetupLogging=yes
; Icon configuration
SetupIconFile=brand\favicon.ico
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
; Application binaries from publish output
Source: "publish\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
Name: "{group}\{#AppName}"; Filename: "http://localhost:8090"; IconFilename: "{app}\wwwroot\favicon.ico"
Name: "{group}\Logs Directory"; Filename: "{commonappdata}\ThingConnect.Pulse\logs";
Name: "{group}\Installation Log"; Filename: "{log}"
Name: "{group}\Documentation"; Filename: "https://docs.thingconnect.io/pulse"
Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}"
[Run]
; Install and start the Windows service
Filename: "{sys}\sc.exe"; Parameters: "create ""{#ServiceName}"" start= auto DisplayName= ""{#ServiceDisplayName}"" binPath= ""{app}\{#AppExeName}"""; Flags: runhidden; StatusMsg: "Creating Windows service..."
Filename: "{sys}\sc.exe"; Parameters: "description ""{#ServiceName}"" ""{#ServiceDescription}"""; Flags: runhidden; StatusMsg: "Setting service description..."
Filename: "{sys}\sc.exe"; Parameters: "failure ""{#ServiceName}"" reset= 86400 actions= restart/5000/restart/5000/restart/5000"; Flags: runhidden; StatusMsg: "Configuring service recovery..."
Filename: "{sys}\sc.exe"; Parameters: "start ""{#ServiceName}"""; Flags: runhidden; StatusMsg: "Starting Windows service..."
Filename: "http://localhost:8090"; Description: "Open {#AppName} Web Interface"; Flags: nowait postinstall shellexec skipifsilent
[UninstallRun]
Filename: "{sys}\sc.exe"; Parameters: "stop ""{#ServiceName}"""; Flags: runhidden
Filename: "{sys}\sc.exe"; Parameters: "delete ""{#ServiceName}"""; Flags: runhidden
[Code]
function IsServiceInstalled(): Boolean;
var
ResultCode: Integer;
begin
Result := Exec('sc.exe', 'query "{#ServiceName}"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) and (ResultCode = 0);
end;
function StopService(): Boolean;
var
ResultCode: Integer;
begin
Log('Stopping service: {#ServiceName}');
Result := Exec('sc.exe', 'stop "{#ServiceName}"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if Result then
Sleep(2000); // Wait for service to stop
end;
function RemoveService(): Boolean;
var
ResultCode: Integer;
begin
Log('Removing service: {#ServiceName}');
Result := Exec('sc.exe', 'delete "{#ServiceName}"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
if Result then
Sleep(1000); // Wait for service removal
end;
// Service installation is now handled by [Run] section
procedure CreateDirectoryStructure();
var
ProgramDataRoot: String;
ConfigDir, VersionsDir, LogsDir, DataDir: String;
ConfigFile: String;
DefaultConfig: String;
begin
ProgramDataRoot := ExpandConstant('{commonappdata}') + '\ThingConnect.Pulse';
ConfigDir := ProgramDataRoot + '\config';
VersionsDir := ProgramDataRoot + '\versions';
LogsDir := ProgramDataRoot + '\logs';
DataDir := ProgramDataRoot + '\data';
Log('Creating directory structure at: ' + ProgramDataRoot);
ForceDirectories(ConfigDir);
ForceDirectories(VersionsDir);
ForceDirectories(LogsDir);
ForceDirectories(DataDir);
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssInstall:
begin
Log('=== Installation Step: Preparing installation ===');
Log('Installation target directory: ' + ExpandConstant('{app}'));
// Stop and remove existing service if present
if IsServiceInstalled() then
begin
Log('Existing service detected, will be stopped and removed...');
if StopService() then
Log('Existing service stopped successfully')
else
Log('WARNING: Failed to stop existing service');
if RemoveService() then
Log('Existing service removed successfully')
else
Log('WARNING: Failed to remove existing service');
end else
begin
Log('No existing service found');
end;
end;
ssPostInstall:
begin
Log('=== Post-Install Step: Creating directory structure ===');
// Create directory structure
Log('Creating application data directories...');
CreateDirectoryStructure();
Log('Directory structure created successfully');
end;
end;
end;
function InitializeUninstall(): Boolean;
var
Response: Integer;
ProgramDataRoot: String;
begin
Result := True;
ProgramDataRoot := ExpandConstant('{commonappdata}') + '\ThingConnect.Pulse';
// Ask user about data preservation
Response := MsgBox(
'{#AppName} Uninstaller' + #13#10 + #13#10 +
'The following data will be PERMANENTLY DELETED:' + #13#10 +
'• Configuration files and version history' + #13#10 +
'• All monitoring data and historical records' + #13#10 +
'• Log files' + #13#10 + #13#10 +
'Do you want to keep your configuration and data files?' + #13#10 +
'(Recommended if you plan to reinstall later)',
mbConfirmation, MB_YESNOCANCEL
);
if Response = IDCANCEL then
begin
Result := False; // Cancel uninstall
Exit;
end;
// Stop and remove service
if IsServiceInstalled() then
begin
StopService();
RemoveService();
end;
// Handle data cleanup based on user choice
if Response = IDNO then
begin
Log('User chose to delete all data');
// Remove data directories
DelTree(ProgramDataRoot, True, True, True);
end else
begin
Log('User chose to preserve configuration and data');
MsgBox('Configuration and data files have been preserved in:' + #13#10 +
ProgramDataRoot + #13#10 + #13#10 +
'You can manually remove this directory later if needed.',
mbInformation, MB_OK);
end;
end;