nixpkgs/pkgs/servers/grocy/0001-Define-configs-with-env-vars.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
3.8 KiB
Diff
Raw Normal View History

2023-08-19 11:50:47 +00:00
From 231ee836e357b83cc2fc0a3a977f74839308ec68 Mon Sep 17 00:00:00 2001
2023-08-02 04:44:36 +00:00
From: Ember Keske <git@n0emis.eu>
Date: Wed, 2 Aug 2023 06:36:02 +0200
Subject: [PATCH 1/2] Define configs with env vars
2020-03-06 22:46:07 +00:00
---
2023-08-02 04:44:36 +00:00
app.php | 6 +++---
2020-03-06 22:46:07 +00:00
services/DatabaseService.php | 2 +-
services/FilesService.php | 2 +-
2023-08-02 04:44:36 +00:00
services/StockService.php | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
2020-03-06 22:46:07 +00:00
diff --git a/app.php b/app.php
index bc5b1b3..26f7687 100644
2020-03-06 22:46:07 +00:00
--- a/app.php
+++ b/app.php
2023-08-02 04:44:36 +00:00
@@ -12,7 +12,7 @@ use Slim\Views\Blade;
require_once __DIR__ . '/packages/autoload.php';
2020-02-07 15:34:48 +00:00
// Load config files
-require_once GROCY_DATAPATH . '/config.php';
+require_once getenv('GROCY_CONFIG_FILE');
require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones
require_once __DIR__ . '/helpers/ConfigurationValidator.php';
2020-02-07 15:34:48 +00:00
2023-08-19 11:50:47 +00:00
@@ -64,7 +64,7 @@ $app = AppFactory::create();
2020-03-06 22:46:07 +00:00
$container = $app->getContainer();
2023-08-19 11:50:47 +00:00
$container->set('view', function (Container $container)
{
- return new Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
+ return new Blade(__DIR__ . '/views', getenv('GROCY_CACHE_DIR'));
2020-03-06 22:46:07 +00:00
});
2023-08-19 11:50:47 +00:00
$container->set('UrlManager', function (Container $container)
@@ -106,7 +106,7 @@ $errorMiddleware->setDefaultErrorHandler(
2023-08-02 04:44:36 +00:00
$app->add(new CorsMiddleware($app->getResponseFactory()));
-$app->getRouteCollector()->setCacheFile(GROCY_DATAPATH . '/viewcache/route_cache.php');
+$app->getRouteCollector()->setCacheFile(getenv('GROCY_CACHE_DIR') . '/route_cache.php');
ob_clean(); // No response output before here
$app->run();
diff --git a/controllers/BaseApiController.php b/controllers/BaseApiController.php
index 5941e348..e5b02af4 100644
--- a/controllers/BaseApiController.php
+++ b/controllers/BaseApiController.php
@@ -162,7 +162,7 @@ class BaseApiController extends BaseController
if (self::$htmlPurifierInstance == null)
{
$htmlPurifierConfig = \HTMLPurifier_Config::createDefault();
- $htmlPurifierConfig->set('Cache.SerializerPath', GROCY_DATAPATH . '/viewcache');
+ $htmlPurifierConfig->set('Cache.SerializerPath', getenv('GROCY_CACHE_DIR'));
$htmlPurifierConfig->set('HTML.Allowed', 'div,b,strong,i,em,u,a[href|title|target],iframe[src|width|height|frameborder],ul,ol,li,p[style],br,span[style],img[style|width|height|alt|src],table[border|width|style],tbody,tr,td,th,blockquote,*[style|class|id],h1,h2,h3,h4,h5,h6');
$htmlPurifierConfig->set('Attr.EnableID', true);
$htmlPurifierConfig->set('HTML.SafeIframe', true);
2020-03-06 22:46:07 +00:00
diff --git a/services/DatabaseService.php b/services/DatabaseService.php
index ba79a73..12a851a 100644
2020-03-06 22:46:07 +00:00
--- a/services/DatabaseService.php
+++ b/services/DatabaseService.php
@@ -137,6 +137,6 @@ class DatabaseService
return GROCY_DATAPATH . '/grocy_' . $dbSuffix . '.db';
2020-02-07 15:34:48 +00:00
}
- return GROCY_DATAPATH . '/grocy.db';
+ return getenv('GROCY_DB_FILE');
}
}
2020-03-06 22:46:07 +00:00
diff --git a/services/FilesService.php b/services/FilesService.php
index 7d07035..a6dd4b0 100644
2020-03-06 22:46:07 +00:00
--- a/services/FilesService.php
+++ b/services/FilesService.php
@@ -10,7 +10,7 @@ class FilesService extends BaseService
2020-03-06 22:46:07 +00:00
public function __construct()
{
- $this->StoragePath = GROCY_DATAPATH . '/storage';
2020-02-07 15:34:48 +00:00
+ $this->StoragePath = getenv('GROCY_STORAGE_DIR');
if (!file_exists($this->StoragePath))
2020-02-07 15:34:48 +00:00
{
mkdir($this->StoragePath);
2020-03-06 22:46:07 +00:00
diff --git a/services/StockService.php b/services/StockService.php
index 9f034a5..fd3c0b7 100644
2020-03-06 22:46:07 +00:00
--- a/services/StockService.php
+++ b/services/StockService.php
@@ -1707,7 +1707,7 @@ class StockService extends BaseService
2020-02-07 15:34:48 +00:00
throw new \Exception('No barcode lookup plugin defined');
}
- $path = GROCY_DATAPATH . "/plugins/$pluginName.php";
+ $path = getenv('GROCY_PLUGIN_DIR') . "/$pluginName.php";
2020-02-07 15:34:48 +00:00
if (file_exists($path))
{
require_once $path;
2020-03-06 22:46:07 +00:00
--
2.42.0
2020-03-06 22:46:07 +00:00