aboutsummaryrefslogtreecommitdiff
path: root/cli/_cli.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-01-11 22:36:50 +0100
committerGravatar GitHub <noreply@github.com> 2021-01-11 22:36:50 +0100
commit8dfe2097992307b572b42647b53a76dd5d93aaa9 (patch)
tree5c5cecd7437ee584cc540a98f5597196f74fa4de /cli/_cli.php
parentfd8258775643eb0d898679f210c00de07c79eadc (diff)
Possiblity to autoinstall in Docker Compose (#3353)
* 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
Diffstat (limited to 'cli/_cli.php')
-rw-r--r--cli/_cli.php11
1 files changed, 7 insertions, 4 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);
}