Skip to content

Commit 8dde50f

Browse files
authored
Merge pull request #22 from cazac9/master
enable ssl & install location
2 parents 235c64b + b8f0efe commit 8dde50f

File tree

5 files changed

+70
-35
lines changed

5 files changed

+70
-35
lines changed

eFormAPI/Installation/CustomActions/CustomAction.cs

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ namespace CustomActions
1616
public class CustomActions
1717
{
1818
public static Session Session;
19-
public static string IisSitesDir = @"C:\inetpub\wwwroot\";
20-
public static string TempDir = @"C:\inetpub\wwwroot\microtingTemp";
2119

2220
[CustomAction]
2321
public static ActionResult GetAPIsListCA(Session session)
@@ -75,29 +73,30 @@ public static ActionResult InstallCA(Session session)
7573

7674
if (session.CustomActionData["INSTMODE"] != "Install")
7775
return ActionResult.Success;
78-
76+
77+
var tmpDir = session.CustomActionData["INSTALLFOLDER"] + "microtingTemp";
78+
7979
var customerNumber = session.CustomActionData["CUSTOMERNUMBER"];
8080
var domain = session.CustomActionData["DOMAINNAME"];
8181

8282
session.Log("Get latest product version called");
83-
GetProductLatestVersion(TempDir);
83+
GetProductLatestVersion(tmpDir);
8484
IncrementProgressBar(session);
8585

86-
var uiPorts = Directory.GetDirectories(IisSitesDir).Where(t => t.Contains("_client_")).Select(t => int.Parse(t.Split('_').Last()));
87-
var nextUiPort = uiPorts.Any() ? uiPorts.Max() + 1 : 3000;
86+
var webApiPort = GetWebApiPort();
87+
var nextUiPort = webApiPort-2000;
8888
var uiName = $"{customerNumber}_{domain}_client_{nextUiPort}";
89-
var uiIisDir = IisSitesDir + uiName;
90-
var angularSolutionLocation = $@"{TempDir}\eform-client";
91-
session.Log("Build Angullar app tasrk started");
89+
var uiIisDir = session.CustomActionData["INSTALLFOLDER"] + uiName;
90+
var angularSolutionLocation = $@"{tmpDir}\eform-client";
91+
session.Log("Build Angullar app task started");
9292
BuildAngularApp(uiIisDir, angularSolutionLocation);
9393
IncrementProgressBar(session);
9494

95-
var webApiLocation = $@"{TempDir}\eFormAPI\eFormAPI";
96-
var webApiPort = GetWebApiPort();
95+
var webApiLocation = $@"{tmpDir}\eFormAPI\eFormAPI";
9796
var webApiName = $"{customerNumber}_{domain}_{webApiPort}";
98-
var webApiIisDir = IisSitesDir + webApiName;
97+
var webApiIisDir = session.CustomActionData["INSTALLFOLDER"] + webApiName;
9998
session.Log("Build WebAPI called");
100-
// Debugger.Launch();
99+
101100
BuildWebApi(webApiLocation, webApiIisDir);
102101
IncrementProgressBar(session);
103102
session.Log("Host WebAPI called");
@@ -120,11 +119,13 @@ public static ActionResult InstallCA(Session session)
120119
SaveInstances(webApiName);
121120
IncrementProgressBar(session);
122121

123-
RunProcess($@"{TempDir}\eFormAPI\Installation\letsencrypt\letsencrypt.exe", $"--plugin manual --manualhost {uiName} --webroot {IisSitesDir.TrimEnd('\\')}");
122+
if (session.CustomActionData["GENERATESSL"]== "1")
123+
RunProcess($@"{tmpDir}\eFormAPI\Installation\letsencrypt\letsencrypt.exe", $"--plugin manual --manualhost {uiName} --webroot {session.CustomActionData["INSTALLFOLDER"].TrimEnd('\\')}");
124+
124125
IncrementProgressBar(session);
125126

126127
session.Log("Clear temp dir called");
127-
DeleteDirectory(TempDir);
128+
DeleteDirectory(tmpDir);
128129
IncrementProgressBar(session);
129130

130131
return ActionResult.Success;
@@ -165,29 +166,33 @@ public static ActionResult UpdateCA(Session session)
165166
if (session.CustomActionData["INSTMODE"] != "Update")
166167
return ActionResult.Success;
167168

168-
var api = session.CustomActionData["DOMAINNAME"].Split('_');
169+
var domainName = session.CustomActionData["DOMAINNAME"];
170+
var api = domainName.Split('_');
169171
var domain = api[1];
170172
var customerNumber = api.First();
171173
var apiPort = int.Parse(api.Last());
172174
var uiPort = apiPort - 2000;
173175

176+
var installDir = GetInstallDirrectory(domainName);
177+
var tmpDir = Path.Combine(installDir + "microtingTemp");
178+
174179
// stop sites
175180
ControlSites(customerNumber, domain, apiPort, uiPort, false);
176181
IncrementProgressBar(session);
177182

178-
GetProductLatestVersion(TempDir);
183+
GetProductLatestVersion(tmpDir);
179184
IncrementProgressBar(session);
180185

181186
// client update
182187
var uiName = $"{customerNumber}_{domain}_client_{uiPort}";
183-
var uiIisDir = @"C:\inetpub\wwwroot\" + uiName;
188+
var uiIisDir = Path.Combine(installDir + uiName);
184189

185190
RunProcess(@"sc", $"stop eformangular{uiName.Replace(".", "")}.exe");
186191
Thread.Sleep(1000);
187192
RunProcess(@"C:\Program Files\nodejs\node.exe", "svc.js uninstall", uiIisDir);
188193
IncrementProgressBar(session);
189194

190-
BuildAngularApp(uiIisDir, TempDir + "\\eform-client");
195+
BuildAngularApp(uiIisDir, tmpDir + "\\eform-client");
191196
IncrementProgressBar(session);
192197

193198

@@ -196,14 +201,14 @@ public static ActionResult UpdateCA(Session session)
196201

197202
// api update
198203
var webApiName = $"{customerNumber}_{domain}_{apiPort}";
199-
var webApiIisDir = @"C:\inetpub\wwwroot\" + webApiName;
200-
BuildWebApi(TempDir + "\\eFormAPI\\eFormAPI", webApiIisDir);
204+
var webApiIisDir = Path.Combine(installDir + webApiName);
205+
BuildWebApi(tmpDir + "\\eFormAPI\\eFormAPI", webApiIisDir);
201206
IncrementProgressBar(session);
202207

203208
ControlSites(customerNumber, domain, apiPort, uiPort, true);
204209
IncrementProgressBar(session);
205210

206-
DeleteDirectory(TempDir);
211+
DeleteDirectory(tmpDir);
207212
IncrementProgressBar(session);
208213

209214
return ActionResult.Success;
@@ -227,24 +232,26 @@ public static ActionResult RemoveCA(Session session)
227232

228233
ResetProgressBar(session, 6);
229234

230-
var api = session.CustomActionData["DOMAINNAME"].Split('_');
235+
var domainName = session.CustomActionData["DOMAINNAME"];
236+
var api = domainName.Split('_');
231237
var domain = api[1];
232238
var customerNumber = api.First();
233239
var apiPort = int.Parse(api.Last());
234240
var uiPort = apiPort - 2000;
235241

242+
var installDir = GetInstallDirrectory(domainName);
243+
236244
var uiName = $"{customerNumber}_{domain}_client_{uiPort}";
237-
var uiIisDir = @"C:\inetpub\wwwroot\" + uiName;
245+
var uiIisDir = Path.Combine(installDir + uiName);
238246
var webApiName = $"{customerNumber}_{domain}_{apiPort}";
239-
var webApiIisDir = @"C:\inetpub\wwwroot\" + webApiName;
240-
247+
var webApiIisDir = Path.Combine(installDir + webApiName);
248+
241249
// stop sites
242250
ControlSites(customerNumber, domain, apiPort, uiPort, false);
243251
IncrementProgressBar(session);
244252
RemoveSites(customerNumber, domain, apiPort, uiPort);
245253
IncrementProgressBar(session);
246254

247-
//Debugger.Launch();
248255
RunProcess(@"sc", $"stop eformangular{uiName.Replace(".", "")}.exe");
249256
Thread.Sleep(1000);
250257
RunProcess(@"C:\Program Files\nodejs\node.exe", "svc.js uninstall", uiIisDir);
@@ -354,6 +361,15 @@ private static void HostWebApi(string webApiName, int port, string iisDir)
354361
}
355362
}
356363

