Chapter 7. Appendix: Modifying the configuration of the command-line assistant
The command-line assistant daemon (clad
) is the core of the command-line assistant powered by RHEL Lightspeed that manages the communication with the RHEL Lightspeed services, such as user history management, among other services. The clad
is a dbus
activated daemon. Any interaction with the command-line assistant, for example, by entering a c
command, activates the daemon.
You can modify the command-line assistant configuration, for example, if you use a proxy, or connect to a different database. Note that these configurations are optional.
7.1. Setting up a proxy configuration
If you need a proxy for Internet access, you can set up a proxy configuration by making the following changes in the config.toml
configuration file.
Prerequisites
- The command-line assistant powered by RHEL Lightspeed is installed.
Procedure
-
Access the proxy configuration by opening the
/etc/xdg/command-line-assistant/config.toml
configuration file. Locate and change the following block in the
config.toml
file :Backend settings for communicating with the external API. proxies = { http = "http://example-host:8002", https = "https://example-host:8002" }
# Backend settings for communicating with the external API. [backend] ... # proxies = { http = "http://example-host:8002", https = "https://example-host:8002" }
Copy to Clipboard Copied! Uncomment the
proxies
key and define yourhttp
orhttps
proxy host:[backend] … # For a https proxy host proxies = { https = "https://<your-https-proxy-host:1234>"}
[backend] … # For a https proxy host proxies = { https = "https://<your-https-proxy-host:1234>"}
Copy to Clipboard Copied! After making the changes, restart
clad
for the changes to be effective:sudo systemctl restart clad
$ sudo systemctl restart clad
Copy to Clipboard Copied! NoteYou can use the
http
value andhttps
key control if the http or https traffic fromclad
is routed to the specified proxy. However, the protocol does not influence the proxy type selection, and you can have a configuration that uses http proxy for https traffic. For example:https = "http://<your-https-proxy-host:1234>"
https = "http://<your-https-proxy-host:1234>"
Copy to Clipboard Copied!
Managing databases with the command-line assistant daemon
To store information and give you access to your history database, by default, command-line assistant daemon (clad
) uses an unencrypted SQLite database. You can install and connect to a different database backend, such as PostgreSQL or MySQL. Clad does not include these databases by default to avoid bringing unwanted dependencies to your system.
7.2. Changing the default database in the configuration file
With the unencrypted SQLite database, you can store information and have access to your history database from the command-line assistant.
Prerequisites
- You have installed the command-line assistant.
Procedure
Install the database of your choice:
To install MySQL, enter:
dnf install python3-PyMySQL
# dnf install python3-PyMySQL
Copy to Clipboard Copied! To install PostgreSQL, enter:
dnf install python3-psycopg2
# dnf install python3-psycopg2
Copy to Clipboard Copied!
-
Access your database configuration file at
/etc/xdg/command-line-assistant/config.toml
. Locate and comment out the default configuration. For example:
[database] # type = "sqlite" # connection_string = "/var/lib/command-line-assistant/history.db"
[database] # type = "sqlite" # connection_string = "/var/lib/command-line-assistant/history.db"
Copy to Clipboard Copied! Configure the database of your choice. The following information is also available in
/etc/xdg/command-line-assistant/config.toml
.-
Set the database type, where
<db_type>
can bemysql
orpostgresql
. Set the database details.
type = <db_type> host = "<hostname_or_ip_address>" port = "5432" username = "<database_user_name>" password = "<password>" database = "<database_name>"
type = <db_type> host = "<hostname_or_ip_address>" port = "5432" username = "<database_user_name>" password = "<password>" database = "<database_name>"
Copy to Clipboard Copied!
-
Set the database type, where
After changing the database type, restart the
clad
daemon to apply the changes:sudo systemctl restart clad
$ sudo systemctl restart clad
Copy to Clipboard Copied!
7.3. Connecting to your database by using the stored systemd-creds
passwords
You can use the systemd-creds
tool to securely store your encrypted credentials, and use the secrets stored in systemd-creds
to connect to the database of your choice: PostgreSQL, SQLite, or MySQL.
Prerequisites
- The command-line assistant.
- Access to the database configuration file.
Procedure
-
Access your database configuration file at
/etc/xdg/command-line-assistant/config.toml
. Remove the
username
andpassword
parameters from the[database]
section, for example:[database] type = "postgresql" host = "localhost" port = "5432" database = "history"
[database] type = "postgresql" host = "localhost" port = "5432" database = "history"
Copy to Clipboard Copied! NoteIf you leave the username and password in the configuration file, these credentials take precedence over the
systemd-creds
tool.Generate encrypted credentials for your username or password. The following example uses
systemd-ask-password
commands. The name must follow the schema ofdatabase-username
anddatabase-password
, otherwise,clad
does not load the credentials properly.To generate an encrypted username, run the following command:
systemd-ask-password -n | ( echo "[Service]" && systemd-creds encrypt --name=<database-username> -p - - ) >/etc/systemd/system/clad.service.d/<username>.conf
$ systemd-ask-password -n | ( echo "[Service]" && systemd-creds encrypt --name=<database-username> -p - - ) >/etc/systemd/system/clad.service.d/<username>.conf
Copy to Clipboard Copied! To generate an encrypted password, enter:
systemd-ask-password -n | ( echo "[Service]" && systemd-creds encrypt --name=<database-password> -p - - ) >/etc/systemd/system/clad.service.d/<password>.conf
$ systemd-ask-password -n | ( echo "[Service]" && systemd-creds encrypt --name=<database-password> -p - - ) >/etc/systemd/system/clad.service.d/<password>.conf
Copy to Clipboard Copied!
After updating the database credentials, reload
systemd
and restart theclad
daemon to apply the changes:sudo systemctl restart clad
$ sudo systemctl restart clad
Copy to Clipboard Copied!