Installation - Automatic installation

Note

This chapter is for information. For a basic installation, you don’t need to apply the content of this chapter.

Purpose

Domogik components can be installed with no user interaction : the install.py scripts has options for each configuration parameters. This is useful for packagers or people who want to automatically deploy some Domogik systems.

Domogik-mq usage

To know all the options available to install Domogik-mq, you can just launch install.py with the -h option:

$ sudo ./install.py -h
usage: install.py [-h] [--dist-packages] [--no-setup] [--no-test]
                  [--no-config] [--no-create-user] [--daemon] [--user USER]
                  [--user-shell USER_SHELL] [--advanced] [--command-line]
                  [--mq_is_master MQ_IS_MASTER]
                  [--mq_log_dir_path MQ_LOG_DIR_PATH]
                  [--mq_pid_dir_path MQ_PID_DIR_PATH]
                  [--mq_log_level MQ_LOG_LEVEL] [--mq_ip MQ_IP]
                  [--mq_req_rep_port MQ_REQ_REP_PORT]
                  [--mq_pub_port MQ_PUB_PORT] [--mq_sub_port MQ_SUB_PORT]

Domogik MQ installation.

optional arguments:
  -h, --help            show this help message and exit
  --dist-packages       Try to use distribution packages instead of pip
                        packages
  --no-setup            Don't install the python packages
  --no-test             Don't run a config test
  --no-config           Don't run a config writer
  --no-create-user      Don't create a user
  --daemon              Install the daemon (master mode)
  --user USER           Set the domogik user
  --user-shell USER_SHELL
                        Set the domogik user shell
  --advanced            Allow to configure all options in interactive mode
  --command-line        Configure the configuration files from the command
                        line only

...

Domogik usage

To know all the options available to install Domogik, you can just launch install.py with the -h option:

$ sudo ./install.py -h
usage: install.py [-h] [--dist-packages] [--no-create-database] [--no-setup]
                  [--no-test] [--no-config] [--no-create-user]
                  [--no-db-upgrade] [--no-mq-check] [--no-db-backup]
                  [--user USER] [--user-shell USER_SHELL] [--advanced]
                  [--command-line]
                  [--domogik_libraries_path DOMOGIK_LIBRARIES_PATH]
                  [--domogik_log_dir_path DOMOGIK_LOG_DIR_PATH]
                  [--domogik_pid_dir_path DOMOGIK_PID_DIR_PATH]
                  [--domogik_log_level DOMOGIK_LOG_LEVEL]
                  [--domogik_log_when DOMOGIK_LOG_WHEN]
                  [--domogik_log_interval DOMOGIK_LOG_INTERVAL]
                  [--domogik_log_backup_count DOMOGIK_LOG_BACKUP_COUNT]
                  [--domogik_bind_interface DOMOGIK_BIND_INTERFACE]
                  [--domogik_broadcast DOMOGIK_BROADCAST]
                  [--database_type DATABASE_TYPE]
                  [--database_user DATABASE_USER]
                  [--database_password DATABASE_PASSWORD]
                  [--database_port DATABASE_PORT]
                  [--database_name DATABASE_NAME]
                  [--database_host DATABASE_HOST]
                  [--database_prefix DATABASE_PREFIX]
                  [--admin_interfaces ADMIN_INTERFACES]
                  [--admin_port ADMIN_PORT] [--admin_use_ssl ADMIN_USE_SSL]
                  [--admin_ssl_certificate ADMIN_SSL_CERTIFICATE]
                  [--admin_ssl_key ADMIN_SSL_KEY]
                  [--admin_clean_json ADMIN_CLEAN_JSON]
                  [--admin_rest_auth ADMIN_REST_AUTH]
                  [--butler_name BUTLER_NAME] [--butler_lang BUTLER_LANG]
                  [--butler_sex BUTLER_SEX] [--backup_folder BACKUP_FOLDER]
                  [--metrics_id METRICS_ID] [--metrics_url METRICS_URL]
                  [--hub_interfaces HUB_INTERFACES]
                  [--hub_log_dir_path HUB_LOG_DIR_PATH]
                  [--hub_log_level HUB_LOG_LEVEL]
                  [--hub_log_bandwidth HUB_LOG_BANDWIDTH]
                  [--hub_log_invalid_data HUB_LOG_INVALID_DATA]

Domogik installation.

optional arguments:
  -h, --help            show this help message and exit
  --dist-packages       Try to use distribution packages instead of pip
                        packages
  --no-create-database  create and allow domogik to access to it, if it is not
                        already created
  --no-setup            Don't install the python packages
  --no-test             Don't run a config test
  --no-config           Don't run a config writer
  --no-create-user      Don't create a user
  --no-db-upgrade       Don't do a db upgrade
  --no-mq-check         Don't check the mq package
  --no-db-backup        Don't do a db backup
  --user USER           Set the domogik user
  --user-shell USER_SHELL
                        Set the domogik user shell
  --advanced            Allow to configure all options in interactive mode
  --command-line        Configure the configuration files from the command
                        line only

...

All configuration options which start by domogik, database, admin or hub are related to parameters from the Domogik configuration file /etc/domogik/domogik.cfg.

The other options are specific:

  • --advanced: all the available options values will be requested to the user.
  • --no-setup: the setup.py script which install python dependencies and Domogik python package won’t be run. This can be useful for setting a Domogik in a virtualenv.
  • --no-test: the test_config.py script won’t be executed after the installation.
  • --no-config: there won’t be any update of the configuration files.
  • --no-create-user: the user won’t be created during installation.
  • --user <login>: set the login which will be used by Domogik (default is domogik)
  • --user-shell <user shell>: set the shell which will be used by the user (default is /bin/sh)
  • --command-line: the configuration files will be update from the command line. If not set, the user will be prompted for the main parameters value.

How to use it

I am a core developer, can these options help me ?

Of course! Here is an example of one developer script named do_install.sh. This developer uses it to stop the running domogik, drop the existing database, re-install domogik and start domogik.

# stop domogik
/etc/init.d/domogik stop
/etc/init.d/domogik-mq stop

# create database
mysql -uroot -plapinous << EOF
  DROP database dmgtest10;
  CREATE DATABASE dmgtest10;
  GRANT ALL PRIVILEGES ON dmgtest10.* to domogik@localhost IDENTIFIED BY 'domopass';
EOF

# install domogik-mq
cd ../domogik-mq/
python install.py \
--daemon \
--user fritz \
--command-line \
--mq_ip 192.168.1.10

# install domogik
cd ../domogik/
python install.py \
--user fritz \
--command-line \
--domogik_log_level debug \
--domogik_bind_interface eth0 \
--database_name dmgtest10 \
--admin_interfaces eth0 \
--hub_interfaces eth0 \
--hub_log_level info \
--hub_log_bandwidth True \
--hub_log_invalid_data True \


# start components
/etc/init.d/domogik-mq start
/etc/init.d/domogik start

As you can see, the developer only set the options he needs to change.

Automated tests

These options can be used to set up some continuous integration environments. We use this with Travis-ci.org.

Packagers

Distribution packagers (Debian, Fedora, ...) can use these options to create their packages.