zabbix-server/dbsetup.sh

17 lines
684 B
Bash
Raw Permalink Normal View History

2025-08-15 23:23:00 +02:00
#!/bin/bash
set -e
# This file is executed INSIDE the postgres container, but only the very first time
# the database is created. If any side-effects of this script need to be performed
# again, execute into the container and try again. There is no need for authentication
# inside the container, the connection is trusted
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER zabbix WITH PASSWORD 'zabbix';
CREATE DATABASE zabbix;
GRANT ALL PRIVILEGES ON DATABASE zabbix TO zabbix;
EOSQL
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname zabbix <<-EOSQL
GRANT ALL PRIVILEGES ON SCHEMA public TO zabbix;
EOSQL