ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Setup\CLI\InstallCommand Class Reference

Installation command. More...

+ Inheritance diagram for ILIAS\Setup\CLI\InstallCommand:
+ Collaboration diagram for ILIAS\Setup\CLI\InstallCommand:

Public Member Functions

 __construct (AgentFinder $agent_finder, ConfigReader $config_reader, array $preconditions)
 

Data Fields

const IMPORT = "import"
 

Protected Member Functions

 configure ()
 
 execute (InputInterface $input, OutputInterface $output)
 
 prepareILIASInstallation (InputInterface $input, OutputInterface $output)
 
 preparePluginInstallation (InputInterface $input, OutputInterface $output)
 
 createTempDir ()
 

Protected Attributes

const TMP_DIR = "tmp_dir"
 
array $preconditions = []
 var Objective[] More...
 

Static Protected Attributes

static $defaultName = "install"
 

Detailed Description

Installation command.

Definition at line 40 of file InstallCommand.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Setup\CLI\InstallCommand::__construct ( AgentFinder  $agent_finder,
ConfigReader  $config_reader,
array  $preconditions 
)

Definition at line 59 of file InstallCommand.php.

References ILIAS\Setup\CLI\InstallCommand\$preconditions, and ILIAS\GlobalScreen\Provider\__construct().

60  {
62  $this->agent_finder = $agent_finder;
63  $this->config_reader = $config_reader;
64  $this->preconditions = $preconditions;
65  }
array $preconditions
var Objective[]
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ configure()

ILIAS\Setup\CLI\InstallCommand::configure ( )
protected

Definition at line 67 of file InstallCommand.php.

References ILIAS\Setup\CLI\configureCommandForPlugins(), and null.

