mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 21:03:17 -07:00
Added usersname and password option for the updater #1460
This commit is contained in:
parent
c0b716f2b7
commit
22a0e92b63
7 changed files with 52 additions and 37 deletions
|
@ -1,5 +1,7 @@
|
|||
using System.Globalization;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Security;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
|
@ -44,5 +46,24 @@ namespace Ombi.Helpers
|
|||
return string.Join("", (sha1.ComputeHash(Encoding.UTF8.GetBytes(input))).Select(x => x.ToString("x2")).ToArray());
|
||||
}
|
||||
|
||||
|
||||
public static bool IsNullOrEmpty(this string s) => string.IsNullOrEmpty(s);
|
||||
public static bool HasValue(this string s) => !IsNullOrEmpty(s);
|
||||
|
||||
public static SecureString ToSecureString(this string password)
|
||||
{
|
||||
if (password == null)
|
||||
throw new ArgumentNullException(nameof(password));
|
||||
|
||||
var securePassword = new SecureString();
|
||||
|
||||
foreach (var c in password)
|
||||
{
|
||||
securePassword.AppendChar(c);
|
||||
}
|
||||
|
||||
securePassword.MakeReadOnly();
|
||||
return securePassword;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2017 Jamie Rees
|
||||
// File: StringHelpers.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
namespace Ombi.Helpers
|
||||
{
|
||||
public static class StringHelpers
|
||||
{
|
||||
public static bool IsNullOrEmpty(this string s) => string.IsNullOrEmpty(s);
|
||||
public static bool HasValue(this string s) => !IsNullOrEmpty(s);
|
||||
}
|
||||
}
|
|
@ -157,7 +157,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
}
|
||||
// Extract it
|
||||
Ctx.WriteLine("Extracting ZIP");
|
||||
Extract(zipDir, tempPath, extension);
|
||||
Extract(zipDir, tempPath);
|
||||
|
||||
Ctx.WriteLine("Finished Extracting files");
|
||||
Ctx.WriteLine("Starting the Ombi.Updater process");
|
||||
|
@ -175,6 +175,14 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
Arguments = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + " " + extension,
|
||||
WorkingDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TempUpdate"),
|
||||
};
|
||||
if (settings.Username.HasValue())
|
||||
{
|
||||
start.UserName = settings.Username;
|
||||
}
|
||||
if (settings.Password.HasValue())
|
||||
{
|
||||
start.Password = settings.Password.ToSecureString();
|
||||
}
|
||||
using (var proc = new Process { StartInfo = start })
|
||||
{
|
||||
proc.Start();
|
||||
|
@ -189,7 +197,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
}
|
||||
}
|
||||
|
||||
private void Extract(string zipDir, string tempPath, string osPlat)
|
||||
private void Extract(string zipDir, string tempPath)
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
|
|
|
@ -3,5 +3,7 @@
|
|||
public class UpdateSettings : Settings
|
||||
{
|
||||
public bool AutoUpdateEnabled { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ export interface IOmbiSettings extends ISettings {
|
|||
|
||||
export interface IUpdateSettings extends ISettings {
|
||||
autoUpdateEnabled: boolean;
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface IEmbySettings extends ISettings {
|
||||
|
|
|
@ -20,6 +20,20 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<small>If you are getting any permissions issues, you can specify a user for the update process to run under.</small>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" id="username" formControlName="username">
|
||||
<label for="username">Username</label>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="password" id="password" formControlName="password">
|
||||
<label for="password">Password</label>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ export class UpdateComponent implements OnInit {
|
|||
.subscribe(x => {
|
||||
this.form = this.fb.group({
|
||||
autoUpdateEnabled: [x.autoUpdateEnabled],
|
||||
username: [x.username],
|
||||
password: [x.password],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue