Skip to content

Commit

Permalink
added Plesk 17x support
Browse files Browse the repository at this point in the history
  • Loading branch information
c1982 committed Nov 8, 2018
1 parent 9c2700e commit 17b7930
Show file tree
Hide file tree
Showing 9 changed files with 815 additions and 2 deletions.
Binary file modified MpImport.v11.suo
Binary file not shown.
154 changes: 154 additions & 0 deletions MpMigrate.Core/Discovery/Plesk_17_Discover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
namespace MpMigrate.Core.Discovery
{

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

public class Plesk_17_Discover : IDiscovery
{
public string Version()
{
if (Environment.Is64BitOperatingSystem)
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PRODUCT_VERSION");
else
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PRODUCT_VERSION");
}

public string VhostPath()
{
return Path.Combine(Environment.GetEnvironmentVariable("plesk_vhosts", EnvironmentVariableTarget.Machine), "{DOMAIN}", "httpdocs");
}

private DatabaseProviders PleskDatabaseProvider(string databaseProviderName)
{
DatabaseProviders provider = DatabaseProviders.Unknown;

switch (databaseProviderName)
{
case "MySQL":
provider = DatabaseProviders.MYSQL;
break;
case "MsSQL":
provider = DatabaseProviders.MSSQL;
break;
}

return provider;

}

public DatabaseProviders GetDatabaseProvider()
{
var providerName = String.Empty;

if (Environment.Is64BitOperatingSystem)
providerName = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PLESK_DATABASE_PROVIDER_NAME");
else
providerName = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PLESK_DATABASE_PROVIDER_NAME");

return PleskDatabaseProvider(providerName);
}

public string GetDatabaseHost()
{
if (Environment.Is64BitOperatingSystem)
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "MySQL_DB_HOST");
else
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "MySQL_DB_HOST");
}

public int GetDatabasePort()
{
if (Environment.Is64BitOperatingSystem)
return int.Parse(CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "MySQL_DB_PORT"));
else
return int.Parse(CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "MySQL_DB_PORT"));
}

public string GetDatabaseUsername()
{
if (Environment.Is64BitOperatingSystem)
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PLESK_DATABASE_LOGIN");
else
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PLESK_DATABASE_LOGIN");
}

public string GetDatabasePassword()
{
return GetPanelPassword();
}

public string GetDatabaseName()
{
if (Environment.Is64BitOperatingSystem)
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "mySQLDBName");
else
return CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "mySQLDBName");
}

public string GetDatabaseFile()
{
return "";
}

public bool isInstalled()
{
var installed = false;
var check_environment = Environment.GetEnvironmentVariable("plesk_dir", EnvironmentVariableTarget.Machine);

var plesk_version = String.Empty;

if (Environment.Is64BitOperatingSystem)
plesk_version = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "PRODUCT_VERSION");
else
plesk_version = CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "PRODUCT_VERSION");

if (Directory.Exists(check_environment))
if (plesk_version.StartsWith("17"))
installed = true;

return installed;
}

public string GetPanelPassword()
{
var plesk_bin = Environment.GetEnvironmentVariable("plesk_bin", EnvironmentVariableTarget.Machine);

if (!String.IsNullOrEmpty(plesk_bin))
{
var plesksrvclient_exe = Path.Combine(plesk_bin, "plesksrvclient.exe");
CoreHelper.Exec(plesksrvclient_exe, "-get -nogui");

return System.Windows.Forms.Clipboard.GetText();
}
else
{
throw new Exception("Could not determine password: Plesk 17.0");
}
}

public string GetEmailPath()
{
var mailproviderPath = String.Empty;

var mailprovider = Environment.Is64BitOperatingSystem
? CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\PLESK\PSA Config\Config", "MAIL_PROVIDERW_DLL")
: CoreHelper.GetRegistryKeyValue(@"SOFTWARE\PLESK\PSA Config\Config", "MAIL_PROVIDERW_DLL");

var isMailEnable = mailprovider.EndsWith("mailenableproviderw.dll");

if (isMailEnable)
mailproviderPath = Path.Combine(CoreHelper.GetRegistryKeyValue(@"SOFTWARE\Wow6432Node\Mail Enable\Mail Enable", "Mail Root"), "{DOMAIN}", "MAILROOT", "{MAILBOX}");

return mailproviderPath;
}

public string InstallPath()
{
return Environment.GetEnvironmentVariable("plesk_dir", EnvironmentVariableTarget.Machine);
}
}
}
4 changes: 4 additions & 0 deletions MpMigrate.Core/MigrateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum PanelTypes
Plesk_12,
Plesk_10,
Plesk_10x,
Plesk_17x,
MaestroPanel,
Entrenix,
Helm,
Expand Down Expand Up @@ -454,6 +455,9 @@ private void LoadVariations()
variationList.Add(new Tuple<PanelTypes, DatabaseProviders, DboFactory, IDiscovery>
(PanelTypes.Plesk_82, DatabaseProviders.OLEDB_ACCESS, new Plesk_82_Access(), new Plesk_86_Discover()));

variationList.Add(new Tuple<PanelTypes, DatabaseProviders, DboFactory, IDiscovery>
(PanelTypes.Plesk_17x, DatabaseProviders.MYSQL, new Plesk_17_MySql(), new Plesk_17_Discover()));


}

Expand Down
1 change: 1 addition & 0 deletions MpMigrate.Core/MpMigrate.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<Compile Include="Discovery\Plesk_12_Discover.cs" />
<Compile Include="Discovery\Entrenix_Discover.cs" />
<Compile Include="Discovery\Plesk_10_Discover.cs" />
<Compile Include="Discovery\Plesk_17_Discover.cs" />
<Compile Include="Discovery\Plesk_9_Discover.cs" />
<Compile Include="Discovery\MaestroPanelDiscover.cs" />
<Compile Include="Discovery\Plesk_11_Discover.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Core.dll.config
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Core.dll
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Core.pdb
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Data.dll
Expand All @@ -8,6 +9,6 @@ O:\Projects\MpImport\MpMigrate.Core\bin\Release\MailEnable.Administration.dll
O:\Projects\MpImport\MpMigrate.Core\bin\Release\Newtonsoft.Json.dll
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.Data.pdb
O:\Projects\MpImport\MpMigrate.Core\bin\Release\MpMigrate.MaestroPanel.Api.pdb
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.csprojResolveAssemblyReference.cache
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.dll
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.pdb
O:\Projects\MpImport\MpMigrate.Core\obj\Release\MpMigrate.Core.csprojResolveAssemblyReference.cache
Loading

0 comments on commit 17b7930

Please sign in to comment.