diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/.htaccess | 14 | ||||
| -rw-r--r-- | cli/README.md | 34 | ||||
| -rw-r--r-- | cli/_update-or-create-user.php | 4 | ||||
| -rwxr-xr-x | cli/create-user.php | 7 | ||||
| -rwxr-xr-x | cli/do-install.php | 7 | ||||
| -rwxr-xr-x | cli/export-sqlite-for-user.php | 28 | ||||
| -rw-r--r-- | cli/i18n/ignore/en.php | 3 | ||||
| -rw-r--r-- | cli/i18n/ignore/fr.php | 3 | ||||
| -rw-r--r-- | cli/i18n/ignore/kr.php | 3 | ||||
| -rw-r--r-- | cli/i18n/ignore/nl.php | 14 | ||||
| -rw-r--r-- | cli/i18n/ignore/oc.php | 3 | ||||
| -rw-r--r-- | cli/i18n/ignore/sk.php | 66 | ||||
| -rw-r--r-- | cli/i18n/ignore/zh-cn.php | 3 | ||||
| -rwxr-xr-x | cli/import-sqlite-for-user.php | 34 | ||||
| -rwxr-xr-x | cli/prepare.php | 14 | ||||
| -rwxr-xr-x | cli/update-user.php | 1 |
16 files changed, 199 insertions, 39 deletions
diff --git a/cli/.htaccess b/cli/.htaccess index 9e768397d..32eca30f7 100644 --- a/cli/.htaccess +++ b/cli/.htaccess @@ -1,3 +1,11 @@ -Order Allow,Deny -Deny from all -Satisfy all +# Apache 2.2 +<IfModule !mod_authz_core.c> + Order Allow,Deny + Deny from all + Satisfy all +</IfModule> + +# Apache 2.4 +<IfModule mod_authz_core.c> + Require all denied +</IfModule> diff --git a/cli/README.md b/cli/README.md index e9e336439..89b440a39 100644 --- a/cli/README.md +++ b/cli/README.md @@ -35,7 +35,7 @@ cd /usr/share/FreshRSS ./cli/prepare.php # Ensure the needed directories in ./data/ -./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 ) +./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 ] # --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) # --base_url should be a public (routable) URL if possible, and is used for push (WebSub), for some API functions (e.g. favicons), and external URLs in FreshRSS. @@ -47,26 +47,20 @@ cd /usr/share/FreshRSS ./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 --purge_after_months 3 --feed_min_articles_default 50 --feed_ttl_default 3600 --since_hours_posts_per_rss 168 --min_posts_per_rss 2 --max_posts_per_rss 400 ) +./cli/create-user.php --user username [ --password 'password' --api_password 'api_password' --language en --email user@example.net --token 'longRandomString' --no_default_feeds --purge_after_months 3 --feed_min_articles_default 50 --feed_ttl_default 3600 --since_hours_posts_per_rss 168 --min_posts_per_rss 2 --max_posts_per_rss 400 ] # --language can be: 'en' (default), 'fr', or one of the [supported languages](../app/i18n/) -./cli/update-user.php --user username ( ... ) +./cli/update-user.php --user username [ ... ] # Same options as create-user.php, except --no_default_feeds which is only available for create-user.php +./cli/actualize-user.php --user username +# Fetch feeds for the specified user + ./cli/delete-user.php --user username ./cli/list-users.php # Return a list of users, with the default/admin user first -./cli/actualize-user.php --user username - -./cli/import-for-user.php --user username --filename /path/to/file.ext -# The extension of the file { .json, .opml, .xml, .zip } is used to detect the type of import - -./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 - ./cli/user-info.php -h --user username # -h is to use a human-readable format # --user can be a username, or '*' to loop on all users @@ -74,6 +68,20 @@ cd /usr/share/FreshRSS # 3) the date/time of last user action, 4) the size occupied, # and the number of: 5) categories, 6) feeds, 7) read articles, 8) unread articles, 9) favourites, and 10) tags +./cli/import-for-user.php --user username --filename /path/to/file.ext +# The extension of the file { .json, .opml, .xml, .zip } is used to detect the type of import + +./cli/export-sqlite-for-user.php --user username --filename /path/to/db.sqlite +# Export the user’s database to a new SQLite file. + +./cli/import-sqlite-for-user.php --user username [ --force-overwrite ] --filename /path/to/db.sqlite +# Import the user’s database from an SQLite file. +# --force-overwrite will clear the target user database before import (import only works on an empty user database) + +./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 + ./cli/db-optimize.php --user username # Optimize database (reduces the size) for a given user (perform `OPTIMIZE TABLE` in MySQL, `VACUUM` in SQLite) ``` @@ -120,4 +128,4 @@ Example to get the number of feeds of a given user: # Install and updates If you want to administrate FreshRSS using git, please read our [installation docs](https://freshrss.github.io/FreshRSS/en/admins/02_Installation.html) -and [update guidelines](https://freshrss.github.io/FreshRSS/en/admins/03_Updating.html). +and [update guidelines](https://freshrss.github.io/FreshRSS/en/admins/03_Updating.html). diff --git a/cli/_update-or-create-user.php b/cli/_update-or-create-user.php index eda597f19..43b86a4a9 100644 --- a/cli/_update-or-create-user.php +++ b/cli/_update-or-create-user.php @@ -45,8 +45,8 @@ $values = array( 'language' => strParam('language'), 'mail_login' => strParam('email'), 'token' => strParam('token'), - 'old_entries' => intParam('purge_after_months'), - 'keep_history_default' => intParam('feed_min_articles_default'), + 'old_entries' => intParam('purge_after_months'), //TODO: Update with new mechanism + 'keep_history_default' => intParam('feed_min_articles_default'), //TODO: Update with new mechanism 'ttl_default' => intParam('feed_ttl_default'), 'since_hours_posts_per_rss' => intParam('since_hours_posts_per_rss'), 'min_posts_per_rss' => intParam('min_posts_per_rss'), diff --git a/cli/create-user.php b/cli/create-user.php index 29675fa53..7e0a031d9 100755 --- a/cli/create-user.php +++ b/cli/create-user.php @@ -16,11 +16,14 @@ if (preg_grep("/^$username$/i", $usernames)) { echo 'FreshRSS creating user “', $username, "”…\n"; -$ok = FreshRSS_user_Controller::createUser($username, +$ok = FreshRSS_user_Controller::createUser( + $username, + empty($options['mail_login']) ? '' : $options['mail_login'], empty($options['password']) ? '' : $options['password'], empty($options['api_password']) ? '' : $options['api_password'], $values, - !isset($options['no_default_feeds'])); + !isset($options['no_default_feeds']) +); if (!$ok) { fail('FreshRSS could not create user!'); diff --git a/cli/do-install.php b/cli/do-install.php index fd5aa4a3c..dea5d235e 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -3,7 +3,7 @@ require(__DIR__ . '/_cli.php'); if (!file_exists(DATA_PATH . '/do-install.txt')) { - fail('FreshRSS looks to be already installed! Please use `./cli/reconfigure.php` instead.'); + fail('FreshRSS seems to be already installed! Please use `./cli/reconfigure.php` instead.'); } $params = array( @@ -82,10 +82,9 @@ if (file_put_contents(join_path(DATA_PATH, 'config.php'), fail('FreshRSS could not write configuration file!: ' . join_path(DATA_PATH, 'config.php')); } -$config['db']['default_user'] = $config['default_user']; -if (!checkDb($config['db'])) { +if (!checkDb()) { @unlink(join_path(DATA_PATH, 'config.php')); - fail('FreshRSS database error: ' . (empty($config['db']['error']) ? 'Unknown error' : $config['db']['error'])); + fail('FreshRSS database error: ' . (empty($_SESSION['bd_error']) ? 'Unknown error' : $_SESSION['bd_error'])); } echo '• Remember to create the default user: ', $config['default_user'] , "\n", diff --git a/cli/export-sqlite-for-user.php b/cli/export-sqlite-for-user.php new file mode 100755 index 000000000..027d13f38 --- /dev/null +++ b/cli/export-sqlite-for-user.php @@ -0,0 +1,28 @@ +#!/usr/bin/php +<?php +require(__DIR__ . '/_cli.php'); + +$params = [ + 'user:', + 'filename:', +]; + +$options = getopt('', $params); + +if (!validateOptions($argv, $params) || empty($options['user']) || empty($options['filename'])) { + fail('Usage: ' . basename(__FILE__) . ' --user username --filename /path/to/db.sqlite'); +} + +$username = cliInitUser($options['user']); +$filename = $options['filename']; + +if (pathinfo($filename, PATHINFO_EXTENSION) !== 'sqlite') { + fail('Only *.sqlite files are supported!'); +} + +echo 'FreshRSS exporting database to SQLite for user “', $username, "”…\n"; + +$databaseDAO = FreshRSS_Factory::createDatabaseDAO($username); +$ok = $databaseDAO->dbCopy($filename, FreshRSS_DatabaseDAO::SQLITE_EXPORT); + +done($ok); diff --git a/cli/i18n/ignore/en.php b/cli/i18n/ignore/en.php index e231afdda..db5a06a5e 100644 --- a/cli/i18n/ignore/en.php +++ b/cli/i18n/ignore/en.php @@ -67,7 +67,6 @@ return array( 'conf.sharing.diaspora', 'conf.sharing.email', 'conf.sharing.facebook', - 'conf.sharing.g+', 'conf.sharing.print', 'conf.sharing.shaarli', 'conf.sharing.twitter', @@ -88,7 +87,6 @@ return array( 'gen.share.diaspora', 'gen.share.email', 'gen.share.facebook', - 'gen.share.g+', 'gen.share.movim', 'gen.share.print', 'gen.share.shaarli', @@ -98,6 +96,7 @@ return array( 'gen.share.jdh', 'gen.share.Known', 'gen.share.gnusocial', + 'gen.share.lemmy', 'index.menu.non-starred', 'index.menu.read', 'index.menu.starred', diff --git a/cli/i18n/ignore/fr.php b/cli/i18n/ignore/fr.php index 0ac2e8758..8ed8ffff1 100644 --- a/cli/i18n/ignore/fr.php +++ b/cli/i18n/ignore/fr.php @@ -8,7 +8,6 @@ return array( 'conf.sharing.blogotext', 'conf.sharing.diaspora', 'conf.sharing.facebook', - 'conf.sharing.g+', 'conf.sharing.print', 'conf.sharing.shaarli', 'conf.sharing.twitter', @@ -35,7 +34,6 @@ return array( 'gen.share.blogotext', 'gen.share.diaspora', 'gen.share.facebook', - 'gen.share.g+', 'gen.share.movim', 'gen.share.shaarli', 'gen.share.twitter', @@ -43,6 +41,7 @@ return array( 'gen.share.wallabagv2', 'gen.share.jdh', 'gen.share.gnusocial', + 'gen.share.lemmy', 'index.about.agpl3', 'index.about.version', 'index.log._', diff --git a/cli/i18n/ignore/kr.php b/cli/i18n/ignore/kr.php index bbccb2d7d..2fa867cbe 100644 --- a/cli/i18n/ignore/kr.php +++ b/cli/i18n/ignore/kr.php @@ -4,7 +4,6 @@ return array( 'conf.sharing.blogotext', 'conf.sharing.diaspora', 'conf.sharing.facebook', - 'conf.sharing.g+', 'conf.sharing.shaarli', 'conf.sharing.twitter', 'conf.sharing.wallabag', @@ -39,7 +38,6 @@ return array( 'gen.share.blogotext', 'gen.share.diaspora', 'gen.share.facebook', - 'gen.share.g+', 'gen.share.gnusocial', 'gen.share.jdh', 'gen.share.linkedin', @@ -51,6 +49,7 @@ return array( 'gen.share.twitter', 'gen.share.wallabag', 'gen.share.wallabagv2', + 'gen.share.lemmy', 'index.about.agpl3', 'sub.api.title', ); diff --git a/cli/i18n/ignore/nl.php b/cli/i18n/ignore/nl.php index 4013bc89e..dc4dd9356 100644 --- a/cli/i18n/ignore/nl.php +++ b/cli/i18n/ignore/nl.php @@ -1,15 +1,18 @@ <?php return array( + 'admin.stats.feed', + 'conf.query.number', 'conf.sharing.blogotext', 'conf.sharing.diaspora', 'conf.sharing.email', 'conf.sharing.facebook', - 'conf.sharing.g+', 'conf.sharing.print', 'conf.sharing.shaarli', 'conf.sharing.twitter', 'conf.sharing.wallabag', + 'install.bdd._', + 'install.bdd.host', 'gen.date.Apr', 'gen.date.Dec', 'gen.date.Nov', @@ -20,20 +23,26 @@ return array( 'gen.lang.en', 'gen.lang.es', 'gen.lang.fr', + 'gen.lang.he', 'gen.lang.it', 'gen.lang.kr', 'gen.lang.nl', + 'gen.lang.oc', 'gen.lang.pt-br', 'gen.lang.ru', + 'gen.lang.sk', 'gen.lang.tr', 'gen.lang.zh-cn', 'gen.share.blogotext', 'gen.share.diaspora', 'gen.share.facebook', 'gen.share.email', - 'gen.share.g+', + 'gen.share.lemmy', + 'gen.share.linkedin', 'gen.share.mastodon', 'gen.share.movim', + 'gen.share.pinboard', + 'gen.share.pocket', 'gen.share.print', 'gen.share.shaarli', 'gen.share.twitter', @@ -41,6 +50,7 @@ return array( 'gen.share.wallabagv2', 'gen.share.jdh', 'gen.share.gnusocial', + 'gen.short.ok', 'index.about.agpl3', 'index.about.website', 'index.about.version', diff --git a/cli/i18n/ignore/oc.php b/cli/i18n/ignore/oc.php index 6413fc5f0..b67b277fe 100644 --- a/cli/i18n/ignore/oc.php +++ b/cli/i18n/ignore/oc.php @@ -8,7 +8,6 @@ return array( 'conf.sharing.blogotext', 'conf.sharing.diaspora', 'conf.sharing.facebook', - 'conf.sharing.g+', 'conf.sharing.print', 'conf.sharing.shaarli', 'conf.sharing.twitter', @@ -36,7 +35,6 @@ return array( 'gen.share.blogotext', 'gen.share.diaspora', 'gen.share.facebook', - 'gen.share.g+', 'gen.share.movim', 'gen.share.shaarli', 'gen.share.twitter', @@ -44,6 +42,7 @@ return array( 'gen.share.wallabagv2', 'gen.share.jdh', 'gen.share.gnusocial', + 'gen.share.lemmy', 'index.about.agpl3', 'index.about.version', 'index.log._', diff --git a/cli/i18n/ignore/sk.php b/cli/i18n/ignore/sk.php new file mode 100644 index 000000000..47d20f81f --- /dev/null +++ b/cli/i18n/ignore/sk.php @@ -0,0 +1,66 @@ +<?php + +return array( + 'conf.sharing.blogotext', + 'conf.sharing.diaspora', + 'conf.sharing.email', + 'conf.sharing.facebook', + 'conf.sharing.print', + 'conf.sharing.shaarli', + 'conf.sharing.twitter', + 'conf.sharing.wallabag', + 'gen.freshrss._', + 'gen.date.apr', + 'gen.date.Aug', + 'gen.date.aug', + 'gen.date.august', + 'gen.date.Dec', + 'gen.date.dec', + 'gen.date.december', + 'gen.date.feb', + 'gen.date.format_date', + 'gen.date.format_date_hour', + 'gen.date.jan', + 'gen.date.mar', + 'gen.date.Nov', + 'gen.date.nov', + 'gen.date.november', + 'gen.date.Sep', + 'gen.date.sep', + 'gen.date.september', + 'gen.lang.cz', + 'gen.lang.de', + 'gen.lang.en', + 'gen.lang.es', + 'gen.lang.fr', + 'gen.lang.he', + 'gen.lang.it', + 'gen.lang.kr', + 'gen.lang.nl', + 'gen.lang.oc', + 'gen.lang.pt-br', + 'gen.lang.ru', + 'gen.lang.tr', + 'gen.lang.sk', + 'gen.lang.zh-cn', + 'gen.share.blogotext', + 'gen.share.diaspora', + 'gen.share.facebook', + 'gen.share.email', + 'gen.share.linkedin', + 'gen.share.mastodon', + 'gen.share.movim', + 'gen.share.pinboard', + 'gen.share.pocket', + 'gen.share.print', + 'gen.share.shaarli', + 'gen.share.twitter', + 'gen.share.wallabag', + 'gen.share.wallabagv2', + 'gen.share.jdh', + 'gen.share.gnusocial', + 'index.about.agpl3', + 'sub.api.title', + 'sub.import_export.title', + 'sub.menu.import_export', +); diff --git a/cli/i18n/ignore/zh-cn.php b/cli/i18n/ignore/zh-cn.php index d55071d10..e0209d475 100644 --- a/cli/i18n/ignore/zh-cn.php +++ b/cli/i18n/ignore/zh-cn.php @@ -5,7 +5,6 @@ return array( 'conf.sharing.diaspora', 'conf.sharing.email', 'conf.sharing.facebook', - 'conf.sharing.g+', 'conf.sharing.shaarli', 'conf.sharing.twitter', 'conf.sharing.wallabag', @@ -27,7 +26,6 @@ return array( 'gen.share.diaspora', 'gen.share.email', 'gen.share.facebook', - 'gen.share.g+', 'gen.share.gnusocial', 'gen.share.jdh', 'gen.share.linkedin', @@ -39,6 +37,7 @@ return array( 'gen.share.twitter', 'gen.share.wallabag', 'gen.share.wallabagv2', + 'gen.share.lemmy', 'index.about.agpl3', 'sub.api.title', 'gen.freshrss._', diff --git a/cli/import-sqlite-for-user.php b/cli/import-sqlite-for-user.php new file mode 100755 index 000000000..f0e54e2fa --- /dev/null +++ b/cli/import-sqlite-for-user.php @@ -0,0 +1,34 @@ +#!/usr/bin/php +<?php +require(__DIR__ . '/_cli.php'); + +$params = [ + 'user:', + 'filename:', + 'force-overwrite', +]; + +$options = getopt('', $params); + +if (!validateOptions($argv, $params) || empty($options['user']) || empty($options['filename'])) { + fail('Usage: ' . basename(__FILE__) . ' --user username --force-overwrite --filename /path/to/db.sqlite'); +} + +$username = cliInitUser($options['user']); +$filename = $options['filename']; + +if (pathinfo($filename, PATHINFO_EXTENSION) !== 'sqlite') { + fail('Only *.sqlite files are supported!'); +} + +echo 'FreshRSS importing database from SQLite for user “', $username, "”…\n"; + +$databaseDAO = FreshRSS_Factory::createDatabaseDAO($username); +$clearFirst = array_key_exists('force-overwrite', $options); +$ok = $databaseDAO->dbCopy($filename, FreshRSS_DatabaseDAO::SQLITE_IMPORT, $clearFirst); +if (!$ok) { + echo 'If you would like to clear the user database first, use the option --force-overwrite', "\n"; +} +invalidateHttpCache($username); + +done($ok); diff --git a/cli/prepare.php b/cli/prepare.php index 81fb53f85..7e8ea051d 100755 --- a/cli/prepare.php +++ b/cli/prepare.php @@ -28,9 +28,17 @@ if (!is_file(DATA_PATH . '/config.php')) { } file_put_contents(DATA_PATH . '/.htaccess', -"Order Allow,Deny\n" . -"Deny from all\n" . -"Satisfy all\n" +"# Apache 2.2\n" . +"<IfModule !mod_authz_core.c>\n" . +" Order Allow,Deny\n" . +" Deny from all\n" . +" Satisfy all\n" . +"</IfModule>\n" . +"\n" . +"# Apache 2.4\n" . +"<IfModule mod_authz_core.c>\n" . +" Require all denied\n" . +"</IfModule>\n" ); accessRights(); diff --git a/cli/update-user.php b/cli/update-user.php index 7eb3e81ff..8067dadd3 100755 --- a/cli/update-user.php +++ b/cli/update-user.php @@ -9,6 +9,7 @@ echo 'FreshRSS updating user “', $username, "”…\n"; $ok = FreshRSS_user_Controller::updateUser( $username, + empty($options['mail_login']) ? null : $options['mail_login'], empty($options['password']) ? '' : $options['password'], empty($options['api_password']) ? '' : $options['api_password'], $values); |
