diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ae25ce0..91c6d42c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,25 +107,22 @@ jobs: - name: Create the package structure run: | sudo mkdir -p pkg/usr/lib/ - sudo mkdir -p pkg/DEBIAN sudo cp -r --no-preserve ownership dist pkg/usr/lib/kyoo sudo install -Dm 644 deployment/kyoo.service -t pkg/usr/lib/systemd/system/ sudo install -Dm 644 deployment/kyoo.sysusers pkg/usr/lib/sysusers.d/kyoo.conf sudo install -Dm 644 deployment/kyoo.tmpfiles pkg/usr/lib/tmpfiles.d/kyoo.conf - sudo install -Dm 755 deployment/postinst -t pkg/DEBIAN/ - uses: jiro4989/build-deb-action@v2 with: package: kyoo package_root: pkg maintainer: Zoe Roux version: ${{env.version}} - depends: "postgresql, libavutil-dev, libavcodec-dev, libavformat-dev" + depends: "libavutil-dev, libavcodec-dev, libavformat-dev" arch: amd64 desc: ${{env.description}} - name: Build rpm package run: | mkdir out - sudo rm -rf pkg/DEBIAN rpmbuild -bb --buildroot $(pwd)/out --build-in-place --define "_rpmdir $(pwd)/rpm" deployment/kyoo.spec - name: Prepare arch package run: | diff --git a/Kyoo.Abstractions/Controllers/IApplication.cs b/Kyoo.Abstractions/Controllers/IApplication.cs new file mode 100644 index 00000000..95e01454 --- /dev/null +++ b/Kyoo.Abstractions/Controllers/IApplication.cs @@ -0,0 +1,24 @@ +namespace Kyoo.Abstractions.Controllers +{ + /// + /// An interface that allow one to interact with the host and shutdown or restart the app. + /// + public interface IApplication + { + /// + /// Shutdown the process and stop gracefully. + /// + void Shutdown(); + + /// + /// Restart Kyoo from scratch, reload plugins, configurations and restart the web server. + /// + void Restart(); + + /// + /// Get the data directory + /// + /// Retrieve the data directory where runtime data should be stored + string GetDataDirectory(); + } +} \ No newline at end of file diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target index 888c2ed7..490cbebe 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.linux.target @@ -17,4 +17,5 @@ + \ No newline at end of file diff --git a/Kyoo.WindowsHost/Kyoo.WindowsHost.target b/Kyoo.WindowsHost/Kyoo.WindowsHost.target index 70bd90b0..c945d8ad 100644 --- a/Kyoo.WindowsHost/Kyoo.WindowsHost.target +++ b/Kyoo.WindowsHost/Kyoo.WindowsHost.target @@ -11,7 +11,7 @@ - + diff --git a/Kyoo.WindowsHost/Program.cs b/Kyoo.WindowsHost/Program.cs index 46e0d427..c3ea68b4 100644 --- a/Kyoo.WindowsHost/Program.cs +++ b/Kyoo.WindowsHost/Program.cs @@ -1,8 +1,5 @@ -using System; using System.Threading.Tasks; using Autofac; -using Microsoft.Extensions.Hosting; -using Microsoft.Win32; namespace Kyoo.WindowsHost { @@ -13,22 +10,13 @@ namespace Kyoo.WindowsHost /// It adds a system trait for windows and since the host is build as a windows executable instead of a console /// app, the console is not showed. /// - public static async Task Main(string[] args) + public static Task Main(string[] args) { - object dataDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\SDG\Kyoo\Settings", "DataDir", null) - ?? Registry.GetValue(@"HKEY_CURRENT_USER\Software\SDG\Kyoo\Settings", "DataDir", null); - if (dataDir is string data) - Environment.SetEnvironmentVariable("KYOO_DATA_DIR", data); - Kyoo.Program.SetupDataDir(args); - - IHost host = Kyoo.Program.CreateWebHostBuilder(args) - .ConfigureContainer(builder => - { - builder.RegisterType().As().SingleInstance(); - }) - .Build(); - - await Kyoo.Program.StartWithHost(host); + Application application = new(); + return application.Start(args, builder => + { + builder.RegisterType().As().SingleInstance(); + }); } } } \ No newline at end of file diff --git a/Kyoo.WindowsHost/SystemTrait.cs b/Kyoo.WindowsHost/SystemTrait.cs index 6e120682..96525f7d 100644 --- a/Kyoo.WindowsHost/SystemTrait.cs +++ b/Kyoo.WindowsHost/SystemTrait.cs @@ -5,6 +5,7 @@ using System.IO; using System.Threading; using System.Windows.Forms; using Autofac; +using Kyoo.Abstractions.Controllers; using Kyoo.Models.Options; using Microsoft.Extensions.Options; @@ -15,6 +16,11 @@ namespace Kyoo.WindowsHost /// public sealed class SystemTrait : IStartable, IDisposable { + /// + /// The application running Kyoo. + /// + private readonly IApplication _application; + /// /// The options containing the . /// @@ -29,16 +35,18 @@ namespace Kyoo.WindowsHost /// /// Create a new . /// + /// The application running Kyoo. /// The options to use. - public SystemTrait(IOptions options) + public SystemTrait(IApplication application, IOptions options) { + _application = application; _options = options; } /// public void Start() { - _thread = new Thread(() => InternalSystemTrait.Run(_options)) + _thread = new Thread(() => InternalSystemTrait.Run(_application, _options)) { IsBackground = true }; @@ -48,8 +56,7 @@ namespace Kyoo.WindowsHost /// public void Dispose() { - // TODO not sure that the trait is ended and that it does shutdown but the only way to shutdown the - // app anyway is via the Trait's Exit or a Signal so it's fine. + System.Windows.Forms.Application.Exit(); _thread?.Join(); _thread = null; } @@ -61,6 +68,11 @@ namespace Kyoo.WindowsHost private class InternalSystemTrait : ApplicationContext { /// + /// The application running Kyoo. + /// + private readonly IApplication _application; + + /// /// The options containing the . /// private readonly IOptions _options; @@ -73,13 +85,15 @@ namespace Kyoo.WindowsHost /// /// Create a new . Used only by . /// + /// The application running Kyoo. /// The option containing the public url. - private InternalSystemTrait(IOptions options) + private InternalSystemTrait(IApplication application, IOptions options) { + _application = application; _options = options; AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose(); - Application.ApplicationExit += (_, _) => Dispose(); + System.Windows.Forms.Application.ApplicationExit += (_, _) => Dispose(); _icon = new NotifyIcon(); _icon.Text = "Kyoo"; @@ -96,20 +110,21 @@ namespace Kyoo.WindowsHost _icon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { new ToolStripMenuItem("Open browser", null, (_, _) => { _StartBrowser(); }), - new ToolStripMenuItem("Open logs", null, (_, _) => { Process.Start("explorer.exe", Environment.CurrentDirectory); }), + new ToolStripMenuItem("Open logs", null, (_, _) => { _OpenLogs(); }), new ToolStripSeparator(), - new ToolStripMenuItem("Exit", null, (_, _) => { Environment.Exit(0); }) + new ToolStripMenuItem("Exit", null, (_, _) => { _application.Shutdown(); }) }); } /// /// Run the trait in the current thread, this method does not return while the trait is running. /// + /// The application running Kyoo. /// The options to pass to . - public static void Run(IOptions options) + public static void Run(IApplication application, IOptions options) { - using InternalSystemTrait trait = new(options); - Application.Run(trait); + using InternalSystemTrait trait = new(application, options); + System.Windows.Forms.Application.Run(trait); } /// @@ -134,6 +149,15 @@ namespace Kyoo.WindowsHost }; browser.Start(); } + + /// + /// Open the log directory in windows's explorer. + /// + private void _OpenLogs() + { + string logDir = Path.Combine(_application.GetDataDirectory(), "logs"); + Process.Start("explorer.exe", logDir); + } } } } \ No newline at end of file diff --git a/Kyoo/Application.cs b/Kyoo/Application.cs new file mode 100644 index 00000000..4cc1004d --- /dev/null +++ b/Kyoo/Application.cs @@ -0,0 +1,244 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Autofac; +using Autofac.Extensions.DependencyInjection; +using JetBrains.Annotations; +using Kyoo.Abstractions.Controllers; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Win32; +using Serilog; +using Serilog.Templates; +using Serilog.Templates.Themes; +using ILogger = Serilog.ILogger; + +namespace Kyoo +{ + public class Application : IApplication + { + /// + /// The path to the data directory. + /// + private string _dataDir; + + /// + /// Should the application restart after a shutdown? + /// + private bool _shouldRestart; + + /// + /// The cancellation token source used to allow the app to be shutdown or restarted. + /// + private CancellationTokenSource _tokenSource; + + /// + /// Start the application with the given console args. + /// This is generally called from the Main entrypoint of Kyoo. + /// + /// The console arguments to use for kyoo. + /// A task representing the whole process + public Task Start(string[] args) + { + return Start(args, _ => { }); + } + + /// + /// Start the application with the given console args. + /// This is generally called from the Main entrypoint of Kyoo. + /// + /// The console arguments to use for kyoo. + /// A custom action to configure the container before the start + /// A task representing the whole process + public async Task Start(string[] args, Action configure) + { + _dataDir = _SetupDataDir(args); + + LoggerConfiguration config = new(); + _ConfigureLogging(config, null); + Log.Logger = config.CreateBootstrapLogger() + .ForContext(); + + AppDomain.CurrentDomain.ProcessExit += (_, _) => Log.CloseAndFlush(); + AppDomain.CurrentDomain.UnhandledException += (_, ex) + => Log.Fatal(ex.ExceptionObject as Exception, "Unhandled exception"); + + do + { + IHost host = _CreateWebHostBuilder(args) + .ConfigureContainer(configure) + .Build(); + Log.Logger = host.Services.GetRequiredService().ForContext(); + + _tokenSource = new CancellationTokenSource(); + await _StartWithHost(host, _tokenSource.Token); + } + while (_shouldRestart); + } + + /// + public void Shutdown() + { + _shouldRestart = false; + _tokenSource.Cancel(); + } + + /// + public void Restart() + { + _shouldRestart = true; + _tokenSource.Cancel(); + } + + /// + public string GetDataDirectory() + { + return _dataDir; + } + + /// + /// Parse the data directory from environment variables and command line arguments, create it if necessary. + /// Set the current directory to said data folder and place a default configuration file if it does not already + /// exists. + /// + /// The command line arguments + /// The current data directory. + private static string _SetupDataDir(string[] args) + { + Dictionary registry = new(); + + if (OperatingSystem.IsWindows()) + { + object dataDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\SDG\Kyoo\Settings", "DataDir", null) + ?? Registry.GetValue(@"HKEY_CURRENT_USER\Software\SDG\Kyoo\Settings", "DataDir", null); + if (dataDir is string data) + registry.Add("DataDir", data); + } + + IConfiguration parsed = new ConfigurationBuilder() + .AddInMemoryCollection(registry) + .AddEnvironmentVariables() + .AddEnvironmentVariables("KYOO_") + .AddCommandLine(args) + .Build(); + + string path = parsed.GetValue("datadir") + ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Kyoo"); + + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + Environment.CurrentDirectory = path; + + if (!File.Exists(Program.JsonConfigPath)) + File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, Program.JsonConfigPath), + Program.JsonConfigPath); + + return path; + } + + /// + /// Start the given host and log failing exceptions. + /// + /// The host to start. + /// A token to allow one to stop the host. + private async Task _StartWithHost(IHost host, CancellationToken cancellationToken) + { + try + { + Log.Information("Running as {Name}", Environment.UserName); + Log.Information("Data directory: {DataDirectory}", GetDataDirectory()); + await host.RunAsync(cancellationToken); + } + catch (Exception ex) + { + Log.Fatal(ex, "Unhandled exception"); + } + } + + /// + /// Create a a web host + /// + /// Command line parameters that can be handled by kestrel + /// A new web host instance + private IHostBuilder _CreateWebHostBuilder(string[] args) + { + IConfiguration configuration = _SetupConfig(new ConfigurationBuilder(), args).Build(); + + return new HostBuilder() + .UseServiceProviderFactory(new AutofacServiceProviderFactory()) + .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) + .UseEnvironment(Program.Environment) + .ConfigureAppConfiguration(x => _SetupConfig(x, args)) + .UseSerilog((host, builder) => _ConfigureLogging(builder, host.Configuration)) + .ConfigureServices(x => x.AddRouting()) + .ConfigureContainer(x => + { + x.RegisterInstance(this).As().SingleInstance().ExternallyOwned(); + }) + .ConfigureWebHost(x => x + .UseKestrel(options => { options.AddServerHeader = false; }) + .UseIIS() + .UseIISIntegration() + .UseUrls(configuration.GetValue("basics:url")) + .UseStartup(host => PluginsStartup.FromWebHost(host, new LoggerFactory().AddSerilog())) + ); + } + + /// + /// Register settings.json, environment variables and command lines arguments as configuration. + /// + /// The configuration builder to use + /// The command line arguments + /// The modified configuration builder + private IConfigurationBuilder _SetupConfig(IConfigurationBuilder builder, string[] args) + { + return builder.SetBasePath(GetDataDirectory()) + .AddJsonFile(Path.Join(AppDomain.CurrentDomain.BaseDirectory, Program.JsonConfigPath), false, true) + .AddJsonFile(Program.JsonConfigPath, false, true) + .AddEnvironmentVariables() + .AddEnvironmentVariables("KYOO_") + .AddCommandLine(args); + } + + /// + /// Configure the logging. + /// + /// The logger builder to configure. + /// The configuration to read settings from. + private void _ConfigureLogging(LoggerConfiguration builder, [CanBeNull] IConfiguration configuration) + { + if (configuration != null) + { + try + { + builder.ReadFrom.Configuration(configuration, "logging"); + } + catch (Exception ex) + { + Log.Fatal(ex, "Could not read serilog configuration"); + } + } + + const string template = + "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} " + + "({@i:0000000000})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; + + builder + .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) + .WriteTo.Debug() + .WriteTo.File( + path: Path.Combine(GetDataDirectory(), "logs", "log-.log"), + formatter: new ExpressionTemplate(template), + rollingInterval: RollingInterval.Day, + rollOnFileSizeLimit: true + ) + .Enrich.WithThreadId() + .Enrich.FromLogContext(); + } + } +} \ No newline at end of file diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 8c9aa0d5..b53ac5ae 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -21,10 +21,6 @@ transcoder.dll libtranscoder.dylib libtranscoder.so - - $(TranscoderRoot)buildWin - $(TranscoderRoot)buildOSX - $(TranscoderRoot)build @@ -52,7 +48,7 @@ - + diff --git a/Kyoo/Program.cs b/Kyoo/Program.cs index b2844b39..a2c3689a 100644 --- a/Kyoo/Program.cs +++ b/Kyoo/Program.cs @@ -1,17 +1,5 @@ -using System; -using System.IO; using System.Threading.Tasks; -using Autofac.Extensions.DependencyInjection; -using JetBrains.Annotations; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Serilog; -using Serilog.Templates; -using Serilog.Templates.Themes; -using SEnvironment = System.Environment; namespace Kyoo { @@ -29,158 +17,19 @@ namespace Kyoo /// The string representation of the environment used in . /// #if DEBUG - private const string Environment = "Development"; + public const string Environment = "Development"; #else - private const string Environment = "Production"; + public const string Environment = "Production"; #endif - /// - /// Initialize the bootstrap logger to use it anywhere. This is done here so it is called before any method, - /// even if the is not used and this binary is used as a dll. - /// - static Program() - { - LoggerConfiguration config = new(); - _ConfigureLogging(null, config); - Log.Logger = config.CreateBootstrapLogger().ForContext(); - - AppDomain.CurrentDomain.ProcessExit += (_, _) => Log.CloseAndFlush(); - } - /// /// Main function of the program /// /// Command line arguments public static Task Main(string[] args) { - SetupDataDir(args); - return StartWithHost(CreateWebHostBuilder(args).Build()); - } - - /// - /// Start the given host and log failing exceptions. - /// - /// The host to start. - public static async Task StartWithHost(IHost host) - { - try - { - Log.Information("Running as {Name}", System.Environment.UserName); - Log.Information("Data directory: {DataDirectory}", System.Environment.CurrentDirectory); - await host.RunAsync(); - } - catch (Exception ex) - { - Log.Fatal(ex, "Unhandled exception"); - } - } - - /// - /// Register settings.json, environment variables and command lines arguments as configuration. - /// - /// The configuration builder to use - /// The command line arguments - /// The modified configuration builder - private static IConfigurationBuilder SetupConfig(IConfigurationBuilder builder, string[] args) - { - return builder.SetBasePath(System.Environment.CurrentDirectory) - .AddJsonFile(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), false, true) - .AddJsonFile(JsonConfigPath, false, true) - .AddEnvironmentVariables() - .AddEnvironmentVariables("KYOO_") - .AddCommandLine(args); - } - - /// - /// Configure the logging. - /// - /// The host context that contains the configuration - /// The logger builder to configure. - private static void _ConfigureLogging([CanBeNull] HostBuilderContext context, LoggerConfiguration builder) - { - if (context != null) - { - try - { - builder.ReadFrom.Configuration(context.Configuration, "logging"); - } - catch (Exception ex) - { - Log.Fatal(ex, "Could not read serilog configuration"); - } - } - - const string template = - "[{@t:HH:mm:ss} {@l:u3} {Substring(SourceContext, LastIndexOf(SourceContext, '.') + 1), 15} " - + "({@i:0000000000})] {@m}{#if not EndsWith(@m, '\n')}\n{#end}{@x}"; - - builder - .WriteTo.Console(new ExpressionTemplate(template, theme: TemplateTheme.Code)) - .WriteTo.Debug() - .WriteTo.File( - path: "logs/log-.log", - formatter: new ExpressionTemplate(template), - rollingInterval: RollingInterval.Day, - rollOnFileSizeLimit: true - ) - .Enrich.WithThreadId() - .Enrich.FromLogContext(); - } - - /// - /// Create a a web host - /// - /// Command line parameters that can be handled by kestrel - /// A new web host instance - public static IHostBuilder CreateWebHostBuilder(string[] args) - { - IConfiguration configuration = SetupConfig(new ConfigurationBuilder(), args).Build(); - - return new HostBuilder() - .UseServiceProviderFactory(new AutofacServiceProviderFactory()) - .UseContentRoot(AppDomain.CurrentDomain.BaseDirectory) - .UseEnvironment(Environment) - .ConfigureAppConfiguration(x => SetupConfig(x, args)) - .UseSerilog(_ConfigureLogging) - .ConfigureServices(x => x.AddRouting()) - .ConfigureWebHost(x => x - .UseKestrel(options => { options.AddServerHeader = false; }) - .UseIIS() - .UseIISIntegration() - .UseUrls(configuration.GetValue("basics:url")) - .UseStartup(host => PluginsStartup.FromWebHost(host, new LoggerFactory().AddSerilog())) - ); - } - - /// - /// Parse the data directory from environment variables and command line arguments, create it if necessary. - /// Set the current directory to said data folder and place a default configuration file if it does not already - /// exists. - /// - /// The command line arguments - public static void SetupDataDir(string[] args) - { - IConfiguration parsed = new ConfigurationBuilder() - .AddEnvironmentVariables() - .AddEnvironmentVariables("KYOO_") - .AddCommandLine(args) - .Build(); - - string path = parsed.GetValue("data_dir"); - if (path == null) - path = Path.Combine(SEnvironment.GetFolderPath(SEnvironment.SpecialFolder.LocalApplicationData), "Kyoo"); - - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); - SEnvironment.CurrentDirectory = path; - - if (!File.Exists(JsonConfigPath)) - File.Copy(Path.Join(AppDomain.CurrentDomain.BaseDirectory, JsonConfigPath), JsonConfigPath); + Application application = new(); + return application.Start(args); } } - - /// - /// An useless class only used to have a logger in the main. - /// - internal class Application {} } diff --git a/deployment/PKGBUILD b/deployment/PKGBUILD index 005865a1..e1763fd2 100644 --- a/deployment/PKGBUILD +++ b/deployment/PKGBUILD @@ -8,7 +8,7 @@ arch=("i686" "x86_64" "armv6h") url="https://github.com/AnonymusRaccoon/Kyoo" license=("GPLv3") groups=() -depends=("dotnet-runtime>=5" "aspnet-runtime>=5" "postgresql" "ffmpeg") +depends=("dotnet-runtime>=5" "aspnet-runtime>=5" "ffmpeg") makedepends=("dotnet-sdk>=5" "cmake" "gcc" "make" "npm" "git") install="kyoo.install" source=("git+https://github.com/AnonymusRaccoon/Kyoo" #tag=v${pkgver} @@ -30,7 +30,7 @@ build() { # cd "Kyoo-$pkgver" cd "Kyoo" export DOTNET_CLI_TELEMETRY_OPTOUT=1 - dotnet publish -c Release -o "$srcdir/output" Kyoo + dotnet publish -c Release -o "$srcdir/output" Kyoo } package() { diff --git a/deployment/PKGBUILD.github b/deployment/PKGBUILD.github index 1fbdaa3d..fa5403a1 100644 --- a/deployment/PKGBUILD.github +++ b/deployment/PKGBUILD.github @@ -8,7 +8,7 @@ arch=("i686" "x86_64" "armv6h") url="https://github.com/AnonymusRaccoon/Kyoo" license=("GPLv3") groups=() -depends=("postgresql" "ffmpeg") +depends=("ffmpeg") makedepends=() install="kyoo.install" # The output folder is needed but we can't use directory in the source array. diff --git a/deployment/kyoo.install b/deployment/kyoo.install deleted file mode 100644 index 080047de..00000000 --- a/deployment/kyoo.install +++ /dev/null @@ -1,11 +0,0 @@ -post_install() { - sudo -u postgres psql <<- "EOF" - DO $$ - BEGIN - CREATE ROLE kyoo WITH CREATEDB LOGIN PASSWORD 'kyooPassword'; - EXCEPTION WHEN DUPLICATE_OBJECT THEN - RAISE NOTICE 'not creating role kyoo -- it already exists'; - END - $$; - EOF -} \ No newline at end of file diff --git a/deployment/kyoo.service b/deployment/kyoo.service index 88b91542..a53b1967 100644 --- a/deployment/kyoo.service +++ b/deployment/kyoo.service @@ -5,7 +5,7 @@ After=network.target [Service] User=kyoo -Environment=KYOO_DATA_DIR=/var/lib/kyoo +Environment=KYOO_DATADIR=/var/lib/kyoo ExecStart=/usr/lib/kyoo/Kyoo Restart=on-abort TimeoutSec=20 diff --git a/deployment/kyoo.spec b/deployment/kyoo.spec index 6cf1c4a2..b59e907e 100644 --- a/deployment/kyoo.spec +++ b/deployment/kyoo.spec @@ -7,7 +7,7 @@ Summary: A media browser URL: https://github.com/AnonymusRaccoon/Kyoo License: GPL-3.0 BuildArch: x86_64 -Requires: postgresql-server ffmpeg-devel +Requires: ffmpeg-devel AutoReqProv: no %description @@ -24,17 +24,3 @@ rm -rf %{buildroot} /usr/lib/systemd/system/* /usr/lib/sysusers.d/kyoo.conf /usr/lib/tmpfiles.d/kyoo.conf - -%post -sudo postgresql-setup --initdb 2> /dev/null || true -sudo systemctl start postgresql -sudo -u postgres psql << "EOF" -DO $$ -BEGIN - CREATE ROLE kyoo WITH CREATEDB LOGIN PASSWORD 'kyooPassword'; - EXCEPTION WHEN DUPLICATE_OBJECT THEN - RAISE NOTICE 'not creating role kyoo -- it already exists'; -END -$$; -EOF - diff --git a/deployment/postinst b/deployment/postinst deleted file mode 100644 index cdf42470..00000000 --- a/deployment/postinst +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -set -e - -sudo -u postgres psql << "EOF" -DO $$ -BEGIN - CREATE ROLE kyoo WITH CREATEDB LOGIN PASSWORD 'kyooPassword'; - EXCEPTION WHEN DUPLICATE_OBJECT THEN - RAISE NOTICE 'not creating role kyoo -- it already exists'; -END -$$; -EOF - -systemd-sysusers -systemd-tmpfiles --create