mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-14 08:17:52 -05:00
* 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
47 lines
1.2 KiB
PHP
Executable File
47 lines
1.2 KiB
PHP
Executable File
#!/usr/bin/env php
|
||
<?php
|
||
$isUpdate = false;
|
||
require(__DIR__ . '/_update-or-create-user.php');
|
||
|
||
$username = $options['user'];
|
||
if (!FreshRSS_user_Controller::checkUsername($username)) {
|
||
fail('FreshRSS error: invalid username “' . $username .
|
||
'”! Must be matching ' . FreshRSS_user_Controller::USERNAME_PATTERN);
|
||
}
|
||
|
||
$usernames = listUsers();
|
||
if (preg_grep("/^$username$/i", $usernames)) {
|
||
fail('FreshRSS warning: username already exists “' . $username . '”', EXIT_CODE_ALREADY_EXISTS);
|
||
}
|
||
|
||
echo 'FreshRSS creating user “', $username, "”…\n";
|
||
|
||
$ok = FreshRSS_user_Controller::createUser(
|
||
$username,
|
||
empty($options['mail_login']) ? '' : $options['mail_login'],
|
||
empty($options['password']) ? '' : $options['password'],
|
||
$values,
|
||
!isset($options['no_default_feeds'])
|
||
);
|
||
|
||
if (!$ok) {
|
||
fail('FreshRSS could not create user!');
|
||
}
|
||
|
||
if (!empty($options['api_password'])) {
|
||
$username = cliInitUser($username);
|
||
$error = FreshRSS_api_Controller::updatePassword($options['api_password']);
|
||
if ($error) {
|
||
fail($error);
|
||
}
|
||
}
|
||
|
||
invalidateHttpCache(FreshRSS_Context::$system_conf->default_user);
|
||
|
||
echo 'ℹ️ Remember to refresh the feeds of the user: ', $username ,
|
||
"\t", './cli/actualize-user.php --user ', $username, "\n";
|
||
|
||
accessRights();
|
||
|
||
done($ok);
|