Using templates to configure services

Note The tool is under construction.


This manual explains how to configure services with templates. These are powerful tools, that allow you to create multiple setup profiles for cl-setup, to be used repeatedly.


  • Services are settings of a package or packages, combined in a logical solution
  • Profiles are groups of templates aiming at service configuration

As an example, try to create a profile called kernel for kernel configuration on your computer. To do so, only three steps are needed:

1) Create a file named /var/calculate/ini.env and add the following line to it:

[setup-kernel] = Kernel settings

Now cl-setup can recognize the setup profile you submitted and handle it:

# cl-setup list
kernel - Kernel settings

2) You can now prepare a template for kernel settings. Use the same tool to set the path to your templates:

# cl-setup setup kernel

Basic path and templates will be created.

3) Now create the template:

vi /var/calculate/templates/setup/kernel/sysctl.conf
# Calculate format=procmail path=/etc mergepkg(sys-apps/baselayout)!=
net.ipv4.ip_forward = 1


  • # Calculate stands for the template header;
  • format=procmail is a configuration file format that makes your template to replace settings without rewriting them;
  • path=/etc is the path to the config file;
  • _mergepkg (sys-apps / baselayout)! = _ is the function that checks in parallel for the presence of a package for which configuration is performed and assigns the files that are being created. As this is done at the package manager level, the files you have created will also be deleted when a package is deleted.

Done! All you have to do now to configure the kernel is to run:

cl-setup kernel

Once this operation is completed, the package forwarding setup variable in /etc/sysctl.conf will get a new value, while the file header will be modified to contain the path to your template:

# Modified Calculate Utilities 3.5.9
# Processed template files:
# /var/calculate/templates/setup/kernel/sysctl.conf
# For modify this file, create /etc/sysctl.conf.clt template.
net.ipv4.ip_forward = 1

Besides, a runtime entry will be generated in_/etc/calulate/ini.env_ when the tool is running.

run = Mon, 08 Jan 2018 02:14:36 +0300

This entry says to the Utilities that the kernel service has been configured and will use your template to generate sysctl.conf while re-installing the package.

This example illustrates a simple case of using templates. We explain below how to use the cl-setup tool to pass on parameters to your templates, run input value checks, and more. Putting templates on a LiveUSB or in your profile, you can always use your tools for solving administration tasks.

Template profile

cl-setup had the following syntax:

cl_setup [profile] [option or option=value (space separated if more than one]

To view the available profiles, run:

# cl-setup list
openvpn - Настройка OpenVPN

Template profiles, copied parameters and conditionals are described in the ini.env. file. You can store your settings anywhere you like, for instance in /var/calculate/ini.env, /var/calculate/remote/ini.env, /etc/calculate/ini.env, or else in your user directory.

To create a profile, add a "setup-service_name" section in ini.env, for example:


Properties of the copied parameters

In the service configuration section, list the available parameters and specify their properties in the same order in which they should be displayed when help is called:

cl-setup help service_name

The properties are comma-separated, and followed by the value. Example: = DNS

Available properties:


Here you can describe the possible values the parameter takes. You can enumerate valid values in square brackets, specify the values to select from, comma-separated, in round brackets, give a specific value type, such as an IP address, in curly brackets. Example:

remote.available = [a-zA-Z0-9_-\.]

When you choose between on and off, the "checkbox" field will be displayed in the GUI client window. Example:

gateway.available = (on, off)


This property prevents from entering contradictory parameters or selecting a parameter with a value that is incompatible with another one. In this case, the value must be specified in curly braces. You may specify multiple conditions, comma-separated. Example:

dns.block = type(client)


This is the default field value. If the user did not specify this parameter, the default value will be used.

type.default = client


Brief description of the settings It is provided when help is displayed for the settings profile To localize, put the locale in brackets at the end of the line.


Parameter name in English To localize, put the locale in brackets at the end of the line. If you choose to localize, the English locale is also mandatory. Example:[fr] = Option


Description of a parameter block starting with this element. It can be localized, as well as the parameter name. Example:

type.separate[fr] = Options générales

Example: OpenVPN parameters profile

See below a sample OpenVPN configuration service:

[setup-openvpn] = OpenVPN setting
setup.description = ...
setup.descriopion[ru] = ...[ru] = Настройка OpenVPN
type.available = (client, server)
type.default = client = Type[ru] = Тип
type.separate = Default options
type.separate[ru] = Общие настройки
name.available = [a-zA-Z0-9_-] = Key name[ru] = Имя ключа = path to directory easy-rsa[ru] = путь к директории easy-rsa
easy-rsa.default = /usr/share/easy-rsa
gateway.available = (on, off)
gateway.block = type(client) = Default gateway[ru] = Маршрут по умолчанию
gateway.separate = Server setup
gateway.separate[ru] = Настройки сервера
dns.available = {ip}
dns.block = type(client) = DNS
remote.available = [a-zA-Z0-9_-\.]
remote.block = type(server) = Server address[ru] = Адрес сервера
remote.separate = Client settings
remote.separate[ru] = Настройки клиента
port.available = [0-9]{4,5}
port.block = type(server)
port.default = 1194 = Port[ru] = Порт