This repository has been archived on 2024-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
docker-mediawiki/build/scripts/config_placeholder_replace.php

39 lines
966 B
PHP
Raw Permalink Normal View History

2022-12-02 21:14:14 +02:00
<?php
if ($argc != 3) {
die('error: invalid arg count');
}
$config_path = $argv[1];
$file_path = $argv[2];
$config = json_decode(file_get_contents($config_path), true);
$content = file_get_contents($file_path);
foreach ($config as $key => $value) {
/**
* Transform from json to native config types
*/
// switch ($key) {
// case 'POSTGREY_WHITELIST_DOMAINS':
// $value = implode("\n", $value);
// break;
// case 'POSTFIXADMIN_SETUP_PASSWORD':
// $value = password_hash($value, '2y');
// break;
// case 'ROUNDCUBE_PLUGIN_ALIAS_ADDRESSBOOK_DOMAINS':
// $value = json_encode($value);
// break;
// case 'ROUNDCUBE_PLUGIN_ALIAS_ADDRESSBOOK_USERS':
// $value = json_encode($value);
// break;
// case 'ROUNDCUBE_PLUGIN_X2FA_ENABLED_METHODS':
// $value = json_encode($value);
// break;
// }
$content = str_replace('{{' . $key . '}}', $value, $content);
}
exit(file_put_contents($file_path, $content) === false ? 1 : 0);