From 203f2fff127ff618585a7970d150dd46991e3f34 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Wed, 27 Feb 2013 18:53:32 -0500 Subject: [PATCH 01/10] New installer app revision --- MediaBrowser.Installer/MediaBrowser.Installer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Installer/MediaBrowser.Installer.csproj b/MediaBrowser.Installer/MediaBrowser.Installer.csproj index 36769fdb2..0fcb05202 100644 --- a/MediaBrowser.Installer/MediaBrowser.Installer.csproj +++ b/MediaBrowser.Installer/MediaBrowser.Installer.csproj @@ -29,7 +29,7 @@ Media Browser Team Media Browser false - 21 + 23 0.1.1.%2a false true From bbb654c03000adda608c78bcb380369eec35225a Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 11:33:54 -0500 Subject: [PATCH 02/10] Add server shutdown to uninstaller Shutdown still doesn't work on server end --- .../MainWindow.xaml.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs index 9937177a7..702c76bf6 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Net; using System.Reflection; using System.IO; using System.Threading; @@ -78,6 +79,21 @@ namespace MediaBrowser.Uninstaller.Execute if (Product == "Server") { RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk")); + using (var client = new WebClient()) + { + lblHeading.Content = "Shutting Down Server..."; + try + { + client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", ""); + } + catch (WebException ex) + { + if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase)) + { + MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message); + } + } + } } // if the startmenu item is empty now - delete it too if (Directory.GetFiles(startMenu).Length == 0) @@ -99,6 +115,7 @@ namespace MediaBrowser.Uninstaller.Execute var rootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser" + RootSuffix); + lblHeading.Content = "Removing System Files..."; if (cbxRemoveAll.IsChecked == true) { // Just remove our whole directory @@ -107,7 +124,6 @@ namespace MediaBrowser.Uninstaller.Execute else { // First remove the system - lblHeading.Content = "Removing System Files..."; RemovePath(Path.Combine(rootPath, "System")); RemovePath(Path.Combine(rootPath, "MediaTools")); From 18f2ffd92cc98328a70f843be8d993bf6b2eb1ac Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 11:43:00 -0500 Subject: [PATCH 03/10] Don't async the server shutdown in installer This way we can allow them to do it manually if it fails --- MediaBrowser.Installer/MainWindow.xaml.cs | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs index fe672ec07..4268e5757 100644 --- a/MediaBrowser.Installer/MainWindow.xaml.cs +++ b/MediaBrowser.Installer/MainWindow.xaml.cs @@ -114,25 +114,22 @@ namespace MediaBrowser.Installer var version = await GetPackageVersion(); lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr); - // Now in the background - try and shut down the server if that is what we are installing + // Now try and shut down the server if that is what we are installing if (PackageName == "MBServer") { - Task.Run(async () => - { - using (var client = new WebClient()) - { - try - { - await client.UploadStringTaskAsync("http://localhost:8096/mediabrowser/system/shutdown", "").ConfigureAwait(false); - } - catch (WebException e) - { - if (e.GetStatus() == HttpStatusCode.NotFound || e.Message.StartsWith("Unable to connect",StringComparison.OrdinalIgnoreCase)) return; // just wasn't running + using (var client = new WebClient()) + { + try + { + client.UploadString("http://localhost:8096/mediabrowser/System/Shutdown", ""); + } + catch (WebException e) + { + if (e.GetStatus() == HttpStatusCode.NotFound || e.Message.StartsWith("Unable to connect",StringComparison.OrdinalIgnoreCase)) return; // just wasn't running - MessageBox.Show("Error shutting down server.\n\n" + e.GetStatus() + "\n\n" + e.Message); - } - } - }); + MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + e.GetStatus() + "\n\n" + e.Message); + } + } } // Download From cc574074b9375390e3a7252ea97abe89f387861f Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 12:04:25 -0500 Subject: [PATCH 04/10] Only try to shutdown server if actually running --- MediaBrowser.Installer/MainWindow.xaml.cs | 4 ++-- .../MainWindow.xaml.cs | 21 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs index 4268e5757..f3f3c7740 100644 --- a/MediaBrowser.Installer/MainWindow.xaml.cs +++ b/MediaBrowser.Installer/MainWindow.xaml.cs @@ -114,8 +114,8 @@ namespace MediaBrowser.Installer var version = await GetPackageVersion(); lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr); - // Now try and shut down the server if that is what we are installing - if (PackageName == "MBServer") + // Now try and shut down the server if that is what we are installing and it is running + if (PackageName == "MBServer" && Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0) { using (var client = new WebClient()) { diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs index 702c76bf6..9906af273 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs @@ -79,18 +79,21 @@ namespace MediaBrowser.Uninstaller.Execute if (Product == "Server") { RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk")); - using (var client = new WebClient()) + if (Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0) { - lblHeading.Content = "Shutting Down Server..."; - try + using (var client = new WebClient()) { - client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", ""); - } - catch (WebException ex) - { - if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase)) + lblHeading.Content = "Shutting Down Server..."; + try { - MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message); + client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", ""); + } + catch (WebException ex) + { + if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase)) + { + MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message); + } } } } From d3e6dd55350293673e8e494b3d7c4bcd6c79768d Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 12:12:38 -0500 Subject: [PATCH 05/10] MBTheater shutdown code in installer/uninstaller --- MediaBrowser.Installer/MainWindow.xaml.cs | 20 +++++++++++++++++++ .../MainWindow.xaml.cs | 16 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs index f3f3c7740..58d1d11ac 100644 --- a/MediaBrowser.Installer/MainWindow.xaml.cs +++ b/MediaBrowser.Installer/MainWindow.xaml.cs @@ -131,6 +131,26 @@ namespace MediaBrowser.Installer } } } + else + { + if (PackageName == "MBTheater") + { + // Uninstalling MBT - shut it down if it is running + var processes = Process.GetProcessesByName("mediabrowser.ui"); + if (processes.Length > 0) + { + try + { + processes[0].CloseMainWindow(); + } + catch (Exception ex) + { + MessageBox.Show("Unable to shutdown Media Browser Theater. Please ensure it is not running before hitting OK.\n\n" + ex.Message, "Error"); + } + } + + } + } // Download var archive = await DownloadPackage(version); diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs index 9906af273..28eded0b9 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs @@ -98,6 +98,22 @@ namespace MediaBrowser.Uninstaller.Execute } } } + else + { + // Installing MBT - shut it down if it is running + var processes = Process.GetProcessesByName("mediabrowser.ui"); + if (processes.Length > 0) + { + try + { + processes[0].CloseMainWindow(); + } + catch (Exception ex) + { + MessageBox.Show("Unable to shutdown Media Browser Theater. Please ensure it is not running before hitting OK.\n\n" + ex.Message, "Error"); + } + } + } // if the startmenu item is empty now - delete it too if (Directory.GetFiles(startMenu).Length == 0) { From a34c8c7cff0b43818a14fbbee39432e4d267eeec Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 12:27:49 -0500 Subject: [PATCH 06/10] Playing nice doesn't work - kill MBT --- MediaBrowser.Installer/MainWindow.xaml.cs | 6 ++++-- MediaBrowser.Installer/MediaBrowser.Installer.csproj | 2 +- MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs index 58d1d11ac..abcf3a169 100644 --- a/MediaBrowser.Installer/MainWindow.xaml.cs +++ b/MediaBrowser.Installer/MainWindow.xaml.cs @@ -112,11 +112,11 @@ namespace MediaBrowser.Installer // Determine Package version var version = await GetPackageVersion(); - lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr); // Now try and shut down the server if that is what we are installing and it is running if (PackageName == "MBServer" && Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0) { + lblStatus.Content = "Shutting Down Media Browser Server..."; using (var client = new WebClient()) { try @@ -139,9 +139,10 @@ namespace MediaBrowser.Installer var processes = Process.GetProcessesByName("mediabrowser.ui"); if (processes.Length > 0) { + lblStatus.Content = "Shutting Down Media Browser Theater..."; try { - processes[0].CloseMainWindow(); + processes[0].Kill(); } catch (Exception ex) { @@ -153,6 +154,7 @@ namespace MediaBrowser.Installer } // Download + lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr); var archive = await DownloadPackage(version); dlAnimation.StopAnimation(); prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden; diff --git a/MediaBrowser.Installer/MediaBrowser.Installer.csproj b/MediaBrowser.Installer/MediaBrowser.Installer.csproj index 0fcb05202..bc9a53936 100644 --- a/MediaBrowser.Installer/MediaBrowser.Installer.csproj +++ b/MediaBrowser.Installer/MediaBrowser.Installer.csproj @@ -29,7 +29,7 @@ Media Browser Team Media Browser false - 23 + 25 0.1.1.%2a false true diff --git a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs index 28eded0b9..934ff284b 100644 --- a/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs +++ b/MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs @@ -83,7 +83,7 @@ namespace MediaBrowser.Uninstaller.Execute { using (var client = new WebClient()) { - lblHeading.Content = "Shutting Down Server..."; + lblHeading.Content = "Shutting Down Media Browser Server..."; try { client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", ""); @@ -104,9 +104,10 @@ namespace MediaBrowser.Uninstaller.Execute var processes = Process.GetProcessesByName("mediabrowser.ui"); if (processes.Length > 0) { + lblHeading.Content = "Shutting Down Media Browser Theater..."; try { - processes[0].CloseMainWindow(); + processes[0].Kill(); } catch (Exception ex) { From 0180e89310fc5f4f608f4bc186d791ab787faf3e Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 12:28:23 -0500 Subject: [PATCH 07/10] Installer rev change --- MediaBrowser.Installer/MediaBrowser.Installer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Installer/MediaBrowser.Installer.csproj b/MediaBrowser.Installer/MediaBrowser.Installer.csproj index bc9a53936..4bd424e14 100644 --- a/MediaBrowser.Installer/MediaBrowser.Installer.csproj +++ b/MediaBrowser.Installer/MediaBrowser.Installer.csproj @@ -29,7 +29,7 @@ Media Browser Team Media Browser false - 25 + 26 0.1.1.%2a false true From 989bb48596664313df15dc67d43dc5a174562dcd Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 14:29:17 -0500 Subject: [PATCH 08/10] Start on new update routines --- MediaBrowser.Api/PackageService.cs | 5 +---- MediaBrowser.Common/Constants/Constants.cs | 2 +- .../Updates/CheckForUpdateResult.cs | 11 ++++++++++- .../ApplicationHost.cs | 17 ++++++++++++----- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs index 698d7e47f..a45b11e26 100644 --- a/MediaBrowser.Api/PackageService.cs +++ b/MediaBrowser.Api/PackageService.cs @@ -123,10 +123,7 @@ namespace MediaBrowser.Api if (updateCheckResult.IsUpdateAvailable) { - result.Add(new PackageVersionInfo - { - versionStr = updateCheckResult.AvailableVersion.ToString() - }); + result.Add(updateCheckResult.Package); } } diff --git a/MediaBrowser.Common/Constants/Constants.cs b/MediaBrowser.Common/Constants/Constants.cs index e8a347829..676518737 100644 --- a/MediaBrowser.Common/Constants/Constants.cs +++ b/MediaBrowser.Common/Constants/Constants.cs @@ -8,6 +8,6 @@ namespace MediaBrowser.Common.Constants { public static class Constants { - public const string MBAdminUrl = "http://mb3admin.com/admin/"; + public const string MBAdminUrl = "http://www.mb3admin.com/admin/"; } } diff --git a/MediaBrowser.Model/Updates/CheckForUpdateResult.cs b/MediaBrowser.Model/Updates/CheckForUpdateResult.cs index 48c0b398c..c9bc2d6b9 100644 --- a/MediaBrowser.Model/Updates/CheckForUpdateResult.cs +++ b/MediaBrowser.Model/Updates/CheckForUpdateResult.cs @@ -17,6 +17,15 @@ namespace MediaBrowser.Model.Updates /// Gets or sets the available version. /// /// The available version. - public Version AvailableVersion { get; set; } + public Version AvailableVersion + { + get { return Package != null ? Package.version : new Version(0, 0); } + set { } // need this for the serializer + } + + /// + /// Get or sets package information for an available update + /// + public PackageVersionInfo Package { get; set; } } } diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 5ba0485ed..d4b19e872 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -1,4 +1,5 @@ -using BDInfo; +using System.Security; +using BDInfo; using MediaBrowser.ClickOnce; using MediaBrowser.Common.Implementations; using MediaBrowser.Common.Implementations.HttpClientManager; @@ -13,6 +14,8 @@ using MediaBrowser.Common.IO; using MediaBrowser.Common.Kernel; using MediaBrowser.Common.Net; using MediaBrowser.Common.ScheduledTasks; +using MediaBrowser.Common.Security; +using MediaBrowser.Common.Updates; using MediaBrowser.Controller; using MediaBrowser.Controller.Library; using MediaBrowser.IsoMounter; @@ -145,7 +148,7 @@ namespace MediaBrowser.ServerApplication /// true if this instance can self update; otherwise, false. public bool CanSelfUpdate { - get { return ClickOnceHelper.IsNetworkDeployed; } + get { return true; } } /// @@ -154,10 +157,14 @@ namespace MediaBrowser.ServerApplication /// The cancellation token. /// The progress. /// Task{CheckForUpdateResult}. - public Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress) + public async Task CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress progress) { - // Get package manager using Resolve() - return new ApplicationUpdateCheck().CheckForApplicationUpdate(cancellationToken, progress); + var pkgManager = Resolve(); + var availablePackages = await pkgManager.GetAvailablePackages(Resolve(), Resolve(), Kernel.SecurityManager, Kernel.ResourcePools, Resolve(), CancellationToken.None).ConfigureAwait(false); + var version = Kernel.InstallationManager.GetLatestCompatibleVersion(availablePackages, "MBServer", Kernel.Configuration.SystemUpdateLevel); + + return version != null ? new CheckForUpdateResult {AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version} : + new CheckForUpdateResult(); } /// From 34ea03c36a567998ad0964e0824bcf706a578c84 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 14:29:55 -0500 Subject: [PATCH 09/10] Catch error when downloading install package --- MediaBrowser.Installer/MainWindow.xaml.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs index abcf3a169..63e1f5dbd 100644 --- a/MediaBrowser.Installer/MainWindow.xaml.cs +++ b/MediaBrowser.Installer/MainWindow.xaml.cs @@ -154,8 +154,17 @@ namespace MediaBrowser.Installer } // Download + string archive = null; lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr); - var archive = await DownloadPackage(version); + try + { + archive = await DownloadPackage(version); + } + catch (Exception e) + { + SystemClose("Error Downloading Package - " + e.GetType().FullName + "\n\n" + e.Message); + } + dlAnimation.StopAnimation(); prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden; From 759f7fe84210d810685576ae99f6aecc187a24eb Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Feb 2013 14:32:17 -0500 Subject: [PATCH 10/10] Installer rev --- MediaBrowser.Installer/MediaBrowser.Installer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.Installer/MediaBrowser.Installer.csproj b/MediaBrowser.Installer/MediaBrowser.Installer.csproj index 4bd424e14..4149a8ab1 100644 --- a/MediaBrowser.Installer/MediaBrowser.Installer.csproj +++ b/MediaBrowser.Installer/MediaBrowser.Installer.csproj @@ -29,7 +29,7 @@ Media Browser Team Media Browser false - 26 + 28 0.1.1.%2a false true