|
|
@ -49,8 +49,6 @@ namespace Ombi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(HelpOutput(result));
|
|
|
|
Console.WriteLine(HelpOutput(result));
|
|
|
|
if (baseUrl.HasValue())
|
|
|
|
if (baseUrl.HasValue())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -64,82 +62,75 @@ namespace Ombi
|
|
|
|
demoInstance.Demo = demo;
|
|
|
|
demoInstance.Demo = demo;
|
|
|
|
instance.StoragePath = storagePath ?? string.Empty;
|
|
|
|
instance.StoragePath = storagePath ?? string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
services.ConfigureDatabases(null);
|
|
|
|
services.ConfigureDatabases(null);
|
|
|
|
using (var provider = services.BuildServiceProvider())
|
|
|
|
using var provider = services.BuildServiceProvider();
|
|
|
|
{
|
|
|
|
var settingsDb = provider.GetRequiredService<SettingsContext>();
|
|
|
|
var settingsDb = provider.GetRequiredService<SettingsContext>();
|
|
|
|
var ombiDb = provider.GetRequiredService<OmbiContext>();
|
|
|
|
var ombiDb = provider.GetRequiredService<OmbiContext>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (migrate)
|
|
|
|
if (migrate)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine("Migrate in progress...");
|
|
|
|
Console.WriteLine("Migrate in progress...");
|
|
|
|
|
|
|
|
|
|
|
|
var migrationTasks = new List<Task>();
|
|
|
|
var migrationTasks = new List<Task>();
|
|
|
|
var externalDb = provider.GetRequiredService<ExternalContext>();
|
|
|
|
var externalDb = provider.GetRequiredService<ExternalContext>();
|
|
|
|
migrationTasks.Add(settingsDb.Database.MigrateAsync());
|
|
|
|
migrationTasks.Add(settingsDb.Database.MigrateAsync());
|
|
|
|
migrationTasks.Add(ombiDb.Database.MigrateAsync());
|
|
|
|
migrationTasks.Add(ombiDb.Database.MigrateAsync());
|
|
|
|
migrationTasks.Add(externalDb.Database.MigrateAsync());
|
|
|
|
migrationTasks.Add(externalDb.Database.MigrateAsync());
|
|
|
|
|
|
|
|
|
|
|
|
Task.WaitAll(migrationTasks.ToArray());
|
|
|
|
Task.WaitAll(migrationTasks.ToArray());
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Migrate complete.");
|
|
|
|
Console.WriteLine("Migrate complete.");
|
|
|
|
Environment.Exit(0);
|
|
|
|
Environment.Exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var config = await settingsDb.ApplicationConfigurations.ToListAsync();
|
|
|
|
var config = await settingsDb.ApplicationConfigurations.ToListAsync();
|
|
|
|
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
|
|
|
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
|
|
|
var ombiSettingsContent = await settingsDb.Settings.FirstOrDefaultAsync(x => x.SettingsName == "OmbiSettings");
|
|
|
|
var ombiSettingsContent = await settingsDb.Settings.FirstOrDefaultAsync(x => x.SettingsName == "OmbiSettings");
|
|
|
|
var securityToken = config.FirstOrDefault(x => x.Type == ConfigurationTypes.SecurityToken);
|
|
|
|
var securityToken = config.FirstOrDefault(x => x.Type == ConfigurationTypes.SecurityToken);
|
|
|
|
await CheckSecurityToken(securityToken, settingsDb, instance);
|
|
|
|
await CheckSecurityToken(securityToken, settingsDb, instance);
|
|
|
|
if (url == null)
|
|
|
|
if (url == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
url = new ApplicationConfiguration
|
|
|
|
{
|
|
|
|
{
|
|
|
|
url = new ApplicationConfiguration
|
|
|
|
Type = ConfigurationTypes.Url,
|
|
|
|
{
|
|
|
|
Value = "http://*:5000"
|
|
|
|
Type = ConfigurationTypes.Url,
|
|
|
|
};
|
|
|
|
Value = "http://*:5000"
|
|
|
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
|
|
|
};
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
|
|
|
{
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
using var tran = await settingsDb.Database.BeginTransactionAsync();
|
|
|
|
{
|
|
|
|
settingsDb.ApplicationConfigurations.Add(url);
|
|
|
|
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
|
|
|
await settingsDb.SaveChangesAsync();
|
|
|
|
{
|
|
|
|
await tran.CommitAsync();
|
|
|
|
settingsDb.ApplicationConfigurations.Add(url);
|
|
|
|
});
|
|
|
|
await settingsDb.SaveChangesAsync();
|
|
|
|
|
|
|
|
await tran.CommitAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
urlValue = url.Value;
|
|
|
|
urlValue = url.Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!url.Value.Equals(host))
|
|
|
|
if (!url.Value.Equals(host))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
url.Value = UrlArgs;
|
|
|
|
|
|
|
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
|
|
|
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
url.Value = UrlArgs;
|
|
|
|
using var tran = await settingsDb.Database.BeginTransactionAsync();
|
|
|
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
|
|
|
await settingsDb.SaveChangesAsync();
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
await tran.CommitAsync();
|
|
|
|
{
|
|
|
|
});
|
|
|
|
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
await settingsDb.SaveChangesAsync();
|
|
|
|
|
|
|
|
await tran.CommitAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
urlValue = url.Value;
|
|
|
|
urlValue = url.Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (string.IsNullOrEmpty(urlValue))
|
|
|
|
else if (string.IsNullOrEmpty(urlValue))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
urlValue = host;
|
|
|
|
urlValue = host;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await SortOutBaseUrl(baseUrl, settingsDb, ombiSettingsContent);
|
|
|
|
await SortOutBaseUrl(baseUrl, settingsDb, ombiSettingsContent);
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"We are running on {urlValue}");
|
|
|
|
Console.WriteLine($"We are running on {urlValue}");
|
|
|
|
|
|
|
|
|
|
|
|
CreateHostBuilder(args).Build().Run();
|
|
|
|
CreateHostBuilder(args).Build().Run();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static async Task CheckSecurityToken(ApplicationConfiguration securityToken, SettingsContext ctx, StartupSingleton instance)
|
|
|
|
private static async Task CheckSecurityToken(ApplicationConfiguration securityToken, SettingsContext ctx, StartupSingleton instance)
|
|
|
@ -154,12 +145,10 @@ namespace Ombi
|
|
|
|
var strat = ctx.Database.CreateExecutionStrategy();
|
|
|
|
var strat = ctx.Database.CreateExecutionStrategy();
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using (var tran = await ctx.Database.BeginTransactionAsync())
|
|
|
|
using var tran = await ctx.Database.BeginTransactionAsync();
|
|
|
|
{
|
|
|
|
ctx.ApplicationConfigurations.Add(securityToken);
|
|
|
|
ctx.ApplicationConfigurations.Add(securityToken);
|
|
|
|
await ctx.SaveChangesAsync();
|
|
|
|
await ctx.SaveChangesAsync();
|
|
|
|
await tran.CommitAsync();
|
|
|
|
await tran.CommitAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -170,7 +159,7 @@ namespace Ombi
|
|
|
|
Host.CreateDefaultBuilder(args)
|
|
|
|
Host.CreateDefaultBuilder(args)
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
webBuilder.ConfigureKestrel(serverOptions =>
|
|
|
|
webBuilder.ConfigureKestrel(_ =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set properties and call methods on options
|
|
|
|
// Set properties and call methods on options
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -204,12 +193,10 @@ namespace Ombi
|
|
|
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
|
|
|
var strat = settingsDb.Database.CreateExecutionStrategy();
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
await strat.ExecuteAsync(async () =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using (var tran = await settingsDb.Database.BeginTransactionAsync())
|
|
|
|
using var tran = await settingsDb.Database.BeginTransactionAsync();
|
|
|
|
{
|
|
|
|
settingsDb.Add(ombiSettingsContent);
|
|
|
|
settingsDb.Add(ombiSettingsContent);
|
|
|
|
await settingsDb.SaveChangesAsync();
|
|
|
|
await settingsDb.SaveChangesAsync();
|
|
|
|
await tran.CommitAsync();
|
|
|
|
await tran.CommitAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var ombiSettings = JsonConvert.DeserializeObject<OmbiSettings>(ombiSettingsContent.Content);
|
|
|
|
var ombiSettings = JsonConvert.DeserializeObject<OmbiSettings>(ombiSettingsContent.Content);
|
|
|
|