diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 708e42960d..80ac37d527 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -193,6 +193,11 @@ namespace MediaBrowser.Common.Implementations
}
}
+ public virtual string OperatingSystemDisplayName
+ {
+ get { return Environment.OSVersion.VersionString; }
+ }
+
///
/// Initializes a new instance of the class.
///
diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
index 5ebc1e4c55..2c387a4ddf 100644
--- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
+++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs
@@ -208,7 +208,7 @@ namespace MediaBrowser.Common.Implementations.Security
{ "systemid", _appHost.SystemId },
{ "mb2equiv", mb2Equivalent },
{ "ver", version },
- { "platform", Environment.OSVersion.VersionString },
+ { "platform", _appHost.OperatingSystemDisplayName },
{ "isservice", _appHost.IsRunningAsService.ToString().ToLower() }
};
diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs
index 26e556b1e0..c843e828b2 100644
--- a/MediaBrowser.Common/IApplicationHost.cs
+++ b/MediaBrowser.Common/IApplicationHost.cs
@@ -13,6 +13,12 @@ namespace MediaBrowser.Common
///
public interface IApplicationHost
{
+ ///
+ /// Gets the display name of the operating system.
+ ///
+ /// The display name of the operating system.
+ string OperatingSystemDisplayName { get; }
+
///
/// Gets the name.
///
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs
index a736df9778..85410faf2b 100644
--- a/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs
+++ b/MediaBrowser.Server.Implementations/EntryPoints/UsageReporter.cs
@@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{ "serverid", _applicationHost.SystemId },
{ "deviceid", _applicationHost.SystemId },
{ "ver", _applicationHost.ApplicationVersion.ToString() },
- { "platform", Environment.OSVersion.VersionString },
+ { "platform", _applicationHost.OperatingSystemDisplayName },
{ "isservice", _applicationHost.IsRunningAsService.ToString().ToLower()}
};
diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
index 449b9acaf8..01c4cc2912 100644
--- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
+++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj
@@ -69,6 +69,7 @@
Properties\SharedVersion.cs
+
diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
new file mode 100644
index 0000000000..ce81326fb9
--- /dev/null
+++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
@@ -0,0 +1,193 @@
+using MediaBrowser.Common.Net;
+using MediaBrowser.IsoMounter;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Server.Mono.Networking;
+using MediaBrowser.Server.Startup.Common;
+using Mono.Unix.Native;
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Text.RegularExpressions;
+
+namespace MediaBrowser.Server.Mono.Native
+{
+ public abstract class BaseMonoApp : INativeApp
+ {
+ ///
+ /// Shutdowns this instance.
+ ///
+ public abstract void Shutdown();
+
+ ///
+ /// Restarts this instance.
+ ///
+ public void Restart()
+ {
+
+ }
+
+ ///
+ /// Determines whether this instance [can self restart].
+ ///
+ /// true if this instance [can self restart]; otherwise, false.
+ public bool CanSelfRestart
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Gets a value indicating whether this instance can self update.
+ ///
+ /// true if this instance can self update; otherwise, false.
+ public bool CanSelfUpdate
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool SupportsAutoRunAtStartup
+ {
+ get { return false; }
+ }
+
+ public void PreventSystemStandby()
+ {
+
+ }
+
+ public List GetAssembliesWithParts()
+ {
+ var list = new List();
+
+ if (Environment.OperatingSystem == Startup.Common.OperatingSystem.Linux)
+ {
+ list.AddRange(GetLinuxAssemblies());
+ }
+
+ list.Add(GetType().Assembly);
+
+ return list;
+ }
+
+ private IEnumerable GetLinuxAssemblies()
+ {
+ var list = new List();
+
+ list.Add(typeof(LinuxIsoManager).Assembly);
+
+ return list;
+ }
+
+ public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
+ {
+ }
+
+ private NativeEnvironment _nativeEnvironment;
+ public NativeEnvironment Environment
+ {
+ get { return _nativeEnvironment ?? (_nativeEnvironment = GetEnvironmentInfo()); }
+ }
+
+ public bool SupportsRunningAsService
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public bool IsRunningAsService
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public void ConfigureAutoRun(bool autorun)
+ {
+ }
+
+ public INetworkManager CreateNetworkManager(ILogger logger)
+ {
+ return new NetworkManager(logger);
+ }
+
+ private NativeEnvironment GetEnvironmentInfo()
+ {
+ var info = new NativeEnvironment
+ {
+ OperatingSystem = Startup.Common.OperatingSystem.Linux
+ };
+
+ var uname = GetUnixName();
+
+ var sysName = uname.sysname ?? string.Empty;
+
+ if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
+ {
+ info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
+ }
+ else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
+ {
+ info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
+ }
+ else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
+ {
+ // TODO: How to detect BSD?
+ info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
+ }
+
+ var archX86 = new Regex("(i|I)[3-6]86");
+
+ if (archX86.IsMatch(uname.machine))
+ {
+ info.SystemArchitecture = Architecture.X86;
+ }
+ else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
+ {
+ info.SystemArchitecture = Architecture.X86_X64;
+ }
+ else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
+ {
+ info.SystemArchitecture = Architecture.Arm;
+ }
+
+ info.OperatingSystemVersionString = string.IsNullOrWhiteSpace(sysName) ?
+ System.Environment.OSVersion.VersionString :
+ sysName;
+
+ return info;
+ }
+
+ private NativeApp.Uname _unixName;
+ private NativeApp.Uname GetUnixName()
+ {
+ if (_unixName == null)
+ {
+ var uname = new NativeApp.Uname();
+ Utsname utsname;
+ var callResult = Syscall.uname(out utsname);
+ if (callResult == 0)
+ {
+ uname.sysname = utsname.sysname;
+ uname.machine = utsname.machine;
+ }
+
+ _unixName = uname;
+ }
+ return _unixName;
+ }
+
+ public class Uname
+ {
+ public string sysname = string.Empty;
+ public string machine = string.Empty;
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Mono/Native/NativeApp.cs b/MediaBrowser.Server.Mono/Native/NativeApp.cs
index 541b2bd7dd..b71b74a662 100644
--- a/MediaBrowser.Server.Mono/Native/NativeApp.cs
+++ b/MediaBrowser.Server.Mono/Native/NativeApp.cs
@@ -1,189 +1,17 @@
-using MediaBrowser.Common.Net;
-using MediaBrowser.IsoMounter;
-using MediaBrowser.Model.Logging;
-using MediaBrowser.Server.Mono.Networking;
-using MediaBrowser.Server.Startup.Common;
-using Mono.Unix.Native;
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Text.RegularExpressions;
-
+
namespace MediaBrowser.Server.Mono.Native
{
///
/// Class NativeApp
///
- public class NativeApp : INativeApp
+ public class NativeApp : BaseMonoApp
{
///
/// Shutdowns this instance.
///
- public void Shutdown()
+ public override void Shutdown()
{
MainClass.Shutdown();
}
-
- ///
- /// Restarts this instance.
- ///
- public void Restart()
- {
-
- }
-
- ///
- /// Determines whether this instance [can self restart].
- ///
- /// true if this instance [can self restart]; otherwise, false.
- public bool CanSelfRestart
- {
- get
- {
- return false;
- }
- }
-
- ///
- /// Gets a value indicating whether this instance can self update.
- ///
- /// true if this instance can self update; otherwise, false.
- public bool CanSelfUpdate
- {
- get
- {
- return false;
- }
- }
-
- public bool SupportsAutoRunAtStartup
- {
- get { return false; }
- }
-
- public void PreventSystemStandby()
- {
-
- }
-
- public List GetAssembliesWithParts()
- {
- var list = new List();
-
- if (Environment.OperatingSystem == Startup.Common.OperatingSystem.Linux)
- {
- list.AddRange(GetLinuxAssemblies());
- }
-
- list.Add(GetType().Assembly);
-
- return list;
- }
-
- private List GetLinuxAssemblies()
- {
- var list = new List();
-
- list.Add(typeof(LinuxIsoManager).Assembly);
-
- return list;
- }
-
- public void AuthorizeServer(int httpServerPort, string httpServerUrlPrefix, int udpPort, string tempDirectory)
- {
- }
-
- private NativeEnvironment _nativeEnvironment;
- public NativeEnvironment Environment
- {
- get { return _nativeEnvironment ?? (_nativeEnvironment = GetEnvironmentInfo()); }
- }
-
- public bool SupportsRunningAsService
- {
- get
- {
- return false;
- }
- }
-
- public bool IsRunningAsService
- {
- get
- {
- return false;
- }
- }
-
- public void ConfigureAutoRun(bool autorun)
- {
- }
-
- public INetworkManager CreateNetworkManager(ILogger logger)
- {
- return new NetworkManager(logger);
- }
-
- private NativeEnvironment GetEnvironmentInfo()
- {
- var info = new NativeEnvironment
- {
- OperatingSystem = Startup.Common.OperatingSystem.Linux
- };
-
- var uname = GetUnixName();
-
- var sysName = uname.sysname ?? string.Empty;
-
- if (string.Equals(sysName, "Darwin", StringComparison.OrdinalIgnoreCase))
- {
- info.OperatingSystem = Startup.Common.OperatingSystem.Osx;
- }
- else if (string.Equals(sysName, "Linux", StringComparison.OrdinalIgnoreCase))
- {
- info.OperatingSystem = Startup.Common.OperatingSystem.Linux;
- }
- else if (string.Equals(sysName, "BSD", StringComparison.OrdinalIgnoreCase))
- {
- // TODO: How to detect BSD?
- info.OperatingSystem = Startup.Common.OperatingSystem.Bsd;
- }
-
- var archX86 = new Regex("(i|I)[3-6]86");
-
- if (archX86.IsMatch(uname.machine))
- {
- info.SystemArchitecture = Architecture.X86;
- }
- else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase))
- {
- info.SystemArchitecture = Architecture.X86_X64;
- }
- else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase))
- {
- info.SystemArchitecture = Architecture.Arm;
- }
-
- return info;
- }
-
- private static Uname GetUnixName()
- {
- var uname = new Uname();
- Utsname utsname;
- var callResult = Syscall.uname(out utsname);
- if (callResult == 0)
- {
- uname.sysname = utsname.sysname;
- uname.machine = utsname.machine;
- }
- return uname;
- }
-
- public class Uname
- {
- public string sysname = string.Empty;
- public string machine = string.Empty;
- }
}
}
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 1cfdfa3abf..73dcdaacbe 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -266,6 +266,11 @@ namespace MediaBrowser.Server.Startup.Common
}
}
+ public override string OperatingSystemDisplayName
+ {
+ get { return NativeApp.Environment.OperatingSystemVersionString; }
+ }
+
public override bool IsRunningAsService
{
get { return NativeApp.IsRunningAsService; }
@@ -531,7 +536,7 @@ namespace MediaBrowser.Server.Startup.Common
/// Task.
private async Task RegisterMediaEncoder(IProgress progress)
{
- var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager)
+ var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment)
.GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);
new FFmpegValidator(Logger, ApplicationPaths).Validate(info);
@@ -909,7 +914,7 @@ namespace MediaBrowser.Server.Startup.Common
CachePath = ApplicationPaths.CachePath,
MacAddress = GetMacAddress(),
HttpServerPortNumber = HttpServerPort,
- OperatingSystem = Environment.OSVersion.ToString(),
+ OperatingSystem = OperatingSystemDisplayName,
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
WanAddress = ConnectManager.WanApiAddress,
diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
index 2e58e75d87..229fee18d8 100644
--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs
@@ -22,19 +22,21 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
private readonly ILogger _logger;
private readonly IZipClient _zipClient;
private readonly IFileSystem _fileSystem;
+ private readonly NativeEnvironment _environment;
private readonly string[] _fontUrls =
{
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z"
};
- public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem)
+ public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment)
{
_logger = logger;
_appPaths = appPaths;
_httpClient = httpClient;
_zipClient = zipClient;
_fileSystem = fileSystem;
+ _environment = environment;
}
public async Task GetFFMpegInfo(NativeEnvironment environment, StartupOptions options, IProgress progress)
@@ -240,7 +242,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
private void SetFilePermissions(string targetFolder, string file)
{
// Linux: File permission to 666, and user's execute bit
- if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
+ if (_environment.OperatingSystem == OperatingSystem.Bsd || _environment.OperatingSystem == OperatingSystem.Linux || _environment.OperatingSystem == OperatingSystem.Osx)
{
Syscall.chmod(Path.Combine(targetFolder, Path.GetFileName(file)), FilePermissions.DEFFILEMODE | FilePermissions.S_IXUSR);
}
diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/MediaBrowser.Server.Startup.Common/INativeApp.cs
index c41c666657..5042e1cea3 100644
--- a/MediaBrowser.Server.Startup.Common/INativeApp.cs
+++ b/MediaBrowser.Server.Startup.Common/INativeApp.cs
@@ -1,5 +1,4 @@
-using System;
-using MediaBrowser.Common.Net;
+using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
using System.Collections.Generic;
using System.Reflection;
diff --git a/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs b/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs
index df9dacb4c0..5b45afe731 100644
--- a/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs
+++ b/MediaBrowser.Server.Startup.Common/NativeEnvironment.cs
@@ -5,6 +5,7 @@ namespace MediaBrowser.Server.Startup.Common
{
public OperatingSystem OperatingSystem { get; set; }
public Architecture SystemArchitecture { get; set; }
+ public string OperatingSystemVersionString { get; set; }
}
public enum OperatingSystem
diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs
index 8974ca8da6..e1c481d225 100644
--- a/MediaBrowser.ServerApplication/MainStartup.cs
+++ b/MediaBrowser.ServerApplication/MainStartup.cs
@@ -49,7 +49,7 @@ namespace MediaBrowser.ServerApplication
var logger = _logger = logManager.GetLogger("Main");
- BeginLog(logger, appPaths);
+ ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
// Install directly
if (options.ContainsOption("-installservice"))
@@ -188,16 +188,6 @@ namespace MediaBrowser.ServerApplication
}
}
- ///
- /// Begins the log.
- ///
- /// The logger.
- /// The app paths.
- private static void BeginLog(ILogger logger, IApplicationPaths appPaths)
- {
- ApplicationHost.LogEnvironmentInfo(logger, appPaths, true);
- }
-
private static readonly TaskCompletionSource ApplicationTaskCompletionSource = new TaskCompletionSource();
///
diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
index a4d0f74ab6..9a37c268c9 100644
--- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs
+++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs
@@ -33,7 +33,8 @@ namespace MediaBrowser.ServerApplication.Native
return new NativeEnvironment
{
OperatingSystem = OperatingSystem.Windows,
- SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86
+ SystemArchitecture = System.Environment.Is64BitOperatingSystem ? Architecture.X86_X64 : Architecture.X86,
+ OperatingSystemVersionString = System.Environment.OSVersion.VersionString
};
}
}