add a script to import config
This commit is contained in:
parent
205a72f74d
commit
9f7d6c931e
|
@ -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,
|
||||||
|
]);
|
||||||
|
}
|
Loading…
Reference in New Issue