diff options
Diffstat (limited to 'cli/do-install.php')
| -rwxr-xr-x | cli/do-install.php | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/cli/do-install.php b/cli/do-install.php index 100d4947f..143ca5c3e 100755 --- a/cli/do-install.php +++ b/cli/do-install.php @@ -3,9 +3,14 @@ require('_cli.php'); require(LIB_PATH . '/lib_install.php'); +if (!file_exists(DATA_PATH . '/do-install.txt')) { + fail('FreshRSS looks to be already installed! Please use `./cli/reconfigure.php` instead.'); +} + $params = array( 'environment:', 'base_url:', + 'language:', 'title:', 'default_user:', 'allow_anonymous', @@ -13,6 +18,7 @@ $params = array( 'auth_type:', 'api_enabled', 'allow_robots', + 'disable_update', ); $dBparams = array( @@ -29,32 +35,13 @@ $options = getopt('', array_merge($params, $dBparams)); 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" . + " --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_ )"); + " --db-base freshrss --db-prefix freshrss_ --disable_update )"); } fwrite(STDERR, 'FreshRSS install…' . "\n"); -$requirements = checkRequirements(); -if ($requirements['all'] !== 'ok') { - $message = 'FreshRSS install failed requirements:' . "\n"; - foreach ($requirements as $requirement => $check) { - if ($check !== 'ok' && $requirement !== 'all') { - $message .= '• ' . $requirement . "\n"; - } - } - fail($message); -} - -if (!ctype_alnum($options['default_user'])) { - fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . $options['default_user']); -} - -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']); -} - $config = array( 'salt' => generateSalt(), 'db' => FreshRSS_Context::$system_conf->db, @@ -73,12 +60,34 @@ if ((!empty($config['base_url'])) && server_is_public($config['base_url'])) { foreach ($dBparams as $dBparam) { $dBparam = rtrim($dBparam, ':'); - if (!empty($options[$dBparam])) { + if (isset($options[$dBparam])) { $param = substr($dBparam, strlen('db-')); $config['db'][$param] = $options[$dBparam]; } } +$requirements = checkRequirements($config['db']['type']); +if ($requirements['all'] !== 'ok') { + $message = 'FreshRSS install failed requirements:' . "\n"; + foreach ($requirements as $requirement => $check) { + if ($check !== 'ok' && !in_array($requirement, array('all', 'pdo', 'message'))) { + $message .= '• ' . $requirement . "\n"; + } + } + if (!empty($requirements['message'])) { + $message .= '• ' . $requirements['message'] . "\n"; + } + fail($message); +} + +if (!FreshRSS_user_Controller::checkUsername($options['default_user'])) { + fail('FreshRSS invalid default username (must be ASCII alphanumeric): ' . $options['default_user']); +} + +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']); +} + if (file_put_contents(join_path(DATA_PATH, 'config.php'), "<?php\n return " . var_export($config, true) . ";\n") === false) { fail('FreshRSS could not write configuration file!: ' . join_path(DATA_PATH, 'config.php')); } |
