]> git.p6c8.net - jirafeau_project.git/commitdiff
fix for #20, added also lang to env variables; added function for associative arrays...
authorBlackstareye <>
Fri, 24 Jan 2025 19:26:29 +0000 (20:26 +0100)
committerBlackstareye <>
Fri, 24 Jan 2025 19:29:41 +0000 (20:29 +0100)
docker/README.md
docker/docker_config.php

index 10ee3224e986b53c79bc7930754b38f78ac1426c..0ee1a9621d2c29f77d0eba868f22514d164a31d0 100644 (file)
@@ -38,6 +38,8 @@ More details about options in `lib/config.original.php`.
 Available options:
 - `ADMIN_PASSWORD`: setup a specific admin password. If not set, a random password will be generated.
 - `ADMIN_IP`: set one or more ip allowed to access admin interface (separated by comma).
+- `LANG`: choose the language for jirafeau (default auto).
+- `AVAILABILITIES`: change the array for availablibilities that the user can select (see `docker-compose.yaml` for an example how to do that). Availability is the time the file should be available before it can be deleted.
 - `WEB_ROOT`: setup a specific domain to point at when generating links (e.g. 'jirafeau.mydomain.com/').
 - `VAR_ROOT`: setup a specific path where to place files. default: '/data'.
 - `FILE_HASH`: can be set to `md5`, `partial_md5` or `random` (default).
index 75c6fb8cca3c58fefe62e53f2ab89d7e1646c3ba..140149e4794213d9694dc177fb2be9a035ad7e9d 100644 (file)
@@ -91,6 +91,28 @@ function env_2_cfg_string_array(&$cfg, $config_name)
     return true;
 }
 
+function env_2_cfg_string_array_key_value(&$cfg, $config_name)
+{
+    $env_name = strtoupper($config_name);
+    $env_string = getenv($env_name);
+    if ($env_string === false) {
+        return;
+    }
+    $result = json_decode($env_string, true);
+    if (json_last_error() === JSON_ERROR_NONE) {
+        // JSON is valid
+        $c = count($result);
+        echo ("setting $config_name array with $c value(s)n\n");
+    } else {
+        echo ("ERROR - invalid json for environment key $config_name \n");
+    } 
+    
+    $cfg[$config_name] = $result;
+    return true;
+}
+
+
+
 function setup_admin_password(&$cfg)
 {
     if (strlen($cfg['admin_password']) > 0) {
@@ -165,6 +187,7 @@ function run_setup(&$cfg)
     env_2_cfg_bool($cfg, 'preview');
     env_2_cfg_string($cfg, 'title', false);
     env_2_cfg_string($cfg, 'organisation');
+    env_2_cfg_string($cfg, 'lang');
     env_2_cfg_string($cfg, 'contactperson');
     env_2_cfg_string($cfg, 'style');
     env_2_cfg_string($cfg, 'availability_default');
@@ -179,6 +202,8 @@ function run_setup(&$cfg)
     env_2_cfg_string_array($cfg, 'admin_ip');
     env_2_cfg_string_array($cfg, 'upload_ip_nopassword');
     env_2_cfg_string_array($cfg, 'proxy_ip');
+    // this is a key value based value
+    env_2_cfg_string_array_key_value($cfg, 'availabilities');
     env_2_cfg_bool($cfg, 'store_uploader_ip');
     env_2_cfg_string($cfg, 'download_password_requirement');
     env_2_cfg_int($cfg, 'download_password_gen_len');

patrick-canterino.de