mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
added optional launch args for the auto updater
This commit is contained in:
parent
defc5a7a91
commit
9165f3f31e
4 changed files with 49 additions and 16 deletions
|
@ -28,6 +28,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MarkdownSharp;
|
using MarkdownSharp;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
|
@ -118,10 +120,23 @@ namespace PlexRequests.UI.Modules.Admin
|
||||||
Analytics.TrackEventAsync(Category.Admin, PlexRequests.Helpers.Analytics.Action.Update, "AutoUpdate", Username, CookieHelper.GetAnalyticClientId(Cookies));
|
Analytics.TrackEventAsync(Category.Admin, PlexRequests.Helpers.Analytics.Action.Update, "AutoUpdate", Username, CookieHelper.GetAnalyticClientId(Cookies));
|
||||||
|
|
||||||
var url = Request.Form["url"];
|
var url = Request.Form["url"];
|
||||||
|
var args = (string)Request.Form["args"].ToString();
|
||||||
|
var lowered = args.ToLower();
|
||||||
|
var appPath = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(typeof(SystemStatusModule)).Location ?? string.Empty) ?? string.Empty, "PlexRequests.Updater.exe");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(lowered))
|
||||||
|
{
|
||||||
|
if (lowered.Contains("plexrequests.exe"))
|
||||||
|
{
|
||||||
|
lowered = lowered.Replace("plexrequests.exe", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var startArgs = string.IsNullOrEmpty(lowered) ? appPath : $"{lowered} Plexrequests.Updater.exe";
|
||||||
|
|
||||||
var startInfo = Type.GetType("Mono.Runtime") != null
|
var startInfo = Type.GetType("Mono.Runtime") != null
|
||||||
? new ProcessStartInfo("mono PlexRequests.Updater.exe") { Arguments = url }
|
? new ProcessStartInfo(startArgs) { Arguments = $"{url} {lowered}", }
|
||||||
: new ProcessStartInfo("PlexRequests.Updater.exe") { Arguments = url };
|
: new ProcessStartInfo(startArgs) { Arguments = $"{url} {lowered}" };
|
||||||
|
|
||||||
Process.Start(startInfo);
|
Process.Start(startInfo);
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
{
|
{
|
||||||
<label class="control-label"><a href="@Model.Status.UpdateUri" target="_blank"><i class="fa fa-check"></i></a></label>
|
<label class="control-label"><a href="@Model.Status.UpdateUri" target="_blank"><i class="fa fa-check"></i></a></label>
|
||||||
<br />
|
<br />
|
||||||
|
<input id="args" class="form-control form-control-custom " placeholder="optional launch arguments e.g. /etc/mono /opt/PlexRequests.exe">
|
||||||
|
<br/>
|
||||||
<button id="autoUpdate" class="btn btn-success-outline">Automatic Update (beta) <i class="fa fa-download"></i></button>
|
<button id="autoUpdate" class="btn btn-success-outline">Automatic Update (beta) <i class="fa fa-download"></i></button>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -92,7 +94,10 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "Post",
|
type: "Post",
|
||||||
url: "autoupdate",
|
url: "autoupdate",
|
||||||
data: { url: "@Model.Status.DownloadUri" },
|
data: {
|
||||||
|
url: "@Model.Status.DownloadUri",
|
||||||
|
args: $('#args').val()
|
||||||
|
},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
error: function () {
|
error: function () {
|
||||||
setTimeout(
|
setTimeout(
|
||||||
|
|
|
@ -8,7 +8,14 @@ namespace PlexRequests.Updater
|
||||||
{
|
{
|
||||||
Console.WriteLine ("Starting PlexRequests .Net updater");
|
Console.WriteLine ("Starting PlexRequests .Net updater");
|
||||||
var s = new Updater();
|
var s = new Updater();
|
||||||
s.Start(args[0]);
|
if (args.Length >= 2)
|
||||||
|
{
|
||||||
|
s.Start(args[0], args[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s.Start(args[0], string.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace PlexRequests.Updater
|
namespace PlexRequests.Updater
|
||||||
|
@ -67,7 +68,7 @@ namespace PlexRequests.Updater
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(string downloadPath)
|
public void Start(string downloadPath, string launchOptions)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -79,6 +80,10 @@ namespace PlexRequests.Updater
|
||||||
Console.WriteLine("Downloading new version");
|
Console.WriteLine("Downloading new version");
|
||||||
using (var client = new WebClient())
|
using (var client = new WebClient())
|
||||||
{
|
{
|
||||||
|
client.DownloadProgressChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{e.ProgressPercentage}%");
|
||||||
|
};
|
||||||
client.DownloadFile(downloadPath, TempPath);
|
client.DownloadFile(downloadPath, TempPath);
|
||||||
}
|
}
|
||||||
Console.WriteLine("Downloaded!");
|
Console.WriteLine("Downloaded!");
|
||||||
|
@ -130,7 +135,7 @@ namespace PlexRequests.Updater
|
||||||
RestoreBackup();
|
RestoreBackup();
|
||||||
}
|
}
|
||||||
|
|
||||||
FinishUpdate();
|
FinishUpdate(launchOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +144,9 @@ namespace PlexRequests.Updater
|
||||||
Console.WriteLine("Backing up the current version");
|
Console.WriteLine("Backing up the current version");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dir = Directory.CreateDirectory("BackupSystem");
|
var applicationPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Updater)).Location ?? string.Empty) ?? string.Empty;
|
||||||
var applicationPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath));
|
|
||||||
|
var dir = Directory.CreateDirectory(Path.Combine(applicationPath, "BackupSystem"));
|
||||||
|
|
||||||
var allfiles = Directory.GetFiles(applicationPath, "*.*", SearchOption.AllDirectories);
|
var allfiles = Directory.GetFiles(applicationPath, "*.*", SearchOption.AllDirectories);
|
||||||
BackupPath = Path.Combine(dir.FullName, "PlexRequestsBackup.zip");
|
BackupPath = Path.Combine(dir.FullName, "PlexRequestsBackup.zip");
|
||||||
|
@ -179,7 +185,9 @@ namespace PlexRequests.Updater
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Directory.CreateDirectory("UpdateTemp");
|
var location = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Updater)).Location ?? string.Empty);
|
||||||
|
var path = Path.Combine(location, "UpdateTemp");
|
||||||
|
return Directory.CreateDirectory(path);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -190,12 +198,10 @@ namespace PlexRequests.Updater
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FinishUpdate()
|
private void FinishUpdate(string launchOptions)
|
||||||
{
|
{
|
||||||
ProcessStartInfo startInfo;
|
var args = Error ? "-u 2" : "-u 1";
|
||||||
startInfo = Type.GetType("Mono.Runtime") != null
|
var startInfo = new ProcessStartInfo($"{launchOptions}PlexRequests.exe") { Arguments = args, UseShellExecute = true };
|
||||||
? new ProcessStartInfo("mono PlexRequests.exe") { Arguments = Error ? "-u 2" : "-u 1" }
|
|
||||||
: new ProcessStartInfo("PlexRequests.exe") { Arguments = Error ? "-u 2" : "-u 1" };
|
|
||||||
|
|
||||||
Process.Start(startInfo);
|
Process.Start(startInfo);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue