39 lines
966 B
PHP
39 lines
966 B
PHP
<?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);
|