Child pages
  • Command Line Setup
Skip to end of metadata
Go to start of metadata

Since version 4.9.1, CONTENIDO features an automated setup script. It is a PHP file which is supposed to be run with the CLI interpreter of PHP.

The CLI setup does not support upgrades yet!

Usage

In order for the script to work correctly, the working directory has to be the setup/ directory of your CONTENIDO installation.

$ cd contenido/setup/

The script itself has to be called with the php interpreter.

$ php ./autoinstall.php 

If the script suddenly stops without giving an error message try starting it like this:

php -d max_execution_time=0 ./autoinstall.php 

This tells PHP to let the script run indefinitely instead of interrupting it after a while.

With a standard installation this will start the interactive setup. The script will ask for necessary configuration options and you will have to enter them.

>>>>> Welcome to CONTENIDO <<<<<
Database settings:
	Host [localhost]:      
	User [root]: mysql
	Password: ***
	Database name [contenido]: 
	Charset [utf8]: 
	Prefix [con]: 
Please enter the http path to where the contenido/ folder resides
e.g. http://localhost/
	Backend web path []:
...

If you don't enter anything for one of the options, the setup will always use what is in written in the brackets as your answer. In this example, it would use "localhost" as the database host.

However, the script can also read this configuration from a .ini file. The default name for this is "autoinstall.ini". You can also use 

$ php ./autoinstall.php --file "/some/path/to/the/ini/file.ini"

to use "file.ini" instead of the default file.

An example configuration file can be found in "autoinstall-example.ini":

;Setup information for the automated CONTENIDO setup
;The autoinstall.php will always look for a file called 'autoinstall.ini' for configuration information
;You can also specify another file by calling "./autoinstall.php --ini PATH_TO_FILE"
;all of these settings are MANDATORY

[db]
;specify database connection settings in this section
user=USERNAME
host=HOSTNAME
password=USER_PASSWORD
charset=DATABASE_CHARSET
collation=DATABASE_COLLATION
database=DATABASE_NAME
prefix=TABLE_PREFIX

[paths]
;information about paths
;Use the path where the contenido folder is located in. (aka "PATH_TO_BACKEND/..")
;This is the path that web browsers will have to be able to use, so start with "http://..." and end with a "/"
http_root_path=HTTP_PATH

[setup]
;This setting specifies which components of the example client will be installed
;it can either be "CLIENTEXAMPLES" to install the complete example client,
;"CLIENTMODULES" to only install the modules
;or "NOCLIENT" to not install the example client at all
client_mode=CLIENTEXAMPLES

[admin_user]
;set some information about the sysadmin account
password=SYSADMIN_PASSWORD
email=SYSADMIN_EMAIL

Don't forget to delete your setup folder after installing! The .ini file you used for the setup contains sensible information like your sysadmin password and your database passwords!

XML

The autoinstall script can also read settings from an XML instead of an ini file. There is also an example for that called "autoinstall-example.xml":

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE setup SYSTEM "installsettings.dtd">
<!-- For a more detailed documentation see the autoinstall-example.ini
The configurable settings are mostly the same -->
<setup>
	<db>
		<host>
			HOST_NAME
		</host>
		<user>
			USER
		</user>
		<password>
			PASSWORD
		</password>
		<database>
			DATABASE_NAME
		</database>
		<charset>
			DATABASE_CHARSET
		</charset>
		<collation>
			DATABASE_COLLATION
		</collation>
		<prefix>
			DATABASE_PREFIX
		</prefix>
	</db>
	
	<path>
		<http_root_path>
			CONTENIDO_WEB_ROOT
		</http_root_path>
	</path>
	
	<client>
		<client_mode>
			CLIENTEXAMPLES
		</client_mode>
	</client>
	
	<admin_user>
		<password>
			SYSADMIN_PASSWORD
		</password>
		<email>
			SYSADMIN_EMAIL
		</email>
	</admin_user>
</setup>

To use an XML file, just use the "–file" switch. The setup will detect automatically the right file type.

Interactive mode vs. non-interactive mode

Per default, the setup tries to be as interactive as possible and it will ask the users about potential errors or missing configuration values. If this behavior is not wanted (e.g. for some kind of automated setup), you can use

$ php ./autoinstall.php --non-interactive

This will disable all interactive features of the script. The configuration will be read from the .ini file (either the "autoinstall.ini" or whatever is given by the "–file" parameter). If some kind of error comes up, the script will terminate (for example if the ini file can't be found or read).

The script can also be forced to use the interactive mode, even though an "autoinstall.ini" is present. This is especially useful if only some of the values need to be changed, since the setup will use whatever is written in the ini file, if nothing is given by the user.

$ php ./autoinstall.php --interactive

If the autoinstall.php is started without one of those two parameters it will look for the .ini file and use it if it is present. If it is not present it will fall back to the interactive setup process.

Overwriting settings with command line parameters

The script also supports setting options with command line parameters. It uses the same names as the .ini file, so you can use parameters like

$ php ./autoinstall.php --db.database "someDatabaseName" --setup.client_mode "CLIENTMODULES"

and the setup will use "someDatabaseName" as database name and it will only install the modules of the example client.

Just be careful with passwords, since they will be saved in your bash history.

Advanced options

The setup is capable of deleting the database before installing it. This is especially useful for development purposes. To do that you have to add the right setting to your ini or XML file:

ini
[advanced]
delete_database=YES
XML
<setup>
...
	<advanced>
		<delete_database>
			YES
		</delete_database>
	</advanced>
...
</setup>

The setup will ask for confirmation before deleting anything, even if the "--non-interactive" parameter is present.

Other options

The command line setup is localized. You can choose the language by using the "–locale" parameter:

$ php ./autoinstall.php --locale de_DE

The locale has to be a valid CONTENIDO locale (meaning it has to exist as a subfolder of contenido/setup/locale).

For a quick overview about the possible parameters and what the script does, you can use 

$ php ./autoinstall.php --help

This will display a short summary of the valid parameters.

  • No labels