diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-05-23 16:44:15 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-05-23 16:44:15 -0400 |
| commit | d0c9273d679cfec73c10e6f863c5cf9012a3aa2f (patch) | |
| tree | 6c6b595c169911e981ea43882dbcc864f1678d50 /MediaBrowser.ServerApplication | |
| parent | 25e325481db84629fa5b42a4bf8b1cf6f1761057 (diff) | |
install service with Emby name
Diffstat (limited to 'MediaBrowser.ServerApplication')
5 files changed, 44 insertions, 10 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..f918fc37c 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 @@ -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")); } } } |
