add a script to import config

This commit is contained in:
Simon Vieille 2020-10-23 18:25:08 +02:00
parent 205a72f74d
commit 9f7d6c931e
Signed by untrusted user: deblan
GPG Key ID: 03383D15A1D31745
1 changed files with 24 additions and 0 deletions

24
bin/import_config.php Normal file
View File

@ -0,0 +1,24 @@
<?php
/**
* Imports a json configuration into a sqlite database.
*
* Usage:
* php bin/import_config.php /path/to/config.json /path/to/owncloud.db
*/
$configFile = $argv[1];
$databaseFile = $argv[2];
$content = file_get_contents($configFile);
$config = json_decode($content, true);
$pdo = new \Pdo(sprintf('sqlite:%s', $databaseFile));
$stmt = $pdo->prepare('UPDATE oc_appconfig SET configvalue=:value WHERE configkey=:key and appid=:appId');
foreach ($config as $key => $value) {
$stmt->execute([
'appId' => 'side_menu',
'key' => $key,
'value' => $value,
]);
}