diff options
Diffstat (limited to 'MediaBrowser.ServerApplication')
| -rw-r--r-- | MediaBrowser.ServerApplication/App.config | 2 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/BackgroundService.cs | 24 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/MainStartup.cs | 11 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/Native/Autorun.cs | 19 |
5 files changed, 46 insertions, 12 deletions
diff --git a/MediaBrowser.ServerApplication/App.config b/MediaBrowser.ServerApplication/App.config index 94dd9ee73..14ce35a96 100644 --- a/MediaBrowser.ServerApplication/App.config +++ b/MediaBrowser.ServerApplication/App.config @@ -13,7 +13,7 @@ </nlog> <appSettings> <add key="DebugProgramDataPath" value="..\..\..\ProgramData-Server" /> - <add key="ReleaseProgramDataPath" value="%ApplicationData%\MediaBrowser-Server" /> + <add key="ReleaseProgramDataPath" value=".." /> <add key="ClientSettingsProvider.ServiceUri" value="" /> </appSettings> <startup useLegacyV2RuntimeActivationPolicy="true"> diff --git a/MediaBrowser.ServerApplication/BackgroundService.cs b/MediaBrowser.ServerApplication/BackgroundService.cs index 019a11e1c..da7537cd7 100644 --- a/MediaBrowser.ServerApplication/BackgroundService.cs +++ b/MediaBrowser.ServerApplication/BackgroundService.cs @@ -1,4 +1,5 @@ using MediaBrowser.Model.Logging; +using System.Linq; using System.ServiceProcess; namespace MediaBrowser.ServerApplication @@ -8,8 +9,25 @@ namespace MediaBrowser.ServerApplication /// </summary> public class BackgroundService : ServiceBase { - public static string Name = "MediaBrowser"; - public static string DisplayName = "Media Browser"; + public static string Name = "Emby"; + public static string DisplayName = "Emby Server"; + + public static string GetExistingServiceName() + { + try + { + if (ServiceController.GetServices().Any(s => s.ServiceName == "MediaBrowser")) + { + return "MediaBrowser"; + } + } + catch + { + return "MediaBrowser"; + } + + return Name; + } private readonly ILogger _logger; @@ -24,7 +42,7 @@ namespace MediaBrowser.ServerApplication CanStop = true; - ServiceName = Name; + ServiceName = GetExistingServiceName(); } /// <summary> diff --git a/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs b/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs index 15cab6c19..08c8a25b9 100644 --- a/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs +++ b/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.ServerApplication DelayedAutoStart = true, - Description = "The windows background service for Media Browser Server.", + Description = "The windows background service for Emby Server.", // Will ensure the network is available ServicesDependedOn = new[] { "LanmanServer", "Tcpip" } diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 6e8774eea..968172bc3 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -370,7 +370,8 @@ namespace MediaBrowser.ServerApplication private static void RunServiceInstallationIfNeeded(string applicationPath) { - var ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == BackgroundService.Name); + var serviceName = BackgroundService.GetExistingServiceName(); + var ctl = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == serviceName); if (ctl == null) { @@ -476,7 +477,7 @@ namespace MediaBrowser.ServerApplication // Update is there - execute update try { - var serviceName = _isRunningAsService ? BackgroundService.Name : string.Empty; + var serviceName = _isRunningAsService ? BackgroundService.GetExistingServiceName() : string.Empty; new ApplicationUpdater().UpdateApplication(appPaths, updateArchive, logger, serviceName); // And just let the app exit so it can update @@ -515,11 +516,11 @@ namespace MediaBrowser.ServerApplication _logger.Info("Hiding server notify icon"); _serverNotifyIcon.Visible = false; - _logger.Info("Executing windows forms restart"); + _logger.Info("Starting new instance"); //Application.Restart(); Process.Start(_appHost.ServerConfigurationManager.ApplicationPaths.ApplicationPath); - _logger.Info("Calling Application.Exit"); + _logger.Info("Calling Environment.Exit"); Environment.Exit(0); } } @@ -539,7 +540,7 @@ namespace MediaBrowser.ServerApplication private static void ShutdownWindowsService() { _logger.Info("Stopping background service"); - var service = new ServiceController(BackgroundService.Name); + var service = new ServiceController(BackgroundService.GetExistingServiceName()); service.Refresh(); diff --git a/MediaBrowser.ServerApplication/Native/Autorun.cs b/MediaBrowser.ServerApplication/Native/Autorun.cs index 593bb7955..dd2a77565 100644 --- a/MediaBrowser.ServerApplication/Native/Autorun.cs +++ b/MediaBrowser.ServerApplication/Native/Autorun.cs @@ -18,17 +18,32 @@ namespace MediaBrowser.ServerApplication.Native { var shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Media Browser 3", "Media Browser Server.lnk"); + if (!Directory.Exists(Path.GetDirectoryName(shortcutPath))) + { + shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Emby", "Emby Server.lnk"); + } + var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); + // Remove lnk from old name + try + { + fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Media Browser Server.lnk")); + } + catch + { + + } + if (autorun) { //Copy our shortut into the startup folder for this user - File.Copy(shortcutPath, Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "MBstartup.lnk"), true); + File.Copy(shortcutPath, Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk"), true); } else { //Remove our shortcut from the startup folder for this user - fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "MBstartup.lnk")); + fileSystem.DeleteFile(Path.Combine(startupPath, Path.GetFileName(shortcutPath) ?? "Emby Server.lnk")); } } } |
