biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / grocy / 0001-Define-configs-with-env-vars.patch
blob75aa54f9c9c28d435dc3df34f40fc6ed9d9cf427
1 From 231ee836e357b83cc2fc0a3a977f74839308ec68 Mon Sep 17 00:00:00 2001
2 From: Ember Keske <git@n0emis.eu>
3 Date: Wed, 2 Aug 2023 06:36:02 +0200
4 Subject: [PATCH 1/2] Define configs with env vars
6 ---
7 app.php | 6 +++---
8 services/DatabaseService.php | 2 +-
9 services/FilesService.php | 2 +-
10 services/StockService.php | 2 +-
11 4 files changed, 6 insertions(+), 6 deletions(-)
13 diff --git a/app.php b/app.php
14 index bc5b1b3..26f7687 100644
15 --- a/app.php
16 +++ b/app.php
17 @@ -12,7 +12,7 @@ use Slim\Views\Blade;
18 require_once __DIR__ . '/packages/autoload.php';
20 // Load config files
21 -require_once GROCY_DATAPATH . '/config.php';
22 +require_once getenv('GROCY_CONFIG_FILE');
23 require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones
24 require_once __DIR__ . '/helpers/ConfigurationValidator.php';
26 @@ -64,7 +64,7 @@ $app = AppFactory::create();
27 $container = $app->getContainer();
28 $container->set('view', function (Container $container)
30 - return new Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
31 + return new Blade(__DIR__ . '/views', getenv('GROCY_CACHE_DIR'));
32 });
34 $container->set('UrlManager', function (Container $container)
35 @@ -106,7 +106,7 @@ $errorMiddleware->setDefaultErrorHandler(
37 $app->add(new CorsMiddleware($app->getResponseFactory()));
39 -$app->getRouteCollector()->setCacheFile(GROCY_DATAPATH . '/viewcache/route_cache.php');
40 +$app->getRouteCollector()->setCacheFile(getenv('GROCY_CACHE_DIR') . '/route_cache.php');
42 ob_clean(); // No response output before here
43 $app->run();
44 diff --git a/controllers/BaseApiController.php b/controllers/BaseApiController.php
45 index 5941e348..e5b02af4 100644
46 --- a/controllers/BaseApiController.php
47 +++ b/controllers/BaseApiController.php
48 @@ -162,7 +162,7 @@ class BaseApiController extends BaseController
49 if (self::$htmlPurifierInstance == null)
51 $htmlPurifierConfig = \HTMLPurifier_Config::createDefault();
52 - $htmlPurifierConfig->set('Cache.SerializerPath', GROCY_DATAPATH . '/viewcache');
53 + $htmlPurifierConfig->set('Cache.SerializerPath', getenv('GROCY_CACHE_DIR'));
54 $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');
55 $htmlPurifierConfig->set('Attr.EnableID', true);
56 $htmlPurifierConfig->set('HTML.SafeIframe', true);
57 diff --git a/services/DatabaseService.php b/services/DatabaseService.php
58 index ba79a73..12a851a 100644
59 --- a/services/DatabaseService.php
60 +++ b/services/DatabaseService.php
61 @@ -137,6 +137,6 @@ class DatabaseService
62 return GROCY_DATAPATH . '/grocy_' . $dbSuffix . '.db';
65 - return GROCY_DATAPATH . '/grocy.db';
66 + return getenv('GROCY_DB_FILE');
69 diff --git a/services/FilesService.php b/services/FilesService.php
70 index 7d07035..a6dd4b0 100644
71 --- a/services/FilesService.php
72 +++ b/services/FilesService.php
73 @@ -10,7 +10,7 @@ class FilesService extends BaseService
75 public function __construct()
77 - $this->StoragePath = GROCY_DATAPATH . '/storage';
78 + $this->StoragePath = getenv('GROCY_STORAGE_DIR');
79 if (!file_exists($this->StoragePath))
81 mkdir($this->StoragePath);
82 diff --git a/services/StockService.php b/services/StockService.php
83 index 9f034a5..fd3c0b7 100644
84 --- a/services/StockService.php
85 +++ b/services/StockService.php
86 @@ -1707,7 +1707,7 @@ class StockService extends BaseService
87 throw new \Exception('No barcode lookup plugin defined');
90 - $path = GROCY_DATAPATH . "/plugins/$pluginName.php";
91 + $path = getenv('GROCY_PLUGIN_DIR') . "/$pluginName.php";
92 if (file_exists($path))
94 require_once $path;
95 --
96 2.42.0