diff --git a/nixos/modules/services/monitoring/zabbix-proxy.nix b/nixos/modules/services/monitoring/zabbix-proxy.nix index 9cfcd1697c11..90abed30db5d 100644 --- a/nixos/modules/services/monitoring/zabbix-proxy.nix +++ b/nixos/modules/services/monitoring/zabbix-proxy.nix @@ -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} diff --git a/pkgs/servers/monitoring/zabbix/proxy.nix b/pkgs/servers/monitoring/zabbix/proxy.nix index 2062dc6659f8..48b72dc0590d 100644 --- a/pkgs/servers/monitoring/zabbix/proxy.nix +++ b/pkgs/servers/monitoring/zabbix/proxy.nix @@ -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/