-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_config.iss
More file actions
223 lines (196 loc) · 9.11 KB
/
setup_config.iss
File metadata and controls
223 lines (196 loc) · 9.11 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
; Guth Pump Works Installer
; Generated by Inno Setup Script Wizard and enhanced with custom functionality
#define MyAppName "Guth Pump Works"
#define MyAppVersion "1.0.0"
#define MyAppPublisher "Guth South Africa PTY LTD"
#define MyAppURL "https://github.com/TravisMain/GuthPumpRegistry"
#define MyAppExeName "GuthPumpWorks.exe"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".gpr"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt
[Setup]
AppId={{FA4584C4-CE7A-41BF-B311-263BA68039C3}}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
UninstallDisplayIcon={app}\{#MyAppExeName}
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
ChangesAssociations=yes
DisableProgramGroupPage=yes
LicenseFile=C:\Users\travism\source\repos\GuthPumpRegistry\license.txt
InfoBeforeFile=C:\Users\travism\source\repos\GuthPumpRegistry\info before.txt
InfoAfterFile=C:\Users\travism\source\repos\GuthPumpRegistry\info after.txt
OutputDir=C:\Users\travism\source\repos\GuthPumpRegistry\output
OutputBaseFilename=GuthPumpWorksSetup
SetupIconFile=C:\Users\travism\source\repos\GuthPumpRegistry\setup_icon.ico
SolidCompression=yes
WizardStyle=modern
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "C:\Users\travism\source\repos\GuthPumpRegistry\dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\travism\source\repos\GuthPumpRegistry\dependencies\msodbcsql.msi"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "C:\Users\travism\source\repos\GuthPumpRegistry\dependencies\VC_redist.x64.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
Source: "C:\Users\travism\source\repos\GuthPumpRegistry\README.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\travism\source\repos\GuthPumpRegistry\USER_GUIDE.md"; DestDir: "{app}"; Flags: ignoreversion
[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
[Run]
Filename: "msiexec.exe"; Parameters: "/i ""{tmp}\msodbcsql.msi"" /quiet /norestart"; StatusMsg: "Installing Microsoft ODBC Driver for SQL Server..."; Flags: waituntilterminated
Filename: "{tmp}\VC_redist.x64.exe"; Parameters: "/install /quiet /norestart"; StatusMsg: "Installing Visual C++ Redistributable..."; Flags: waituntilterminated
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
[Code]
var
ConfigPage: TWizardPage;
ServerEdit: TEdit;
DataDirEdit: TEdit;
DataDirButton: TButton;
DatabaseEdit: TEdit;
UsernameEdit: TEdit;
PasswordEdit: TEdit;
function EscapeJson(Input: String): String;
var
I: Integer;
ResultStr: String;
begin
ResultStr := '';
for I := 1 to Length(Input) do
if Input[I] = '\' then
ResultStr := ResultStr + '\\'
else if Input[I] = '"' then
ResultStr := ResultStr + '\"'
else
ResultStr := ResultStr + Input[I];
Result := ResultStr;
end;
procedure BrowseDataDirClick(Sender: TObject);
var
Dir: String;
begin
Dir := DataDirEdit.Text;
if BrowseForFolder('Select SQL Server Data Directory', Dir, True) then
DataDirEdit.Text := Dir;
end;
procedure InitializeWizard;
var
ServerLabel: TNewStaticText;
DataDirLabel: TNewStaticText;
DatabaseLabel: TNewStaticText;
UsernameLabel: TNewStaticText;
PasswordLabel: TNewStaticText;
begin
ConfigPage := CreateCustomPage(wpSelectDir, 'SQL Server Configuration',
'Configure SQL Server connection settings for Guth Pump Works');
ServerLabel := TNewStaticText.Create(ConfigPage);
ServerLabel.Parent := ConfigPage.Surface;
ServerLabel.Caption := 'SQL Server Instance (e.g., localhost\SQLEXPRESS):';
ServerLabel.Top := 10;
ServerLabel.Left := 0;
ServerEdit := TEdit.Create(ConfigPage);
ServerEdit.Parent := ConfigPage.Surface;
ServerEdit.Width := ConfigPage.SurfaceWidth - 10;
ServerEdit.Top := ServerLabel.Top + ServerLabel.Height + 5;
ServerEdit.Left := 0;
ServerEdit.Text := 'localhost\SQLEXPRESS';
DataDirLabel := TNewStaticText.Create(ConfigPage);
DataDirLabel.Parent := ConfigPage.Surface;
DataDirLabel.Caption := 'SQL Data Directory (optional, e.g., C:\Program Files\Microsoft SQL Server\...):';
DataDirLabel.Top := ServerEdit.Top + ServerEdit.Height + 20;
DataDirLabel.Left := 0;
DataDirEdit := TEdit.Create(ConfigPage);
DataDirEdit.Parent := ConfigPage.Surface;
DataDirEdit.Width := ConfigPage.SurfaceWidth - 80;
DataDirEdit.Top := DataDirLabel.Top + DataDirLabel.Height + 5;
DataDirEdit.Left := 0;
DataDirEdit.Text := '';
DataDirButton := TButton.Create(ConfigPage);
DataDirButton.Parent := ConfigPage.Surface;
DataDirButton.Caption := 'Browse...';
DataDirButton.Width := 75;
DataDirButton.Height := 25;
DataDirButton.Top := DataDirEdit.Top;
DataDirButton.Left := DataDirEdit.Width + 5;
DataDirButton.OnClick := @BrowseDataDirClick;
DatabaseLabel := TNewStaticText.Create(ConfigPage);
DatabaseLabel.Parent := ConfigPage.Surface;
DatabaseLabel.Caption := 'Database Name (e.g., GuthPumpWorks):';
DatabaseLabel.Top := DataDirEdit.Top + DataDirEdit.Height + 20;
DatabaseLabel.Left := 0;
DatabaseEdit := TEdit.Create(ConfigPage);
DatabaseEdit.Parent := ConfigPage.Surface;
DatabaseEdit.Width := ConfigPage.SurfaceWidth - 10;
DatabaseEdit.Top := DatabaseLabel.Top + DatabaseLabel.Height + 5;
DatabaseEdit.Left := 0;
DatabaseEdit.Text := 'GuthPumpWorks';
UsernameLabel := TNewStaticText.Create(ConfigPage);
UsernameLabel.Parent := ConfigPage.Surface;
UsernameLabel.Caption := 'SQL Username (e.g., sa, optional for Windows Auth):';
UsernameLabel.Top := DatabaseEdit.Top + DatabaseEdit.Height + 20;
UsernameLabel.Left := 0;
UsernameEdit := TEdit.Create(ConfigPage);
UsernameEdit.Parent := ConfigPage.Surface;
UsernameEdit.Width := ConfigPage.SurfaceWidth - 10;
UsernameEdit.Top := UsernameLabel.Top + UsernameLabel.Height + 5;
UsernameEdit.Left := 0;
UsernameEdit.Text := '';
PasswordLabel := TNewStaticText.Create(ConfigPage);
PasswordLabel.Parent := ConfigPage.Surface;
PasswordLabel.Caption := 'SQL Password (optional for Windows Auth):';
PasswordLabel.Top := UsernameEdit.Top + UsernameEdit.Height + 20;
PasswordLabel.Left := 0;
PasswordEdit := TEdit.Create(ConfigPage);
PasswordEdit.Parent := ConfigPage.Surface;
PasswordEdit.Width := ConfigPage.SurfaceWidth - 10;
PasswordEdit.Top := PasswordLabel.Top + PasswordLabel.Height + 5;
PasswordEdit.Left := 0;
PasswordEdit.PasswordChar := '*';
PasswordEdit.Text := '';
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ConfigFile: String;
ConfigText: String;
begin
if CurStep = ssPostInstall then
begin
ConfigFile := ExpandConstant('{app}\config.json');
ConfigText := '{"connection_string": "DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + EscapeJson(ServerEdit.Text) +
';DATABASE=' + EscapeJson(DatabaseEdit.Text);
if (UsernameEdit.Text <> '') and (PasswordEdit.Text <> '') then
ConfigText := ConfigText + ';UID=' + EscapeJson(UsernameEdit.Text) +
';PWD=' + EscapeJson(PasswordEdit.Text) + '",'
else
ConfigText := ConfigText + ';Trusted_Connection=yes",';
ConfigText := ConfigText +
'"document_dirs": {' +
'"notifications": "' + ExpandConstant('{userappdata}\GuthPumpWorks\notifications') + '",' +
'"certificates": "' + ExpandConstant('{userappdata}\GuthPumpWorks\certificates') + '",' +
'"boms": "' + ExpandConstant('{userappdata}\GuthPumpWorks\boms') + '",' +
'"confirmations": "' + ExpandConstant('{userappdata}\GuthPumpWorks\confirmations') + '",' +
'"reports": "' + ExpandConstant('{userappdata}\GuthPumpWorks\reports') + '",' +
'"excel_exports": "' + ExpandConstant('{userappdata}\GuthPumpWorks\exports') + '"' +
'},' +
'"email_settings": {' +
'"smtp_host": "smtp.gmail.com",' +
'"smtp_port": "587",' +
'"smtp_username": "",' +
'"smtp_password": "",' +
'"sender_email": "",' +
'"use_tls": true' +
'}}';
SaveStringToFile(ConfigFile, ConfigText, False);
end;
end;