aboutsummaryrefslogtreecommitdiff
path: root/cli/do-install.php
AgeCommit message (Collapse)Author
2025-09-29Reverse arguments to array_merge of cusotm config (#8033)Gravatar Lars Kellogg-Stedman
The installer was merging the initial configuration into the custom configuration, which meant that any keys set in the system configuration would take precedence over custom configuration. Practically, this meant it was not possible to preconfigure the database connection via `config.custom.php`. This commit reverses the order of the arguments to the `array_merge` function so that keys in the custom configuration will override keys in the initial configuration. See also: https://github.com/FreshRSS/FreshRSS/discussions/8030
2025-09-05Change how files are included (#7916)Gravatar Alexis Degrugillier
1. `include`, `include_once`, `require` and `require_once` are expressions not functions, parentheses are not necessary. 2. to move up the directory tree, it's better to use the `dirname` function instead of relying on `/..`.
2024-12-27PHPStan 2.0 (#7131)Gravatar Alexandre Alapetite
* PHPStan 2.0 fix https://github.com/FreshRSS/FreshRSS/issues/6989 https://github.com/phpstan/phpstan/releases/tag/2.0.0 https://github.com/phpstan/phpstan/blob/2.0.x/UPGRADING.md * More * More * Done * fix i18n CLI * Restore a PHPStan Next test For work towards PHPStan Level 10 * 4 more on Level 10 * fix getTagsForEntry * API at Level 10 * More Level 10 * Finish Minz at Level 10 * Finish CLI at Level 10 * Finish Controllers at Level 10 * More Level 10 * More * Pass bleedingEdge * Clean PHPStan options and add TODOs * Level 10 for main config * More * Consitency array vs. list * Sanitize themes get_infos * Simplify TagDAO->getTagsForEntries() * Finish reportAnyTypeWideningInVarTag * Prepare checkBenevolentUnionTypes and checkImplicitMixed * Fixes * Refix * Another fix * Casing of __METHOD__ constant
2024-11-28Upgrade code to php 8.1 (#6748)Gravatar Luc SANCHEZ
* revert Fix code indentation Fix code Upgrade code to php 8.1 * fix remarques * code review * code review * code review * Apply suggestions from code review * code review * Fixes * Many remainging updates of array syntax * Lost case 'reading-list' * Uneeded PHPDoc --------- Co-authored-by: Luc Sanchez <l.sanchez-prestataire@alptis.fr> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2024-03-19Fix CLI install regressions (#6214)Gravatar Alexandre Alapetite
* Fix CLI install with prefix It was not possible to pass a blank prefix * Fix regression EXIT_CODE_ALREADY_EXISTS The dedicated exit code was not sent anymore when a user already exists
2024-02-28Command Line Parser Concept (#6099)Gravatar Kasimir Cash
* Adds logic for validation * Adds validation to do-install * Adds help to do-install * Adds validation & help to reconfigure * Adds validation to check.translation * Adds validation to manipulate.translation * Small fixes to help texts * Refactors language option validation * Adds default options to validation * Fixes validation with regex * Refactors readAs functions * Updates to new regex validation format * Fixes typing around default values * Adds file extension validation * Restandardises validation & parsing typing around array of strings * Adds NotOneOf validation * Adds ArrayOfString read as * Refactors existing validation * Adds validation throughout cli * Removes unused file * Adds new CL parser with goal of wrapping CLI behaviour * Hides parsing and validation * Rewites CL parser to make better use of classes * Rolls out new parser across CL * Fixes error during unknown option check * Fixes misnamed property calls * Seperates validations into more appropriate locations * Adds common boolean forms to validation * Moves CommandLineParser and Option classes into their own files * Fixes error when validating Int type * Rewrites appendTypedValues -> appendTypedValidValues now filters invalid values from output * Renames -> for clarity * Adds some docs clarifying option defaults and value taking behaviour * Refactors getUsageMessage for readability * Minor formatting changes * Adds tests for CommandLineParser * Adds more tests * Adds minor fixs * Reconfigure now correctly updates config * More fixes to reconfigure * Fixes required files for CommandLineParserTest * Use .php extension for PHP file * PHPStan ignore instead of wrong typing * Refactors to support php 7.4 * Moves away from dynamic properties by adding 'Definintions' to all commands * Renames target to definition for clarity * Stops null from being returned as a valid value in a certain edge case * Adds PHPStan ignore instead of incorrect typing * Refactors tests to take account of new typing solution * Marks file as executable * Draft CLI rework * Finish rewrite as object-oriented * Fix PHPStan ignore and make more strongly typed * Rename class Option to CliOption * Light renaming + anonymous classes --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2024-01-17Standardise command line option parsing (#6036)Gravatar Kasimir Cash
* Separates long & short options for parsing * Adds parsing for short options + doc rewrites * Fixes undefined constant in check.translation * Standardises CL option parsing * Refactors option parsing * Renames getLongOptions -> getOptions * Removes unused code * Converges on string typing for options * Updates docs & help files * Updates array syntax array( ) -> [ ]
2024-01-092297 cli parameters consistency (#6028)Gravatar Kasimir Cash
* Updates do-install params * Adds parseCliParams to _cli.php * Updates do-install to use parseCliParams * Updates reconfigure to use parseCliParams * Fixes bug mail_login => email * Update create-user to use parseCliParams * Minor refactor * Updates update-user to use parseCliParams * Fix no_default_feeds => no-default-feeds * Refactors arrays * Updates CLI Readme * Adds docblocks to _cli functions * Sets vars in _cli functions * Fixes indentation * Meeting coding standards around colons * Meeting PHPStan standards * Removes stray whitespace * Meeting PHPStan Next Level standards * More specific typing * Maintaining types * Typing around getopt() * Fixes typo * Fixes typo perameters -> parameters * Removes unused variable * Rewrites deprecation warning message
2023-12-18Pass PHPStan level 8 (#5946)Gravatar Alexandre Alapetite
* Pass PHPStan level 8 And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels * Revert wrong replace in comment * Fix PHPStan level 8 * Update PHPStan and other dev dependencies * Remove obsolete comment * noVariableVariables and towards bleedingEdge https://github.com/phpstan/phpstan-strict-rules https://phpstan.org/blog/what-is-bleeding-edge * More bleedingEdge * A bit more PHPStan level 9 * More PHPStan level 9 * Prepare for booleansInConditions Ignore int and null * Revert wrong line * More fixes * Fix keep_max_n_unread * Stricter attribute functions * Stricter callHooks and more PHPStan level 9 * More typing * A tiny more
2023-11-16Use strict_types (#5830)Gravatar Luc SANCHEZ
* Little's optimisations and booleans in conditions * Apply strict type * Apply strict type * Apply strict type * Fix multiple bugs with PHP 8.2 and 8.3 * Many declares missing, more errors fixed * Apply strict type * Another approach * Stronger typing for Minz_Session * Fix case of SQLite --------- Co-authored-by: Luc <sanchezluc+freshrss@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2023-05-11A few additional PHPStan rules (#5388)Gravatar Alexandre Alapetite
A subset of https://github.com/phpstan/phpstan-strict-rules
2023-04-23PHPStan Level 7 for ten more files (#5327)Gravatar Alexandre Alapetite
* PHPStan Level 7 for nine more files * Minor syntax * One more
2023-03-26Modernize Constants and use new constant for string 'currentUser' (#5089)Gravatar Luc SANCHEZ
* Modernize Constants and use new constant 'currentUser' * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Add FreshRSS_Context::currentUser() function and use * Update app/Controllers/userController.php * Update app/Controllers/userController.php * Update app/Controllers/userController.php * Update app/Models/Auth.php * Update p/api/greader.php * Update p/api/greader.php * Update p/api/greader.php * Update app/Models/Context.php * Update app/Models/LogDAO.php * Update lib/Minz/Log.php * Update p/api/greader.php * Update app/layout/header.phtml * Update app/views/helpers/export/articles.phtml * Update cli/do-install.php * Remarque's from Alkarex * Remarque's from Alkarex * Refactor using new Minz_User class * Consistent naming of public constants --------- Co-authored-by: Luc <sanchezluc+freshrss@gmail.com> Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2022-08-05CLI allow empty DB prefix (#4488)Gravatar Alexandre Alapetite
Allow an empty `--db-prefix` parameter (i.e. optional) in CLI to have no DB prefix
2022-05-23Custom logo HTML (#4369)Gravatar Alexandre Alapetite
* Custom logo HTML Add option for custom HTML logo/title in the main Web UI view. Can potentially be different per user. #fix https://github.com/FreshRSS/FreshRSS/pull/3830/files#r850472247 * logo_html in main config With new `./data/config.custom.php` to provide custom values before install * Docker documentation * whitespace * Auto relax CSP to allow images for HTML logo * Documentation
2021-03-26tec: Remove data/do-install.txt (#3555)Gravatar berumuron
* Remove file data/do-install.txt This file was painful during update because we had to remember to delete it each time. It added a security issue by allowing an attacker to reinstall FreshRSS during the update process. The (more powerful) file data/applied_migrations.txt has been introduced in 8619cf6fa to replace do-install.txt. We had to wait for at least one release in order to make sure existing instances of FreshRSS created the migration file. It should be ok now. * Replace i18n install.not_deleted key * Update documentation to update FreshRSS
2021-03-20Fix init in CLI install (#3544)Gravatar Alexandre Alapetite
#fix https://github.com/FreshRSS/FreshRSS/issues/3528 config was not properly reloaded after being populated
2021-01-11Possiblity to autoinstall in Docker Compose (#3353)Gravatar Alexandre Alapetite
* Possiblity to autoinstall in Docker Compose #fix https://github.com/FreshRSS/FreshRSS/issues/3349 It is simply calling our existing CLI: do-install.php and create-user.php https://github.com/FreshRSS/FreshRSS/tree/master/cli FreshRSS will typically be ready a few seconds before the database, so introduce a tolerance when the database is not available / up (yet) by trying a few times to connect. Also useful to avoid service interruption when DB service is restarted. Example: ```yml freshrss-app: image: freshrss/freshrss container_name: freshrss-app hostname: freshrss-app restart: unless-stopped ports: - "8080:80" depends_on: - freshrss-db volumes: - data:/var/www/FreshRSS/data - extensions:/var/www/FreshRSS/extensions environment: CRON_MIN: '*/20' FRESHRSS_ENV: development FRESHRSS_INSTALL: |- --api_enabled --base_url https://rss.example.net --db-base freshrss --db-host freshrss-db --db-password freshrss --db-type pgsql --db-user freshrss --default_user admin --language en FRESHRSS_USER: |- --api_password freshrss --email user@example.net --language en --password freshrss --user admin TZ: Europe/Paris ``` * Minor type f in find * shellcheck
2021-01-02Avoid manual initialisations of system or user configuration (#3070)Gravatar Alexandre Alapetite
* Avoid manual intialisations of system or user configuration More consistent use of Context * Simplify FreshRSS_Context::initUser * Remove a few manual get_user_configuration * A bit of debugging * Fix context user init * Fix install * Fix concurrency Concurrent requests could lead to bad race condition * Fix actualize cron Fix case when system i initialised several times
2020-10-06Minz allow parallel sessions (#3096)Gravatar Alexandre Alapetite
* Minz allow parallel sessions #fix https://github.com/FreshRSS/FreshRSS/issues/3093 * Array optimisation * Array optimisation missing * Reduce direct access to $_SESSION except in install process * Fix session start headers warning * Use cookie only the first time the session is started: `PHP Warning: session_start(): Cannot start session when headers already sent in /var/www/FreshRSS/lib/Minz/Session.php on line 39` * New concept of volatile session for API calls Optimisation: do not use cookies or local storage at all for API calls without a Web session Fix warning: ``` PHP Warning: session_destroy(): Trying to destroy uninitialized session in Unknown on line 0 ``` * Only call Minz_Session::init once in our index It was called twice (once indirectly via FreshRSS->init()) * Whitespace * Mutex for notifications Implement mutex for notifications https://github.com/FreshRSS/FreshRSS/pull/3208#discussion_r499509809 * Typo * Install script is not ready for using Minz_Session
2020-07-08Add a migration system (#2760)Gravatar Marien Fressinaud
* Add a Minz_Migrator class Until now, we updated the database structure somewhere in the code but it wasn't always consistent and somehow complicated to find. Also, this code was always checked for nothing. The Migrator aims to improve and ease the creation of migrations. It should improve the way we apply the updates, making the update server almost useless. References: - example of migration (before Migrator): https://github.com/FreshRSS/FreshRSS/commit/cc0db9af4f980829faa4bf0960617807b32fb4fa#diff-11a53443fa81512b128c66b065df0679R10 - update server: https://github.com/FreshRSS/update.freshrss.org - PR moving the code of the update server to the core: https://github.com/FreshRSS/FreshRSS/pull/1760 * Automatically apply migrations For now, administrators are used to have nothing to do during an update else than getting the new code. I suggest to keep this behaviour and automatically apply migrations if we detect new ones. Another solution would be to create a CLI command and ask admins to call it after getting the new code. It could hide migrations errors to end users, but admin can forget to apply migrations since there are not used to it. * Add documentation for Minz Migrator * Execute migrations even if next ones are applied * Change mechanism to prevent multiple update at once * Use mkdir to create the lock and to test it exists Reference: https://stackoverflow.com/a/731634 * Append .lock to applied_migrations_path There are no needs to define another file to serve as a lock. * Change migrations naming convention * Apply suggestions from code review Co-Authored-By: Alexandre Alapetite <alexandre@alapetite.fr> * Perform a low-cost migration versions comparaison * Clarify version numbers concerning the migration system Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
2020-06-06Modify shebang to be more portable (#3038)Gravatar Alexis Degrugillier
The new shebang is a portable way to find the php interpreter. It works on Mac, GNU/Linux and BSD.
2020-01-04Fix wrong getHeader refactoring (#2749)Gravatar Alexandre Alapetite
* Fix wrong getHeader refactoring Fix regression introduced by https://github.com/FreshRSS/FreshRSS/pull/2373 The refactoring required a call to init() even for static functions, which is most of the time not done. Removed premature abstraction of `$_SERVER`, which was the root cause of the bug. https://github.com/FreshRSS/FreshRSS/issues/2748#issuecomment-569898931 * Refactoring: Move serverIsPublic to Minz_Request * Add mitigations for wrong configurations Due to the regression, we have some existing configurations with a bad base_url * Forgot one instance
2019-11-09Fix CLI install for SQLite (#2648)Gravatar Alexandre Alapetite
One forgotten condition. Related to https://github.com/FreshRSS/FreshRSS/pull/2646 and https://github.com/FreshRSS/FreshRSS/pull/2635
2019-11-06Fix database autocreate at install (#2635)Gravatar Alexandre Alapetite
* Fix database autocreate at install Several bugs prevented the auto-creation of the database in Web and CLI installs. Fix https://github.com/YunoHost-Apps/freshrss_ynh/issues/84#issuecomment-549818408 * initDb https://github.com/FreshRSS/FreshRSS/pull/2635#discussion_r343107795
2019-09-29PDO refactoring for code simplification (#2522)Gravatar Alexandre Alapetite
* PDO refactor * Automatic prefix when using the syntax `_tableName` * Uniformity: MySQL is now PDO::ATTR_EMULATE_PREPARES = false just like SQLite and PostgreSQL, with consequences such as only one statement per query * Use PDO methods exec(), query(), prepare() + execute() in a more efficient way * Remove auto-update SQL code for versions older than FreshRSS 1.5 (3 years old) * The name of the default category is set in PHP instead of in the DB (simplies SQL and allows changing the name according to the FreshRSS language) * Rename `->bd` to `->pdo` (less of a frenshism, and more informative) * Fix some requests, which were not compatible with MySQL prepared statements * Whitespace * Fix syntax for PostgreSQL sequences + MySQL install * Minor formatting * Fix lastInsertId for PostgreSQL * Use PHP 5.6+ const Take advantage of https://github.com/FreshRSS/FreshRSS/pull/2527 https://www.php.net/manual/en/migration56.new-features.php * A bit of forgotten PHP 5.6 simplification for cURL * Forgotten $s * Mini fix custom user config https://github.com/FreshRSS/FreshRSS/pull/2490/files#r326290346 * More work on install.php but not finished * install.php working * More cleaning of PDO in install * Even more simplification Take advantage of PDO->exec() to run multiple statements * Disallow changing the name of the default category https://github.com/FreshRSS/FreshRSS/pull/2522#discussion_r326967724
2019-03-19Add an option validation on cli commands (#2278)Gravatar Alexis Degrugillier
If an option used on cli is not recognized, the command aborts and displays an error message. If the typed option is similar to one of the recognized options, a hint is displayed. At the moment, there is a limitation on long options. Short options are not validated at the moment. See #2046
2018-09-09Better test if server has public address (#2010)Gravatar Alexandre Alapetite
* Better test if server has public address * Wrong trailing slash in documentation
2017-12-11Use __DIR__ for relative include and requireGravatar Alexandre Alapetite
For uniformity, and to avoid having PHP searching in include_path. http://php.net/manual/function.include.php https://github.com/FreshRSS/FreshRSS/pull/1715 https://github.com/FreshRSS/FreshRSS/pull/1711#issuecomment-350581350
2017-12-10Check requirement in CLI script (#1711)Gravatar Kevin Papst
* check requirements in actualize_script before executing, fixes #1710 * removed empty whiteline * testing all requirements * incorporated code review feedback * removed code that is already executed in _cli.php * added newline at eof * fixed include problems * fixed include problems
2017-09-22[ci] Add Travis (#1619)Gravatar Frans de Jonge
* [ci] Add Travis * Exclude some libs * Semi-auto whitespace fixes * line length in SQLite * Exclude tests from line length * Feed.php line length * Feed.php: get rid of unnecessary concat * Feed.php: line length * bootstrap.php: no newline at end of file * Allow concatenating across multiple lines * Add Travis badge * do-install line length * update-or-create-user line length * cli/create-user line length * tests/app/Models/SearchTest.php fix indentation * tests/app/Models/UserQueryTest.php fix indentation * tests/app/Models/CategoryTest.php fix indentation * [fix] PHP 5.3 on precise * cli/do-install no spaces * cli/list-users line length * cli/reconfigure line length * empty catch statements * api/index line length nonsense * spaces before semicolon * app/Models/EntryDAO bunch of indentation * extra blank lines * spaces before comma in function call * testing tabwidth * increase to 10 * comment out tabwidth line * try older phpcs version 3.0.0RC4 * line length exception for app/install.php * proper spaces * stray spaces in i18n * Minz/ModelPdo line length * Minz whitespace * greader line length * greader elseif placement * app/Models/Feed.php spacing in function argument * ignore php 5.3 * app/Models/ConfigurationSetter.php stray whitespace * EntryDAOSQLite line length * I vote for higher max line length =P * ignore SQL * remove classname complaint * line length/more legible SQL * ignore line length nonsense * greader line length * feedController issues * uppercase TRUE, FALSE, NULL * revert * importExportController lowercase null * Share.php default value not necessary because ! is_array () a few lines down * CategoryDAO constants should be UPPERCASE * EntryDAO reduce line length * contentious autofix * Allow failures on all versions of PHP except 7.1 because reasons
2017-07-22Update username constraintsGravatar Alexandre Alapetite
https://github.com/FreshRSS/FreshRSS/issues/1597
2017-03-03Allows do-install.php only if data/do-install.txt existsGravatar Alexandre Alapetite
https://github.com/FreshRSS/FreshRSS/issues/1449
2017-03-02CLI add language to installGravatar Alexandre Alapetite
https://github.com/FreshRSS/FreshRSS/issues/1445
2017-02-28Fix CLI install bug with SQLiteGravatar Alexandre Alapetite
And improve requirements check https://github.com/FreshRSS/FreshRSS/issues/1443
2017-02-25Merge branch 'dev' into feature/username-in-cliGravatar Clément
2017-02-24Merge pull request #1436 from dswd/disable-updateGravatar Alexandre Alapetite
Add config option to disable and hide self-update
2017-02-24Added disable_update option to cli/do-install.phpGravatar Dennis Schwerdel
2017-02-23Fixed empty db-prefix in do-install.phpGravatar Dennis Schwerdel
2017-02-16use function with preg_match to check usernameGravatar Clément
2017-02-16Possibility to register user having a '-', a '_' or a '.' in usernameGravatar Clément
2016-11-06Underscore missing in documentationGravatar Alexandre Alapetite
https://github.com/FreshRSS/FreshRSS/pull/1363
2016-11-06Fix small bugs in installGravatar Alexandre Alapetite
Small fixes in install (e.g. better check that DB password works)
2016-10-25A bit more readmeGravatar Alexandre Alapetite
2016-10-24+x execution rights do-installGravatar Alexandre Alapetite
2016-10-24CLI do-installGravatar Alexandre Alapetite
https://github.com/FreshRSS/FreshRSS/issues/1095 https://github.com/FreshRSS/FreshRSS/issues/1090