aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/_cli.php11
-rwxr-xr-xcli/create-user.php4
-rwxr-xr-xcli/do-install.php4
3 files changed, 11 insertions, 8 deletions
diff --git a/cli/_cli.php b/cli/_cli.php
index dc7ee9d64..38eb55990 100644
--- a/cli/_cli.php
+++ b/cli/_cli.php
@@ -3,6 +3,7 @@ if (php_sapi_name() !== 'cli') {
die('FreshRSS error: This PHP script may only be invoked from command line!');
}
+const EXIT_CODE_ALREADY_EXISTS = 3;
const REGEX_INPUT_OPTIONS = '/^--/';
const REGEX_PARAM_OPTIONS = '/:*$/';
@@ -16,9 +17,9 @@ Minz_Translate::init('en');
FreshRSS_Context::$isCli = true;
-function fail($message) {
+function fail($message, $exitCode=1) {
fwrite(STDERR, $message . "\n");
- die(1);
+ die($exitCode);
}
function cliInitUser($username) {
@@ -39,12 +40,14 @@ function cliInitUser($username) {
}
function accessRights() {
- echo '• Remember to re-apply the appropriate access rights, such as:' , "\n",
+ echo 'ℹ️ Remember to re-apply the appropriate access rights, such as:',
"\t", 'sudo chown -R :www-data . && sudo chmod -R g+r . && sudo chmod -R g+w ./data/', "\n";
}
function done($ok = true) {
- fwrite(STDERR, 'Result: ' . ($ok ? 'success' : 'fail') . "\n");
+ if (!$ok) {
+ fwrite(STDERR, (empty($_SERVER['argv'][0]) ? 'Process' : basename($_SERVER['argv'][0])) . ' failed!' . "\n");
+ }
exit($ok ? 0 : 1);
}
diff --git a/cli/create-user.php b/cli/create-user.php
index dd0c23175..f94a0aa7a 100755
--- a/cli/create-user.php
+++ b/cli/create-user.php
@@ -11,7 +11,7 @@ if (!FreshRSS_user_Controller::checkUsername($username)) {
$usernames = listUsers();
if (preg_grep("/^$username$/i", $usernames)) {
- fail('FreshRSS error: username already taken “' . $username . '”');
+ fail('FreshRSS warning: username already exists “' . $username . '”', EXIT_CODE_ALREADY_EXISTS);
}
echo 'FreshRSS creating user “', $username, "”…\n";
@@ -38,7 +38,7 @@ if (!empty($options['api_password'])) {
invalidateHttpCache(FreshRSS_Context::$system_conf->default_user);
-echo '• Remember to refresh the feeds of the user: ', $username , "\n",
+echo 'ℹ️ Remember to refresh the feeds of the user: ', $username ,
"\t", './cli/actualize-user.php --user ', $username, "\n";
accessRights();
diff --git a/cli/do-install.php b/cli/do-install.php
index fd51003ab..258b5b688 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 seems to be already installed! Please use `./cli/reconfigure.php` instead.');
+ fail('FreshRSS seems to be already installed!' . "\n" . 'Please use `./cli/reconfigure.php` instead.', EXIT_CODE_ALREADY_EXISTS);
}
$params = array(
@@ -107,7 +107,7 @@ if (!$ok) {
fail('FreshRSS database error: ' . (empty($_SESSION['bd_error']) ? 'Unknown error' : $_SESSION['bd_error']));
}
-echo '• Remember to create the default user: ', $config['default_user'] , "\n",
+echo 'ℹ️ Remember to create the default user: ', $config['default_user'],
"\t", './cli/create-user.php --user ', $config['default_user'], " --password 'password' --more-options\n";
accessRights();