Skip to content

Commit 17b7930

Browse files
committed
added Plesk 17x support
1 parent 9c2700e commit 17b7930

File tree

9 files changed

+815
-2
lines changed

9 files changed

+815
-2
lines changed

MpImport.v11.suo

-3 KB
Binary file not shown.
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
namespace MpMigrate.Core.Discovery
2+
{
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Text;
9+
10+
public class Plesk_17_Discover : IDiscovery
11+
{
12+
public string Version()
13+
{
14+
if (Environment.Is64BitOperatingSystem)
15+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PRODUCT_VERSION");
16+
else
17+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PRODUCT_VERSION");
18+
}
19+
20+
public string VhostPath()
21+
{
22+
return Path.Combine(Environment.GetEnvironmentVariable("plesk_vhosts", EnvironmentVariableTarget.Machine), "{DOMAIN}", "httpdocs");
23+
}
24+
25+
private DatabaseProviders PleskDatabaseProvider(string databaseProviderName)
26+
{
27+
DatabaseProviders provider = DatabaseProviders.Unknown;
28+
29+
switch (databaseProviderName)
30+
{
31+
case "MySQL":
32+
provider = DatabaseProviders.MYSQL;
33+
break;
34+
case "MsSQL":
35+
provider = DatabaseProviders.MSSQL;
36+
break;
37+
}
38+
39+
return provider;
40+
41+
}
42+
43+
public DatabaseProviders GetDatabaseProvider()
44+
{
45+
var providerName = String.Empty;
46+
47+
if (Environment.Is64BitOperatingSystem)
48+
providerName = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PLESK_DATABASE_PROVIDER_NAME");
49+
else
50+
providerName = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PLESK_DATABASE_PROVIDER_NAME");
51+
52+
return PleskDatabaseProvider(providerName);
53+
}
54+
55+
public string GetDatabaseHost()
56+
{
57+
if (Environment.Is64BitOperatingSystem)
58+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "MySQL_DB_HOST");
59+
else
60+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "MySQL_DB_HOST");
61+
}
62+
63+
public int GetDatabasePort()
64+
{
65+
if (Environment.Is64BitOperatingSystem)
66+
return int.Parse(CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "MySQL_DB_PORT"));
67+
else
68+
return int.Parse(CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "MySQL_DB_PORT"));
69+
}
70+
71+
public string GetDatabaseUsername()
72+
{
73+
if (Environment.Is64BitOperatingSystem)
74+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PLESK_DATABASE_LOGIN");
75+
else
76+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PLESK_DATABASE_LOGIN");
77+
}
78+
79+
public string GetDatabasePassword()
80+
{
81+
return GetPanelPassword();
82+
}
83+
84+
public string GetDatabaseName()
85+
{
86+
if (Environment.Is64BitOperatingSystem)
87+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "mySQLDBName");
88+
else
89+
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "mySQLDBName");
90+
}
91+
92+
public string GetDatabaseFile()
93+
{
94+
return "";
95+
}
96+
97+
public bool isInstalled()
98+
{
99+
var installed = false;
100+
var check_environment = Environment.GetEnvironmentVariable("plesk_dir", EnvironmentVariableTarget.Machine);
101+
102+
var plesk_version = String.Empty;
103+
104+
if (Environment.Is64BitOperatingSystem)
105+
plesk_version = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PRODUCT_VERSION");
106+
else
107+
plesk_version = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PRODUCT_VERSION");
108+
109+
if (Directory.Exists(check_environment))
110+
if (plesk_version.StartsWith("17"))
111+
installed = true;
112+
113+
return installed;
114+
}
115+
116+
public string GetPanelPassword()
117+
{
118+
var plesk_bin = Environment.GetEnvironmentVariable("plesk_bin", EnvironmentVariableTarget.Machine);
119+
120+
if (!String.IsNullOrEmpty(plesk_bin))
121+
{
122+
var plesksrvclient_exe = Path.Combine(plesk_bin, "plesksrvclient.exe");
123+
CoreHelper.Exec(plesksrvclient_exe, "-get -nogui");
124+
125+
return System.Windows.Forms.Clipboard.GetText();
126+
}
127+
else
128+
{
129+
throw new Exception("Could not determine password: Plesk 17.0");
130+
}
131+
}
132+
133+
public string GetEmailPath()
134+
{
135+
var mailproviderPath = String.Empty;
136+
137+
var mailprovider = Environment.Is64BitOperatingSystem
138+
? CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "MAIL_PROVIDERW_DLL")
139+
: CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "MAIL_PROVIDERW_DLL");
140+
141+
var isMailEnable = mailprovider.EndsWith("mailenableproviderw.dll");
142+
143+
if (isMailEnable)
144+
mailproviderPath = Path.Combine(CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\Mail Enable\Mail Enable", "Mail Root"), "{DOMAIN}", "MAILROOT", "{MAILBOX}");
145+
146+
return mailproviderPath;
147+
}
148+
149+
public string InstallPath()
150+
{
151+
return Environment.GetEnvironmentVariable("plesk_dir", EnvironmentVariableTarget.Machine);
152+
}
153+
}
154+
}

MpMigrate.Core/MigrateManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public enum PanelTypes
1919
Plesk_12,
2020
Plesk_10,
2121
Plesk_10x,
22+
Plesk_17x,
2223
MaestroPanel,
2324
Entrenix,
2425
Helm,
@@ -454,6 +455,9 @@ private void LoadVariations()
454455
variationList.Add(new Tuple<PanelTypes, DatabaseProviders, DboFactory, IDiscovery>
455456
(PanelTypes.Plesk_82, DatabaseProviders.OLEDB_ACCESS, new Plesk_82_Access(), new Plesk_86_Discover()));
456457

458+
variationList.Add(new Tuple<PanelTypes, DatabaseProviders, DboFactory, IDiscovery>
459+
(PanelTypes.Plesk_17x, DatabaseProviders.MYSQL, new Plesk_17_MySql(), new Plesk_17_Discover()));
460+
457461

458462
}
459463

MpMigrate.Core/MpMigrate.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<Compile Include="Discovery\Plesk_12_Discover.cs" />
5656
<Compile Include="Discovery\Entrenix_Discover.cs" />
5757
<Compile Include="Discovery\Plesk_10_Discover.cs" />
58+
<Compile Include="Discovery\Plesk_17_Discover.cs" />
5859
<Compile Include="Discovery\Plesk_9_Discover.cs" />
5960
<Compile Include="Discovery\MaestroPanelDiscover.cs" />
6061
<Compile Include="Discovery\Plesk_11_Discover.cs" />

MpMigrate.Core/obj/Release/MpMigrate.Core.csproj.FileListAbsolute.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Core.dll.config
12
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Core.dll
23
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Core.pdb
34
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Data.dll
@@ -8,6 +9,6 @@ O:\Projects\MpImport\MpMigrate.Core\bin\Release\MailEnable.Administration.dll
89
O:\Projects\MpImport\MpMigrate.Core\bin\Release\Newtonsoft.Json.dll
910
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Data.pdb
1011
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.MaestroPanel.Api.pdb
12+
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.csprojResolveAssemblyReference.cache
1113
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.dll
1214
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.pdb
13-
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.csprojResolveAssemblyReference.cache

0 commit comments

Comments
 (0)