aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/README.md28
-rwxr-xr-xcli/create-user.php3
-rwxr-xr-xcli/do-install.php14
-rwxr-xr-xcli/user-info.php35
4 files changed, 70 insertions, 10 deletions
diff --git a/cli/README.md b/cli/README.md
index 444606b50..e4d3409a2 100644
--- a/cli/README.md
+++ b/cli/README.md
@@ -32,11 +32,11 @@ 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
+# --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 )
@@ -55,4 +55,26 @@ 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
+
+./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
+# Returns a * if the user is admin, the name of the user, the date/time of last action, and the size occupied
+```
+
+
+## Unix piping
+
+It is possible to invoke a command multiple times, e.g. with different usernames, thanks to the `xargs -n1` command.
+
+Example showing user information for all users which username starts with 'a':
+
+```sh
+./cli/list-users.php | grep '^a' | xargs -n1 ./cli/user-info.php -h --user
+```
+
+Example showing all users ranked by date of last activity:
+
+```sh
+./cli/user-info.php -h --user '*' | sort -k2 -r
```
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..100d4947f 100755
--- a/cli/do-install.php
+++ b/cli/do-install.php
@@ -26,12 +26,12 @@ $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 )");
+ " --db-base freshrss --db-prefix freshrss_ )");
}
fwrite(STDERR, 'FreshRSS install…' . "\n");
@@ -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'), "<?php\n return " . va
$config['db']['default_user'] = $config['default_user'];
if (!checkDb($config['db'])) {
@unlink(join_path(DATA_PATH, 'config.php'));
- fail('FreshRSS database error: ' . (empty($config['db']['bd_error']) ? 'Unknown error' : $config['db']['bd_error']));
+ fail('FreshRSS database error: ' . (empty($config['db']['error']) ? 'Unknown error' : $config['db']['error']));
}
echo '• Remember to create the default user: ', $config['default_user'] , "\n",
- "\t", './cli/create-user.php --user ', $config['default_user'] , " --password 'password' --more-options\n";
+ "\t", './cli/create-user.php --user ', $config['default_user'], " --password 'password' --more-options\n";
accessRights();
diff --git a/cli/user-info.php b/cli/user-info.php
new file mode 100755
index 000000000..dd38e6c7f
--- /dev/null
+++ b/cli/user-info.php
@@ -0,0 +1,35 @@
+#!/usr/bin/php
+<?php
+require('_cli.php');
+
+$options = getopt('h', array(
+ 'user:',
+ ));
+
+if (empty($options['user'])) {
+ fail('Usage: ' . basename(__FILE__) . " -h --user username");
+}
+
+$users = $options['user'] === '*' ? listUsers() : array($options['user']);
+
+foreach ($users as $username) {
+ $username = cliInitUser($username);
+
+ $entryDAO = FreshRSS_Factory::createEntryDao($username);
+
+ echo $username === FreshRSS_Context::$system_conf->default_user ? '*' : ' ', "\t";
+
+ if (isset($options['h'])) { //Human format
+ echo
+ $username, "\t",
+ date('c', FreshRSS_UserDAO::mtime($username)), "\t",
+ format_bytes($entryDAO->size()), "\t",
+ "\n";
+ } else {
+ echo
+ $username, "\t",
+ FreshRSS_UserDAO::mtime($username), "\t",
+ $entryDAO->size(), "\t",
+ "\n";
+ }
+}