Merge pull request #66591 from aanderse/zabbix-proxy
nixos/zabbixProxy: fix database initialization logic
This commit is contained in:
commit
caf9b8cc35
@ -120,7 +120,8 @@ in
|
|||||||
|
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "zabbix";
|
default = if cfg.database.type == "sqlite" then "${stateDir}/zabbix.db" else "zabbix";
|
||||||
|
defaultText = "zabbix";
|
||||||
description = "Database name.";
|
description = "Database name.";
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -261,17 +262,17 @@ in
|
|||||||
preStart = optionalString pgsqlLocal ''
|
preStart = optionalString pgsqlLocal ''
|
||||||
if ! test -e "${stateDir}/db-created"; then
|
if ! test -e "${stateDir}/db-created"; then
|
||||||
cat ${cfg.package}/share/zabbix/database/postgresql/schema.sql | ${pgsql.package}/bin/psql ${cfg.database.name}
|
cat ${cfg.package}/share/zabbix/database/postgresql/schema.sql | ${pgsql.package}/bin/psql ${cfg.database.name}
|
||||||
cat ${cfg.package}/share/zabbix/database/postgresql/images.sql | ${pgsql.package}/bin/psql ${cfg.database.name}
|
|
||||||
cat ${cfg.package}/share/zabbix/database/postgresql/data.sql | ${pgsql.package}/bin/psql ${cfg.database.name}
|
|
||||||
touch "${stateDir}/db-created"
|
touch "${stateDir}/db-created"
|
||||||
fi
|
fi
|
||||||
'' + optionalString mysqlLocal ''
|
'' + optionalString mysqlLocal ''
|
||||||
if ! test -e "${stateDir}/db-created"; then
|
if ! test -e "${stateDir}/db-created"; then
|
||||||
cat ${cfg.package}/share/zabbix/database/mysql/schema.sql | ${mysql.package}/bin/mysql ${cfg.database.name}
|
cat ${cfg.package}/share/zabbix/database/mysql/schema.sql | ${mysql.package}/bin/mysql ${cfg.database.name}
|
||||||
cat ${cfg.package}/share/zabbix/database/mysql/images.sql | ${mysql.package}/bin/mysql ${cfg.database.name}
|
|
||||||
cat ${cfg.package}/share/zabbix/database/mysql/data.sql | ${mysql.package}/bin/mysql ${cfg.database.name}
|
|
||||||
touch "${stateDir}/db-created"
|
touch "${stateDir}/db-created"
|
||||||
fi
|
fi
|
||||||
|
'' + optionalString (cfg.database.type == "sqlite") ''
|
||||||
|
if ! test -e "${cfg.database.name}"; then
|
||||||
|
${pkgs.sqlite}/bin/sqlite3 "${cfg.database.name}" < ${cfg.package}/share/zabbix/database/sqlite3/schema.sql
|
||||||
|
fi
|
||||||
'' + optionalString (cfg.database.passwordFile != null) ''
|
'' + optionalString (cfg.database.passwordFile != null) ''
|
||||||
# create a copy of the supplied password file in a format zabbix can consume
|
# create a copy of the supplied password file in a format zabbix can consume
|
||||||
touch ${passwordFile}
|
touch ${passwordFile}
|
||||||
|
@ -63,7 +63,10 @@ in
|
|||||||
mkdir -p $out/share/zabbix/database/
|
mkdir -p $out/share/zabbix/database/
|
||||||
'' + optionalString sqliteSupport ''
|
'' + optionalString sqliteSupport ''
|
||||||
mkdir -p $out/share/zabbix/database/sqlite3
|
mkdir -p $out/share/zabbix/database/sqlite3
|
||||||
cp -prvd database/sqlite3/*.sql $out/share/zabbix/database/sqlite3/
|
cp -prvd database/sqlite3/schema.sql $out/share/zabbix/database/sqlite3/
|
||||||
|
'' + optionalString mysqlSupport ''
|
||||||
|
mkdir -p $out/share/zabbix/database/mysql
|
||||||
|
cp -prvd database/mysql/schema.sql $out/share/zabbix/database/mysql/
|
||||||
'' + optionalString postgresqlSupport ''
|
'' + optionalString postgresqlSupport ''
|
||||||
mkdir -p $out/share/zabbix/database/postgresql
|
mkdir -p $out/share/zabbix/database/postgresql
|
||||||
cp -prvd database/postgresql/schema.sql $out/share/zabbix/database/postgresql/
|
cp -prvd database/postgresql/schema.sql $out/share/zabbix/database/postgresql/
|
||||||
|
Loading…
Reference in New Issue
Block a user