mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	Server app update on launch
This commit is contained in:
		
							parent
							
								
									3abf1f7ed2
								
							
						
					
					
						commit
						60662a0f16
					
				@ -104,6 +104,7 @@
 | 
				
			|||||||
    <Compile Include="ScheduledTasks\IntervalTrigger.cs" />
 | 
					    <Compile Include="ScheduledTasks\IntervalTrigger.cs" />
 | 
				
			||||||
    <Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
 | 
					    <Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
 | 
				
			||||||
    <Compile Include="Security\ISecurityManager.cs" />
 | 
					    <Compile Include="Security\ISecurityManager.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Updates\ApplicationUpdater.cs" />
 | 
				
			||||||
    <Compile Include="Updates\IPackageManager.cs" />
 | 
					    <Compile Include="Updates\IPackageManager.cs" />
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										37
									
								
								MediaBrowser.Common/Updates/ApplicationUpdater.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								MediaBrowser.Common/Updates/ApplicationUpdater.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Diagnostics;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using MediaBrowser.Common.Kernel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace MediaBrowser.Common.Updates
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public enum MBApplication
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        MBServer,
 | 
				
			||||||
 | 
					        MBTheater
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// <summary>
 | 
				
			||||||
 | 
					    /// Update the specified application using the specified archive
 | 
				
			||||||
 | 
					    /// </summary>
 | 
				
			||||||
 | 
					    public class ApplicationUpdater
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        private const string UpdaterExe = "Mediabrowser.Installer.exe";
 | 
				
			||||||
 | 
					        public void UpdateApplication(MBApplication app, IApplicationPaths appPaths, string archive)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Use our installer passing it the specific archive
 | 
				
			||||||
 | 
					            // We need to copy to a temp directory and execute it there
 | 
				
			||||||
 | 
					            var source = Path.Combine(appPaths.ProgramSystemPath, UpdaterExe);
 | 
				
			||||||
 | 
					            var target = Path.Combine(Path.GetTempPath(), UpdaterExe);
 | 
				
			||||||
 | 
					            var product = app == MBApplication.MBTheater ? "mbt" : "server";
 | 
				
			||||||
 | 
					            File.Copy(source, target, true);
 | 
				
			||||||
 | 
					            Process.Start(UpdaterExe, string.Format("product={0} archive=\"{1}\" caller={2}", product, archive, Process.GetCurrentProcess().Id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // That's it.  The installer will do the work once we exit
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,8 +1,11 @@
 | 
				
			|||||||
using MediaBrowser.ClickOnce;
 | 
					using System.IO;
 | 
				
			||||||
 | 
					using MediaBrowser.Common.Constants;
 | 
				
			||||||
using MediaBrowser.Common.Kernel;
 | 
					using MediaBrowser.Common.Kernel;
 | 
				
			||||||
 | 
					using MediaBrowser.Common.Updates;
 | 
				
			||||||
using MediaBrowser.Controller;
 | 
					using MediaBrowser.Controller;
 | 
				
			||||||
using MediaBrowser.Controller.Entities;
 | 
					using MediaBrowser.Controller.Entities;
 | 
				
			||||||
using MediaBrowser.Model.Logging;
 | 
					using MediaBrowser.Model.Logging;
 | 
				
			||||||
 | 
					using MediaBrowser.Server.Implementations;
 | 
				
			||||||
using Microsoft.Win32;
 | 
					using Microsoft.Win32;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Diagnostics;
 | 
					using System.Diagnostics;
 | 
				
			||||||
@ -27,6 +30,25 @@ namespace MediaBrowser.ServerApplication
 | 
				
			|||||||
        [STAThread]
 | 
					        [STAThread]
 | 
				
			||||||
        public static void Main()
 | 
					        public static void Main()
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            // Look for the existence of an update archive
 | 
				
			||||||
 | 
					            var appPaths = new ServerApplicationPaths();
 | 
				
			||||||
 | 
					            var updateArchive = Path.Combine(appPaths.TempUpdatePath, Constants.MBServerPkgName + ".zip");
 | 
				
			||||||
 | 
					            if (File.Exists(updateArchive))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // Update is there - execute update
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    new ApplicationUpdater().UpdateApplication(MBApplication.MBServer, appPaths, updateArchive);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    // And just let the app exit so it can update
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (Exception e)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    MessageBox.Show(string.Format("Error attempting to update application.\n\n{0}\n\n{1}", e.GetType().Name, e.Message));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var application = new App();
 | 
					            var application = new App();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            application.Run();
 | 
					            application.Run();
 | 
				
			||||||
 | 
				
			|||||||
@ -375,6 +375,7 @@ xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstall
 | 
				
			|||||||
xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe.config" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
					xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe.config" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
				
			||||||
xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstaller.exe" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
					xcopy "$(SolutionDir)Mediabrowser.Uninstaller\bin\Release\MediaBrowser.Uninstaller.exe" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
				
			||||||
xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
					xcopy "$(SolutionDir)Mediabrowser.Uninstaller.Execute\bin\Release\MediaBrowser.Uninstaller.Execute.exe" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
				
			||||||
 | 
					xcopy "$(SolutionDir)Mediabrowser.Installer\bin\Release\MediaBrowser.Installer.exe" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
				
			||||||
 | 
					
 | 
				
			||||||
xcopy "$(TargetDir)$(TargetFileName).config" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
					xcopy "$(TargetDir)$(TargetFileName).config" "$(SolutionDir)..\Deploy\Server\System\" /y
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -253,7 +253,4 @@ Global
 | 
				
			|||||||
	GlobalSection(SolutionProperties) = preSolution
 | 
						GlobalSection(SolutionProperties) = preSolution
 | 
				
			||||||
		HideSolutionNode = FALSE
 | 
							HideSolutionNode = FALSE
 | 
				
			||||||
	EndGlobalSection
 | 
						EndGlobalSection
 | 
				
			||||||
	GlobalSection(Performance) = preSolution
 | 
					 | 
				
			||||||
		HasPerformanceSessions = true
 | 
					 | 
				
			||||||
	EndGlobalSection
 | 
					 | 
				
			||||||
EndGlobal
 | 
					EndGlobal
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user