]>
git.p6c8.net - jirafeau_project.git/blob - docker/docker_config.php
3 * Jirafeau, your web file repository
4 * Copyright (C) 2020 Jérôme Jutteau <jerome@jutteau.fr>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 define('JIRAFEAU_ROOT', '/www/');
20 define('JIRAFEAU_CFG', JIRAFEAU_ROOT
. 'lib/config.local.php');
22 require(JIRAFEAU_ROOT
. 'lib/settings.php');
23 require(JIRAFEAU_ROOT
. 'lib/functions.php');
24 require(JIRAFEAU_ROOT
. 'lib/lang.php');
26 function env_2_cfg_string(&$cfg, $config_name, $env_name, $default = null)
28 $r = getenv($env_name);
30 if (is_null($default)) {
36 echo("setting $config_name to '$r'\n");
37 $cfg[$config_name] = $r;
41 function setup_admin_password(&$cfg)
43 if (strlen($cfg['admin_password']) > 0) {
46 echo("setting up admin password\n");
47 $p = getenv('ADMIN_PASSWORD');
49 $p = jirafeau_gen_random(20);
50 echo("auto-generated admin password: $p\n");
52 $cfg['admin_password'] = hash('sha256', $p);
56 function set_rights($path)
58 $uid = getenv('USER_ID');
62 $gid = getenv('GROUP_ID');
66 if (!chown($path, $uid)) {
67 echo("setting up user $uid for $path: failed\n");
70 if (!chgrp($path, $gid)) {
71 echo("setting up group $gid for $path: failed\n");
74 if (!chmod($path, 0770)) {
75 echo("setting up permissions $path: failed\n");
81 function setup_var_folder(&$cfg)
83 env_2_cfg_string($cfg, 'var_root', 'VAR_ROOT', '/data/');
84 $var_root = $cfg['var_root'];
85 if (!is_dir($var_root)) {
86 mkdir($var_root, 0770, true);
88 $err = jirafeau_check_var_dir($var_root);
89 if ($err['has_error']) {
90 echo("error: cannot create $var_root folder\n");
93 return set_rights($var_root) &&
94 set_rights($var_root . 'async') &&
95 set_rights($var_root . 'files') &&
96 set_rights($var_root . 'links');
99 // TODO: lots of other options to implement
100 $setup_ok = setup_admin_password($cfg) &&
101 setup_var_folder($cfg);
102 env_2_cfg_string($cfg, 'web_root', 'WEB_ROOT', '');
103 env_2_cfg_string($cfg, 'file_hash', 'FILE_HASH', 'md5');
106 $cfg['installation_done'] = true;
107 jirafeau_export_cfg($cfg);
108 echo("You can now connect to your Jirafeau instance\n");
111 echo("Some Jirafeau options failed");
patrick-canterino.de