alxpanel-provision-db
Creates or repairs the PostgreSQL role and database the panel keeps its own data in.
This is the panel's own database, not the customers' (those are in MariaDB). The install runs this command by itself. Run it by hand, as root, when the install said the database could not be provisioned, or after pointing the panel at a PostgreSQL on another server. It is safe to repeat and never prints the password.
Usage
alxpanel-provision-db
No options. It reads the DB_* settings in /etc/alxpanel/panel.env.
With the local PostgreSQL (the default)
When DB_PASSWORD is empty, which is how a new install starts:
- initialises PostgreSQL if it has no data yet, then enables and starts it;
- makes it store passwords as SCRAM, and require SCRAM for connections from 127.0.0.1 and ::1. Nothing is opened to the network;
- creates the role and the database with a random password;
- writes that password into
/etc/alxpanel/panel.env; - runs the panel's migrations and restarts the panel.
When DB_PASSWORD is already set, it only checks the role, the database and the SCRAM settings, repairs what is missing and reports already provisioned or repaired: ….
On a server with an existing PostgreSQL
Step 2 changes that server's settings. Other roles whose password is stored as md5 can no longer log in over 127.0.0.1 or ::1 until their password is set again:
ALTER ROLE name PASSWORD '...';
The command warns when this applies.
With PostgreSQL on another server
- Create the role and the database there yourself.
- Set
DB_HOST,DB_PORT,DB_DATABASE,DB_USERNAMEandDB_PASSWORDin/etc/alxpanel/panel.env. - Run
alxpanel-provision-db. It runs the migrations against that server and changes nothing else.
Failures
All exit 1, with a message that names the next step. The common ones:
| Message | What to do |
|---|---|
local PostgreSQL not installed |
dnf install postgresql-server, then run the command again. |
DB_HOST=… is remote: create the role/database there, set DB_PASSWORD … |
Follow the steps for another server, above. |
migrations failed; see 'journalctl -u alxpanel-panel-migrate' |
Fix what the journal shows, run the command again. |
postgresql does not accept connections |
journalctl -u postgresql. |
Afterwards, alxpanel-setup starts the panel and prints the sign-in.