mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-15 03:15:56 +03:00
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 {
|
||||
type = types.str;
|
||||
default = "zabbix";
|
||||
default = if cfg.database.type == "sqlite" then "${stateDir}/zabbix.db" else "zabbix";
|
||||
defaultText = "zabbix";
|
||||
description = "Database name.";
|
||||
};
|
||||
|
||||
@ -261,17 +262,17 @@ in
|
||||
preStart = optionalString pgsqlLocal ''
|
||||
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/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"
|
||||
fi
|
||||
'' + optionalString mysqlLocal ''
|
||||
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/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"
|
||||
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) ''
|
||||
# create a copy of the supplied password file in a format zabbix can consume
|
||||
touch ${passwordFile}
|
||||
|
@ -63,7 +63,10 @@ in
|
||||
mkdir -p $out/share/zabbix/database/
|
||||
'' + optionalString sqliteSupport ''
|
||||
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 ''
|
||||
mkdir -p $out/share/zabbix/database/postgresql
|
||||
cp -prvd database/postgresql/schema.sql $out/share/zabbix/database/postgresql/
|
||||
|
Loading…
Reference in New Issue
Block a user