67  : void
68  {
69  $this->setDescription("Creates a fresh ILIAS installation based on the config");
70  $this->addArgument("config", InputArgument::OPTIONAL, "Configuration file for the installation");
71  $this->addOption("config", null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, "Define fields in the configuration file that should be overwritten, e.g. \"a.b.c=foo\"", []);
72  $this->addOption("yes", "y", InputOption::VALUE_NONE, "Confirm every message of the installation.");
73  $this->addOption("import-file", "i", InputOption::VALUE_REQUIRED, "Path to zip file to import from.");
75  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
configureCommandForPlugins()
Definition: HasAgent.php:33
+ Here is the call graph for this function:

◆ createTempDir()

ILIAS\Setup\CLI\InstallCommand::createTempDir ( )
protected

Definition at line 206 of file InstallCommand.php.

References $path, and null.

Referenced by ILIAS\Setup\CLI\InstallCommand\prepareILIASInstallation().

206  : ?string
207  {
208  $path = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . mt_rand() . microtime(true);
209  if (mkdir($path)) {
210  return $path;
211  }
212  return null;
213  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ execute()

ILIAS\Setup\CLI\InstallCommand::execute ( InputInterface  $input,
OutputInterface  $output 
)
protected

Definition at line 77 of file InstallCommand.php.

References Vendor\Package\$e, ILIAS\Setup\NoConfirmationException\getRequestedConfirmation(), ILIAS\Setup\CLI\InstallCommand\prepareILIASInstallation(), and ILIAS\Setup\CLI\InstallCommand\preparePluginInstallation().

77  : int
78  {
79  // ATTENTION: This is a hack to get around the usage of the echo/exit pattern in
80  // the setup for the command line version of the setup. Do not use this.
81  if (!defined("ILIAS_SETUP_IGNORE_DB_UPDATE_STEP_MESSAGES")) {
82  define("ILIAS_SETUP_IGNORE_DB_UPDATE_STEP_MESSAGES", true);
83  }
84 
85  if ($input->hasOption('legacy-plugin') && $input->getOption('legacy-plugin') != "") {
86  list($objective, $environment, $io) = $this->preparePluginInstallation($input, $output);
87  } else {
88  list($objective, $environment, $io) = $this->prepareILIASInstallation($input, $output);
89  }
90  try {
91  $this->achieveObjective($objective, $environment, $io);
92  if ($input->hasOption("import-file") && $input->getOption("import-file") != "") {
93  $io->inform("Please ensure that all ILIAS directories (webdir/datadir/Customizing) have the right owner after import process.");
94  }
95  $io->success("Installation complete. Thanks and have fun!");
96  } catch (NoConfirmationException $e) {
97  $io->error("Aborting Installation, a necessary confirmation is missing:\n\n" . $e->getRequestedConfirmation());
98  }
99 
100  return 0;
101  }
prepareILIASInstallation(InputInterface $input, OutputInterface $output)
preparePluginInstallation(InputInterface $input, OutputInterface $output)
+ Here is the call graph for this function:

◆ prepareILIASInstallation()

ILIAS\Setup\CLI\InstallCommand::prepareILIASInstallation ( InputInterface  $input,
OutputInterface  $output 
)
protected

Definition at line 103 of file InstallCommand.php.

References ILIAS\Setup\CLI\addAgentConfigsToEnvironment(), ILIAS\Setup\CLI\InstallCommand\createTempDir(), MysqlIfsnopDumper\FILE_NAME, ILIAS\Setup\CLI\getRelevantAgent(), ILIAS\Setup\CLI\readAgentConfig(), ILIAS\Setup\Environment\RESOURCE_ADMIN_INTERACTION, and ILIAS\Setup\Environment\RESOURCE_CLIENT_ID.

Referenced by ILIAS\Setup\CLI\InstallCommand\execute().

103  : array
104  {
105  $io = new IOWrapper($input, $output);
106  $io->printLicenseMessage();
107  $io->title("Install ILIAS");
108 
109  $environment = new ArrayEnvironment([
111  ]);
112 
113  if ($input->hasOption("import-file") && $input->getOption("import-file") != "") {
114  if ($input->getArgument("config") == "") {
115  throw new \InvalidArgumentException("Missing configuration file.");
116  }
117  $import_file = $input->getOption("import-file");
118  if (!is_file($import_file)) {
119  throw new \InvalidArgumentException("Can't find import file '$import_file'.");
120  }
121 
122  if (pathinfo($import_file)["extension"] != "zip") {
123  throw new \InvalidArgumentException("Wrong file format for import file. 'zip' is expected.");
124  }
125 
126  $tmp_dir = $this->createTempDir();
127  if (is_null($tmp_dir)) {
128  throw new \RuntimeException("Can't create temporary directory!");
129  }
130  $environment = $environment
131  ->withConfigFor(self::IMPORT, $input->getOption("import-file"))
132  ->withConfigFor(self::TMP_DIR, $tmp_dir)
133  ;
134  $dump_path = $tmp_dir . DIRECTORY_SEPARATOR . MysqlIfsnopDumper::FILE_NAME;
135  $input->setOption(
136  "config",
137  array_merge($input->getOption("config"), ["database.path_to_db_dump=$dump_path"])
138  );
139  }
140 
141  $agent = $this->getRelevantAgent($input);
142 
143  $config = $this->readAgentConfig($agent, $input);
144 
145  $objective = new ObjectiveCollection(
146  "Install and Update ILIAS",
147  false,
148  $agent->getInstallObjective($config),
149  $agent->getUpdateObjective($config)
150  );
151  if ($this->preconditions !== []) {
152  $objective = new ObjectiveWithPreconditions(
153  $objective,
154  ...$this->preconditions
155  );
156  }
157 
158  $environment = $this->addAgentConfigsToEnvironment($agent, $config, $environment);
159  // ATTENTION: This is bad because we strongly couple this generic command
160  // to something very specific here. This can go away once we have got rid of
161  // everything related to clients, since we do not need that client-id then.
162  // This will require some more work, though.
163  $common_config = $config->getConfig("common");
164  $environment = $environment->withResource(
166  $common_config->getClientId()
167  );
168 
169  return [$objective, $environment, $io];
170  }
addAgentConfigsToEnvironment(Agent $agent, Config $config, Environment $environment)
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40
readAgentConfig(Agent $agent, InputInterface $input, ?string $use_config_field=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preparePluginInstallation()

ILIAS\Setup\CLI\InstallCommand::preparePluginInstallation ( InputInterface  $input,
OutputInterface  $output 
)
protected

Definition at line 172 of file InstallCommand.php.

References ILIAS\Setup\CLI\addAgentConfigsToEnvironment(), ILIAS\Setup\CLI\getRelevantAgent(), ILIAS\Setup\CLI\readAgentConfig(), and ILIAS\Setup\Environment\RESOURCE_ADMIN_INTERACTION.

Referenced by ILIAS\Setup\CLI\InstallCommand\execute().

172  : array
173  {
174  $io = new IOWrapper($input, $output);
175  $io->printLicenseMessage();
176  $io->title("Install ILIAS Plugin");
177 
178  $agent = $this->getRelevantAgent($input);
179 
180  $config = $this->readAgentConfig($agent, $input, $input->getOption("legacy-plugin"));
181 
182  $objective = new ObjectiveCollection(
183  "Install and Update ILIAS Plugin",
184  false,
185  $agent->getInstallObjective($config),
186  $agent->getUpdateObjective($config)
187  );
188  if ($this->preconditions !== []) {
189  $objective = new ObjectiveWithPreconditions(
190  $objective,
191  ...$this->preconditions
192  );
193  }
194 
195  $environment = new ArrayEnvironment([
197  ]);
198 
199  if (!is_null($config)) {
200  $environment = $this->addAgentConfigsToEnvironment($agent, $config, $environment);
201  }
202 
203  return [$objective, $environment, $io];
204  }
addAgentConfigsToEnvironment(Agent $agent, Config $config, Environment $environment)
getRelevantAgent(InputInterface $input)
Definition: HasAgent.php:40
readAgentConfig(Agent $agent, InputInterface $input, ?string $use_config_field=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $defaultName

ILIAS\Setup\CLI\InstallCommand::$defaultName = "install"
staticprotected

Definition at line 49 of file InstallCommand.php.

◆ $preconditions

array ILIAS\Setup\CLI\InstallCommand::$preconditions = []
protected

var Objective[]

Definition at line 54 of file InstallCommand.php.

Referenced by ILIAS\Setup\CLI\InstallCommand\__construct().

◆ IMPORT

const ILIAS\Setup\CLI\InstallCommand::IMPORT = "import"

Definition at line 46 of file InstallCommand.php.

◆ TMP_DIR

const ILIAS\Setup\CLI\InstallCommand::TMP_DIR = "tmp_dir"
protected

Definition at line 47 of file InstallCommand.php.


The documentation for this class was generated from the following file: