]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/AutomaticInstallation.php
Add Mastodon API entity classes
[friendica.git] / src / Console / AutomaticInstallation.php
index 05756196a145d209e088adaef5f77c9b398cd99b..8815b98799fbb854ced93fc0d124c71b09f83cd1 100644 (file)
@@ -4,12 +4,12 @@ namespace Friendica\Console;
 
 use Asika\SimpleConsole\Console;
 use Friendica\App;
+use Friendica\App\BaseURL;
 use Friendica\Core\Config;
 use Friendica\Core\Installer;
 use Friendica\Core\Theme;
 use Friendica\Database\Database;
 use Friendica\Util\BasePath;
-use Friendica\Util\BaseURL;
 use Friendica\Util\ConfigFileLoader;
 use RuntimeException;
 
@@ -23,6 +23,12 @@ class AutomaticInstallation extends Console
         * @var Config\Cache\ConfigCache
         */
        private $configCache;
+
+       /**
+        * @var Config\Configuration
+        */
+       private $config;
+
        /**
         * @var Database
         */
@@ -83,12 +89,13 @@ Examples
 HELP;
        }
 
-       public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Database $dba, array $argv = null)
+       public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\Configuration $config, Database $dba, array $argv = null)
        {
                parent::__construct($argv);
 
                $this->appMode = $appMode;
                $this->configCache  =$configCache;
+               $this->config = $config;
                $this->dba = $dba;
        }
 
@@ -122,16 +129,13 @@ HELP;
                $config_file = $this->getOption(['f', 'file']);
 
                if (!empty($config_file)) {
-                       if ($config_file != 'config' . DIRECTORY_SEPARATOR . 'local.config.php') {
-                               // Copy config file
-                               $this->out("Copying config file...\n");
-                               if (!copy($basePathConf . DIRECTORY_SEPARATOR . $config_file, $basePathConf . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
-                                       throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $basePathConf . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.config.php' manually.\n");
-                               }
+
+                       if (!file_exists($config_file)) {
+                               throw new RuntimeException("ERROR: Config file does not exist.\n");
                        }
 
                        //reload the config cache
-                       $loader = new ConfigFileLoader($basePathConf);
+                       $loader = new ConfigFileLoader($config_file);
                        $loader->setupCache($configCache);
 
                } else {
@@ -181,14 +185,14 @@ HELP;
                                $this->out('The Friendica URL has to be set during CLI installation.');
                                return 1;
                        } else {
-                               $baseUrl = new BaseURL($basePathConf, []);
+                               $baseUrl = new BaseURL($this->config, []);
                                $baseUrl->saveByURL($url);
                        }
 
                        $installer->createConfig($configCache);
                }
 
-               $this->out(" Complete!\n\n");
+               $this->out("Complete!\n\n");
 
                // Check database connection
                $this->out("Checking database...\n");
@@ -212,12 +216,20 @@ HELP;
                        throw new RuntimeException($errorMessage);
                }
 
+               if (!empty($config_file) && $config_file != 'config' . DIRECTORY_SEPARATOR . 'local.config.php') {
+                       // Copy config file
+                       $this->out("Copying config file...\n");
+                       if (!copy($basePathConf . DIRECTORY_SEPARATOR . $config_file, $basePathConf . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
+                               throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $basePathConf . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.config.php' manually.\n");
+                       }
+               }
+
                $this->out(" Complete!\n\n");
 
                // Install theme
                $this->out("Installing theme\n");
-               if (!empty($configCache->get('system', 'theme'))) {
-                       Theme::install($configCache->get('system', 'theme'));
+               if (!empty($this->config->get('system', 'theme'))) {
+                       Theme::install($this->config->get('system', 'theme'));
                        $this->out(" Complete\n\n");
                } else {
                        $this->out(" Theme setting is empty. Please check the file 'config/local.config.php'\n\n");