aboutsummaryrefslogtreecommitdiff
path: root/cli/reconfigure.php
diff options
context:
space:
mode:
authorGravatar Clément <clement@selfhost.fr> 2017-02-25 10:20:35 +0100
committerGravatar Clément <clement@selfhost.fr> 2017-02-25 10:20:35 +0100
commit3684d201bda997fdbfd4460dae92100ee47dd7ef (patch)
tree820d753f57c1c5ce455cbb9a68332be681fe5882 /cli/reconfigure.php
parent2d097bc855dbd1ad06c7c306c05e78a198209084 (diff)
parent30ba0753e3fbb7417766f72010c7dd700567bf64 (diff)
Merge remote-tracking branch 'FreshRSS/dev' into dev
Diffstat (limited to 'cli/reconfigure.php')
-rwxr-xr-xcli/reconfigure.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/cli/reconfigure.php b/cli/reconfigure.php
new file mode 100755
index 000000000..5294dd2df
--- /dev/null
+++ b/cli/reconfigure.php
@@ -0,0 +1,58 @@
+#!/usr/bin/php
+<?php
+require('_cli.php');
+
+$params = array(
+ 'environment:',
+ 'base_url:',
+ 'title:',
+ 'default_user:',
+ 'allow_anonymous',
+ 'allow_anonymous_refresh',
+ 'auth_type:',
+ 'api_enabled',
+ 'allow_robots',
+ 'disable_update',
+ );
+
+$dBparams = array(
+ 'db-type:',
+ 'db-host:',
+ 'db-user:',
+ 'db-password:',
+ 'db-base:',
+ 'db-prefix:',
+ );
+
+$options = getopt('', array_merge($params, $dBparams));
+
+fwrite(STDERR, 'Reconfiguring FreshRSS…' . "\n");
+
+$config = Minz_Configuration::get('system');
+foreach ($params as $param) {
+ $param = rtrim($param, ':');
+ if (isset($options[$param])) {
+ $config->$param = $options[$param] === false ? true : $options[$param];
+ }
+}
+$db = $config->db;
+foreach ($dBparams as $dBparam) {
+ $dBparam = rtrim($dBparam, ':');
+ if (isset($options[$dBparam])) {
+ $param = substr($dBparam, strlen('db-'));
+ $db[$param] = $options[$dBparam];
+ }
+}
+$config->db = $db;
+
+if (!ctype_alnum($config->default_user)) {
+ fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . $config->default_user);
+}
+
+if (isset($config->auth_type) && !in_array($config->auth_type, array('form', 'http_auth', 'none'))) {
+ fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }: ' . $config->auth_type);
+}
+
+$config->save();
+
+done();