364+
private static string GetInstallDirrectory(string siteName)
365+
{
366+
using (var serverManager = new ServerManager())
367+
{
368+
var sitePath = serverManager.Sites[siteName].Applications["/"].VirtualDirectories["/"].PhysicalPath;
369+
return new DirectoryInfo(sitePath).Parent.FullName + "\\";
370+
}
371+
}
372+
357373
private static void RunAngularAsWinService(int webApiPort, int uiWinServicePort, string iisDir, string uiName)
358374
{
359375
var serverJs = File.ReadAllText(iisDir + @"\server.js");

eFormAPI/Installation/MainInstaller/DomainNameDlg.wxs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
<Fragment>
44
<UI>
55
<Dialog Id="DomainNameDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">
6-
<Control Id="NameLabel" Type="Text" X="45" Y="73" Width="100" Height="15" TabSkip="no" Text="&amp;Domain Name:"/>
6+
<Control Id="NameLabel" Type="Text" X="45" Y="73" Width="100" Height="15" TabSkip="no" Text="&amp;Domain Name:" />
77
<Control Id="NameEdit" Type="Edit" X="45" Y="85" Width="220" Height="15" Property="DOMAINNAME" Text="{80}" />
88
<Control Type="Text" Id="CustomerNumberText" Width="100" Height="15" X="45" Y="118" Text="&amp;Customer number:" />
9-
<Control Type="Edit" Id="CustomerNumber" Width="220" Height="15" X="45" Y="132" Property="CUSTOMERNUMBER" Text="{80}" />
9+
<Control Type="Edit" Id="CustomerNumber" Width="220" Height="15" X="45" Y="132" Property="CUSTOMERNUMBER" Text="{80}" />
1010

11-
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back"/>
11+
<Control Type="CheckBox" Id="certgen" Property="GENERATESSL" Width="215" Height="17" X="45" Y="165" CheckBoxValue="1" Text="Generate SSL certificate" />
12+
13+
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back" />
1214
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Text="&amp;Next">
1315
<Publish Event="SpawnDialog" Value="EmptyFieldDlg">NOT DOMAINNAME OR NOT CUSTOMERNUMBER</Publish>
1416
</Control>

eFormAPI/Installation/MainInstaller/MaintenanceTypeModifiedDlg.wxs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<Publish Property="INSTMODE" Value="Install" >1</Publish>
1313
<Publish Property="DOMAINNAME" Value="{}" >1</Publish>
1414
<Publish Property="CUSTOMERNUMBER" Value="{}" >1</Publish>
15+
<Publish Property="GENERATESSL" Value="{}" >1</Publish>
1516
</Control>
1617
<Control Id="Update" Type="PushButton" X="98" Y="139" Width="139" Height="33" Text="&amp;Update" >
1718
<Condition Action="disable">NOUI</Condition>

eFormAPI/Installation/MainInstaller/Product.wxs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@
2020
<Fragment>
2121
<Directory Id="TARGETDIR" Name="SourceDir">
2222
<Directory Id="ProgramFilesFolder">
23-
<Directory Id="INSTALLFOLDER" Name="$(var.ProductName)"/>
23+
<Directory Id="INSTALLFOLDER" Name="$(var.ProductName)" />
2424
</Directory>
2525
</Directory>
26-
26+
27+
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"/>
28+
2729
<Property Id="MSIUSEREALADMINDETECTION" Value="1" />
2830
<Property Id="MSIINSTALLPERUSER" Value="{}" />
31+
2932

3033
<SetProperty Id="ARPNOMODIFY" Value="1" After="InstallValidate" Sequence="execute"/>
3134
<Property Id="INSTMODE" Value="{}" Secure="yes" />
3235
<Property Id="DOMAINNAME" Value="{}" Secure="yes"/>
3336
<Property Id="CUSTOMERNUMBER" Value="{}" Secure="yes"/>
37+
<Property Id="GENERATESSL" Value="{}" Secure="yes"/>
38+
<Property Id="INSTALLFOLDER" Value="C:\inetpub\wwwroot" Secure="yes"/>
3439

3540
<InstallExecuteSequence>
3641
<Custom Action="SetProductName" After="InstallInitialize"/>
@@ -51,7 +56,7 @@
5156
<CustomAction Id="RemoveService" BinaryKey="BinaryCA" DllEntry="RemoveCA" Execute="deferred" Impersonate="no" />
5257
<Binary Id="BinaryCA" SourceFile="BuildedCustomActions\CustomActions.CA.dll"/>
5358

54-
<CustomAction Id="SetInstalValues" Property="Install" Value="INSTMODE=[INSTMODE];DOMAINNAME=[DOMAINNAME];CUSTOMERNUMBER=[CUSTOMERNUMBER]" />
59+
<CustomAction Id="SetInstalValues" Property="Install" Value="INSTMODE=[INSTMODE];DOMAINNAME=[DOMAINNAME];CUSTOMERNUMBER=[CUSTOMERNUMBER];GENERATESSL=[GENERATESSL];INSTALLFOLDER=[INSTALLFOLDER]" />
5560
<CustomAction Id="SetRemoveValues" Property="RemoveService" Value="INSTMODE=[INSTMODE];DOMAINNAME=[DOMAINNAME]" />
5661
<CustomAction Id="SetUpdateServiceValues" Property="UpdateService" Value="INSTMODE=[INSTMODE];DOMAINNAME=[DOMAINNAME]" />
5762

eFormAPI/Installation/MainInstaller/WixUI_InstallDirModified.wxs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,26 @@
3333
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="DomainNameDlg"></Publish>
3434

3535
<Publish Dialog="DomainNameDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
36-
<Publish Dialog="DomainNameDlg" Control="Next" Event="NewDialog" Value="VerifyReadyModifiedDlg">1</Publish>
36+
<Publish Dialog="DomainNameDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">1</Publish>
3737

38-
<Publish Dialog="VerifyReadyModifiedDlg" Control="Back" Event="NewDialog" Value="DomainNameDlg" Order="1">WixUI_InstallMode = "Install"</Publish>
38+
<Publish Dialog="VerifyReadyModifiedDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">WixUI_InstallMode = "Install"</Publish>
3939
<Publish Dialog="VerifyReadyModifiedDlg" Control="Back" Event="NewDialog" Value="DomainNameSelectDlg" Order="1">WixUI_InstallMode = "Update" OR WixUI_InstallMode = "Remove"</Publish>
4040

4141
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeModifiedDlg">1</Publish>
4242

4343
<Publish Dialog="DomainNameSelectDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeModifiedDlg">1</Publish>
4444
<Publish Dialog="DomainNameSelectDlg" Control="Next" Event="NewDialog" Value="VerifyReadyModifiedDlg">1</Publish>
45+
46+
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="DomainNameDlg">1</Publish>
47+
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
48+
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
49+
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
50+
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyModifiedDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
51+
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
52+
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
53+
54+
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
55+
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
4556
</UI>
4657
</Fragment>
4758
</Wix>

0 commit comments

Comments
 (0)