2016-11-13 05:33:51 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Reflection;
|
2017-02-26 22:47:52 +01:00
|
|
|
|
using Emby.Server.CinemaMode;
|
2017-02-20 21:50:58 +01:00
|
|
|
|
using Emby.Server.Connect;
|
2016-11-13 05:33:51 +01:00
|
|
|
|
using Emby.Server.Core;
|
2016-11-18 22:06:00 +01:00
|
|
|
|
using Emby.Server.Implementations;
|
2017-02-23 20:13:07 +01:00
|
|
|
|
using Emby.Server.Sync;
|
2017-02-20 21:50:58 +01:00
|
|
|
|
using MediaBrowser.Controller.Connect;
|
2017-02-23 20:13:07 +01:00
|
|
|
|
using MediaBrowser.Controller.Sync;
|
2016-11-13 05:33:51 +01:00
|
|
|
|
using MediaBrowser.IsoMounter;
|
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using MediaBrowser.Model.System;
|
2017-04-10 03:51:36 +02:00
|
|
|
|
using MediaBrowser.Model.Updates;
|
|
|
|
|
using MediaBrowser.Server.Startup.Common;
|
2016-11-13 05:33:51 +01:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Mono
|
|
|
|
|
{
|
|
|
|
|
public class MonoAppHost : ApplicationHost
|
|
|
|
|
{
|
|
|
|
|
public MonoAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action<string, string> certificateGenerator, Func<string> defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool CanSelfRestart
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
// A restart script must be provided
|
|
|
|
|
return StartupOptions.ContainsOption("-restartpath");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-20 21:50:58 +01:00
|
|
|
|
protected override IConnectManager CreateConnectManager()
|
|
|
|
|
{
|
|
|
|
|
return new ConnectManager();
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 20:13:07 +01:00
|
|
|
|
protected override ISyncManager CreateSyncManager()
|
|
|
|
|
{
|
|
|
|
|
return new SyncManager();
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-10 03:51:36 +02:00
|
|
|
|
public override PackageVersionClass SystemUpdateLevel
|
|
|
|
|
{
|
|
|
|
|
get { return UpdateLevelHelper.GetSystemUpdateLevel(ConfigurationManager); }
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-13 05:33:51 +01:00
|
|
|
|
protected override void RestartInternal()
|
|
|
|
|
{
|
|
|
|
|
MainClass.Restart(StartupOptions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override List<Assembly> GetAssembliesWithPartsInternal()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<Assembly>();
|
|
|
|
|
|
|
|
|
|
list.Add(GetType().Assembly);
|
|
|
|
|
list.AddRange(GetLinuxAssemblies());
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<Assembly> GetLinuxAssemblies()
|
|
|
|
|
{
|
|
|
|
|
var list = new List<Assembly>();
|
|
|
|
|
|
2017-02-26 22:47:52 +01:00
|
|
|
|
list.Add(typeof(DefaultIntroProvider).Assembly);
|
2016-11-13 05:33:51 +01:00
|
|
|
|
list.Add(typeof(LinuxIsoManager).Assembly);
|
2017-02-20 21:50:58 +01:00
|
|
|
|
list.Add(typeof(ConnectManager).Assembly);
|
2017-02-23 20:13:07 +01:00
|
|
|
|
list.Add(typeof(SyncManager).Assembly);
|
2016-11-13 05:33:51 +01:00
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ShutdownInternal()
|
|
|
|
|
{
|
|
|
|
|
MainClass.Shutdown();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-19 06:52:49 +01:00
|
|
|
|
protected override bool SupportsDualModeSockets
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return GetMonoVersion() >= new Version(4, 6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Version GetMonoVersion()
|
|
|
|
|
{
|
|
|
|
|
Type type = Type.GetType("Mono.Runtime");
|
|
|
|
|
if (type != null)
|
|
|
|
|
{
|
|
|
|
|
MethodInfo displayName = type.GetTypeInfo().GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
|
|
|
|
var displayNameValue = displayName.Invoke(null, null).ToString().Trim().Split(' ')[0];
|
|
|
|
|
|
|
|
|
|
Version version;
|
|
|
|
|
if (Version.TryParse(displayNameValue, out version))
|
|
|
|
|
{
|
|
|
|
|
return version;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Version(1, 0);
|
|
|
|
|
}
|
2016-11-13 05:33:51 +01:00
|
|
|
|
}
|
|
|
|
|
}
|