From ab4ece6780cf841f6ce4e89f7b81a1ff1661f615 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 24 Oct 2016 01:41:09 +0200 Subject: CLI do-install https://github.com/FreshRSS/FreshRSS/issues/1095 https://github.com/FreshRSS/FreshRSS/issues/1090 --- cli/do-install.php | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 cli/do-install.php (limited to 'cli/do-install.php') diff --git a/cli/do-install.php b/cli/do-install.php new file mode 100644 index 000000000..5eeedc626 --- /dev/null +++ b/cli/do-install.php @@ -0,0 +1,102 @@ +#!/usr/bin/php + $check) { + if ($check !== 'ok' && $requirement !== 'all') { + $message .= '• ' . $requirement . "\n"; + } + } + fail($message); +} + +if (!ctype_alnum($options['default_user'])) { + fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . $options['default_user']); +} + +if (!in_array($options['auth_type'], array('form', 'http_auth', 'none'))) { + fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }: ' . $options['auth_type']); +} + +$config = array( + 'salt' => generateSalt(), + 'db' => FreshRSS_Context::$system_conf->db, + ); + +foreach ($params as $param) { + $param = rtrim($param, ':'); + if (isset($options[$param])) { + $config[$param] = $options[$param] === false ? true : $options[$param]; + } +} + +if ((!empty($config['base_url'])) && server_is_public($config['base_url'])) { + $config['pubsubhubbub_enabled'] = true; +} + +foreach ($dBparams as $dBparam) { + $dBparam = rtrim($dBparam, ':'); + if (!empty($options[$dBparam])) { + $param = substr($dBparam, strlen('db-')); + $config['db'][$param] = $options[$dBparam]; + } +} + +if (file_put_contents(join_path(DATA_PATH, 'config.php'), " Date: Mon, 24 Oct 2016 01:50:13 +0200 Subject: +x execution rights do-install --- cli/do-install.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 cli/do-install.php (limited to 'cli/do-install.php') diff --git a/cli/do-install.php b/cli/do-install.php old mode 100644 new mode 100755 -- cgit v1.2.3 From a7301a43faeb391138478cb462493c3e025296ea Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 25 Oct 2016 22:35:45 +0200 Subject: A bit more readme --- README.fr.md | 2 +- README.md | 2 +- cli/README.md | 11 +++++++---- cli/do-install.php | 3 +-- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'cli/do-install.php') diff --git a/README.fr.md b/README.fr.md index cd1fef6b4..8efa983e3 100644 --- a/README.fr.md +++ b/README.fr.md @@ -32,7 +32,7 @@ Nous sommes une communauté amicale. * Fonctionne même sur un Raspberry Pi 1 avec des temps de réponse < 1s (testé sur 150 flux, 22k articles) * Serveur Web Apache2 (recommandé), ou nginx, lighttpd (non testé sur les autres) * PHP 5.3.3+ (PHP 5.4+ recommandé, et PHP 5.5+ pour les performances, et PHP 7+ pour d’encore meilleures performances) - * Requis : [DOM](http://php.net/dom), [XML](http://php.net/xml), [PDO_MySQL](http://php.net/pdo-mysql) ou [PDO_SQLite](http://php.net/pdo-sqlite) ou [PDO_PGSQL](http://php.net/pdo-pgsql), [cURL](http://php.net/curl) + * Requis : [cURL](http://php.net/curl), [DOM](http://php.net/dom), [XML](http://php.net/xml), et [PDO_MySQL](http://php.net/pdo-mysql) ou [PDO_SQLite](http://php.net/pdo-sqlite) ou [PDO_PGSQL](http://php.net/pdo-pgsql) * Recommandés : [JSON](http://php.net/json), [GMP](http://php.net/gmp) (pour accès API sur plateformes < 64 bits), [IDN](http://php.net/intl.idn) (pour les noms de domaines internationalisés), [mbstring](http://php.net/mbstring) et/ou [iconv](http://php.net/iconv) (pour conversion d’encodages), [ZIP](http://php.net/zip) (pour import/export), [zlib](http://php.net/zlib) (pour les flux compressés) * MySQL 5.5.3+ (recommandé), ou SQLite 3.7.4+, ou PostgreSQL (experimental) * Un navigateur Web récent tel Firefox, Internet Explorer 11 / Edge, Chrome, Opera, Safari. diff --git a/README.md b/README.md index 4ce6a5566..ecdd19376 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ We are a friendly community. * It even works on Raspberry Pi 1 with response time under a second (tested with 150 feeds, 22k articles) * A web server: Apache2 (recommended), nginx, lighttpd (not tested on others) * PHP 5.3.3+ (PHP 5.4+ recommended, and PHP 5.5+ for performance, and PHP 7 for even higher performance) - * Required extensions: [DOM](http://php.net/dom), [XML](http://php.net/xml), [PDO_MySQL](http://php.net/pdo-mysql) or [PDO_SQLite](http://php.net/pdo-sqlite) or [PDO_PGSQL](http://php.net/pdo-pgsql), [cURL](http://php.net/curl) + * Required extensions: [cURL](http://php.net/curl), [DOM](http://php.net/dom), [XML](http://php.net/xml), and [PDO_MySQL](http://php.net/pdo-mysql) or [PDO_SQLite](http://php.net/pdo-sqlite) or [PDO_PGSQL](http://php.net/pdo-pgsql) * Recommended extensions: [JSON](http://php.net/json), [GMP](http://php.net/gmp) (for API access on platforms < 64 bits), [IDN](http://php.net/intl.idn) (for Internationalized Domain Names), [mbstring](http://php.net/mbstring) and/or [iconv](http://php.net/iconv) (for charset conversion), [ZIP](http://php.net/zip) (for import/export), [zlib](http://php.net/zlib) (for compressed feeds) * MySQL 5.5.3+ (recommended), or SQLite 3.7.4+, or PostgreSQL (experimental) * A recent browser like Firefox, Internet Explorer 11 / Edge, Chrome, Opera, Safari. diff --git a/cli/README.md b/cli/README.md index 3f6cbfe1f..444606b50 100644 --- a/cli/README.md +++ b/cli/README.md @@ -32,11 +32,15 @@ Options in parenthesis are optional. ```sh cd /usr/share/FreshRSS -./cli/do-install.php --default_user admin --auth_type form ( --environment production --base_url https://rss.example.net/ --language en --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 ) -# The default database is SQLite -# Does not create the default user. Do that with ./cli/create-user.php +./cli/do-install.php --default_user admin --auth_type form ( --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 ) +# --auth_type can be: 'form' (recommended), 'http_auth' (using the Web server access control), 'none' (dangerous) +# --db-type can be: 'sqlite' (default), 'mysql' (MySQL or MariaDB), 'pgsql' (PostgreSQL) +# --environment can be: 'production' (default), 'development' (for additional log messages) +# --db-prefix is an optional prefix in front of the names of the tables +# This command does not create the default user. Do that with ./cli/create-user.php ./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/) ./cli/delete-user.php --user username @@ -51,5 +55,4 @@ cd /usr/share/FreshRSS ./cli/export-opml-for-user.php --user username > /path/to/file.opml.xml ./cli/export-zip-for-user.php --user username ( --max-feed-entries 100 ) > /path/to/file.zip - ``` diff --git a/cli/do-install.php b/cli/do-install.php index 5eeedc626..667191680 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -6,7 +6,6 @@ require(LIB_PATH . '/lib_install.php'); $params = array( 'environment:', 'base_url:', - 'language:', 'title:', 'default_user:', 'allow_anonymous', @@ -30,7 +29,7 @@ $options = getopt('', array_merge($params, $dBparams)); if (empty($options['default_user']) || empty($options['auth_type'])) { fail('Usage: ' . basename(__FILE__) . " --default_user admin --auth_type form" . " ( --environment production --base_url https://rss.example.net/" . - " --language en --title FreshRSS --allow_anonymous --api_enabled" . + " --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 )"); } -- cgit v1.2.3 From 829d9997d31929b45384808f7cca343edb00b0d2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 6 Nov 2016 14:04:06 +0100 Subject: Fix small bugs in install Small fixes in install (e.g. better check that DB password works) --- CHANGELOG.md | 1 + app/Models/UserDAO.php | 1 - app/install.php | 4 ++-- cli/README.md | 4 ++-- cli/create-user.php | 3 +++ cli/do-install.php | 12 ++++++------ data/config.default.php | 2 +- lib/lib_install.php | 6 +++++- 8 files changed, 20 insertions(+), 13 deletions(-) (limited to 'cli/do-install.php') diff --git a/CHANGELOG.md b/CHANGELOG.md index 52d95d7bd..9410ac339 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Bug fixing * Fix bug in estimating last user activity [#1358](https://github.com/FreshRSS/FreshRSS/issues/1358) * PostgreSQL: fix bug when updating cached values [#1360](https://github.com/FreshRSS/FreshRSS/issues/1360) + * Fix small bugs in installer [#1363](https://github.com/FreshRSS/FreshRSS/pull/1363) ## 2016-11-02 FreshRSS 1.6.1 diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 190954b1a..32bc6de2f 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -88,7 +88,6 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { if (($username == '') || (!ctype_alnum($username))) { $username = Minz_Session::param('currentUser', '_'); } - Minz_Log::debug('touch ' . $username); return touch(join_path(DATA_PATH , 'users', $username, 'config.php')); } diff --git a/app/install.php b/app/install.php index fcc901713..5c8a6e0e8 100644 --- a/app/install.php +++ b/app/install.php @@ -230,7 +230,7 @@ function saveStep3() { $_SESSION['bd_error'] = ''; header('Location: index.php?step=4'); } else { - $_SESSION['bd_error'] = empty($config_array['db']['bd_error']) ? 'Unknown error!' : $config_array['db']['bd_error']; + $_SESSION['bd_error'] = empty($config_array['db']['error']) ? 'Unknown error!' : $config_array['db']['error']; } } invalidateHttpCache(); @@ -375,7 +375,7 @@ function checkDbUser(&$dbOptions) { } } catch (PDOException $e) { $ok = false; - $dbOptions['bd_error'] = $e->getMessage(); + $dbOptions['error'] = $e->getMessage(); } return $ok; } diff --git a/cli/README.md b/cli/README.md index 35c0033a4..25b12234c 100644 --- a/cli/README.md +++ b/cli/README.md @@ -32,8 +32,8 @@ Options in parenthesis are optional. ```sh cd /usr/share/FreshRSS -./cli/do-install.php --default_user admin --auth_type form ( --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 ) -# --auth_type can be: 'form' (recommended), 'http_auth' (using the Web server access control), 'none' (dangerous) +./cli/do-install.php --default_user admin ( --auth_type form --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 ) +# --auth_type can be: 'form' (default), 'http_auth' (using the Web server access control), 'none' (dangerous) # --db-type can be: 'sqlite' (default), 'mysql' (MySQL or MariaDB), 'pgsql' (PostgreSQL) # --environment can be: 'production' (default), 'development' (for additional log messages) # --db-prefix is an optional prefix in front of the names of the tables diff --git a/cli/create-user.php b/cli/create-user.php index 008b82ce3..444264cc7 100755 --- a/cli/create-user.php +++ b/cli/create-user.php @@ -43,6 +43,9 @@ if (!$ok) { invalidateHttpCache(FreshRSS_Context::$system_conf->default_user); +echo '• Remember to refresh the feeds of the user: ', $username , "\n", + "\t", './cli/actualize-user.php --user ', $username, "\n"; + accessRights(); done($ok); diff --git a/cli/do-install.php b/cli/do-install.php index 667191680..b687b86cb 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -26,9 +26,9 @@ $dBparams = array( $options = getopt('', array_merge($params, $dBparams)); -if (empty($options['default_user']) || empty($options['auth_type'])) { - fail('Usage: ' . basename(__FILE__) . " --default_user admin --auth_type form" . - " ( --environment production --base_url https://rss.example.net/" . +if (empty($options['default_user'])) { + fail('Usage: ' . basename(__FILE__) . " --default_user admin ( --auth_type form" . + " --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 )"); @@ -51,7 +51,7 @@ if (!ctype_alnum($options['default_user'])) { fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . $options['default_user']); } -if (!in_array($options['auth_type'], array('form', 'http_auth', 'none'))) { +if (isset($options['auth_type']) && !in_array($options['auth_type'], array('form', 'http_auth', 'none'))) { fail('FreshRSS invalid authentication method (auth_type must be one of { form, http_auth, none }: ' . $options['auth_type']); } @@ -86,11 +86,11 @@ if (file_put_contents(join_path(DATA_PATH, 'config.php'), " 'none', + 'auth_type' => 'form', # Allow or not the use of the API, used for mobile apps. # End-point is http://example.net/FreshRSS/p/api/greader.php diff --git a/lib/lib_install.php b/lib/lib_install.php index 0e7b7f036..dd8090bcd 100644 --- a/lib/lib_install.php +++ b/lib/lib_install.php @@ -54,8 +54,8 @@ function generateSalt() { function checkDb(&$dbOptions) { $dsn = ''; + $driver_options = null; try { - $driver_options = null; switch ($dbOptions['type']) { case 'mysql': include_once(APP_PATH . '/SQL/install.sql.mysql.php'); @@ -99,8 +99,12 @@ function checkDb(&$dbOptions) { default: return false; } + + $c = new PDO($dsn, $dbOptions['user'], $dbOptions['password'], $driver_options); + $res = $c->query('SELECT 1'); } catch (PDOException $e) { $dsn = ''; + syslog(LOG_DEBUG, 'FreshRSS SQL warning: ' . $e->getMessage()); $dbOptions['error'] = $e->getMessage(); } $dbOptions['dsn'] = $dsn; -- cgit v1.2.3 From f3d5cbd7da78b9dff18104c539b140128ec98af2 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 6 Nov 2016 14:23:41 +0100 Subject: Underscore missing in documentation https://github.com/FreshRSS/FreshRSS/pull/1363 --- cli/README.md | 2 +- cli/do-install.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cli/do-install.php') diff --git a/cli/README.md b/cli/README.md index 25b12234c..e4d3409a2 100644 --- a/cli/README.md +++ b/cli/README.md @@ -36,7 +36,7 @@ cd /usr/share/FreshRSS # --auth_type can be: 'form' (default), 'http_auth' (using the Web server access control), 'none' (dangerous) # --db-type can be: 'sqlite' (default), 'mysql' (MySQL or MariaDB), 'pgsql' (PostgreSQL) # --environment can be: 'production' (default), 'development' (for additional log messages) -# --db-prefix is an optional prefix in front of the names of the tables +# --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/create-user.php --user username ( --password 'password' --api-password 'api_password' --language en --email user@example.net --token 'longRandomString' --no-default-feeds ) diff --git a/cli/do-install.php b/cli/do-install.php index b687b86cb..100d4947f 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -31,7 +31,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_ )"); } fwrite(STDERR, 'FreshRSS install…' . "\n"); -- cgit v1.2.3