diff options
| author | 2017-02-25 10:20:59 +0100 | |
|---|---|---|
| committer | 2017-02-25 10:20:59 +0100 | |
| commit | 2e871a0adf131f53dcf345ad2dda73bdf7c1a2c9 (patch) | |
| tree | 2233e1528417ab7860dd3fe8d7a3823d964ea06f /cli | |
| parent | 648fcb63b5170d07ad6d157249be398912da658f (diff) | |
| parent | 3684d201bda997fdbfd4460dae92100ee47dd7ef (diff) | |
Merge branch 'dev' into feature/username-in-cli
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/README.md | 3 | ||||
| -rwxr-xr-x | cli/do-install.php | 5 | ||||
| -rwxr-xr-x | cli/reconfigure.php | 58 |
3 files changed, 64 insertions, 2 deletions
diff --git a/cli/README.md b/cli/README.md index e4d3409a2..5662e2d83 100644 --- a/cli/README.md +++ b/cli/README.md @@ -39,6 +39,9 @@ cd /usr/share/FreshRSS # --db-prefix is an optional prefix in front of the names of the tables. We suggest using 'freshrss_' # This command does not create the default user. Do that with ./cli/create-user.php +./cli/reconfigure.php +# Same parameters as for do-install.php. Used to update an existing installation. + ./cli/create-user.php --user username ( --password 'password' --api-password 'api_password' --language en --email user@example.net --token 'longRandomString' --no-default-feeds ) # --language can be: 'en' (default), 'fr', or one of the [supported languages](../app/i18n/) diff --git a/cli/do-install.php b/cli/do-install.php index 064a64ab2..c2f5b286d 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -13,6 +13,7 @@ $params = array( 'auth_type:', 'api_enabled', 'allow_robots', + 'disable_update', ); $dBparams = array( @@ -31,7 +32,7 @@ if (empty($options['default_user'])) { " --environment production --base_url https://rss.example.net/" . " --title FreshRSS --allow_anonymous --api_enabled" . " --db-type mysql --db-host localhost:3306 --db-user freshrss --db-password dbPassword123" . - " --db-base freshrss --db-prefix freshrss_ )"); + " --db-base freshrss --db-prefix freshrss_ --disable_update )"); } fwrite(STDERR, 'FreshRSS install…' . "\n"); @@ -73,7 +74,7 @@ if ((!empty($config['base_url'])) && server_is_public($config['base_url'])) { foreach ($dBparams as $dBparam) { $dBparam = rtrim($dBparam, ':'); - if (!empty($options[$dBparam])) { + if (isset($options[$dBparam])) { $param = substr($dBparam, strlen('db-')); $config['db'][$param] = $options[$dBparam]; } 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(); |
