mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-27 20:41:54 +00:00
install service with Emby name
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user