diff --git a/mysql.cf b/mysql.cf index 31c5725..f3a90fe 100644 --- a/mysql.cf +++ b/mysql.cf @@ -5,6 +5,7 @@ bundle agent mysql(cfg_param) { vars: + "default_cfg" data => '{ "bind_address":"127.0.0.1", "user":"mysql", @@ -14,6 +15,7 @@ vars: "cfg" data => mergedata(@(default_cfg),@(cfg_param)); freebsd:: + "user" string => "mysql"; # "server_pkgs" slist => {"mariadb106-server"}; # "client_pkgs" slist => {"mariadb106-client"}; "server_pkgs" slist => {"mysql80-server"}; @@ -23,7 +25,11 @@ vars: "cfg_dir" string => "/usr/local/etc/mysql"; "cfg_file" string => "/usr/local/etc/mysql/my.cnf"; "bin_dir" string => "/usr/local/bin"; + "install_db_cmd" string => "$(bin_dir)/mariadb-install-db --user=$(user) > /dev/null"; + "default_datadir" string => "/var/db/mysql"; + debian:: + "user" string => "mysql"; "server_pkgs" slist => {"mariadb-server"}; "client_pkgs" slist => {"mariadb-client"}; "type" string => "mariadb"; @@ -31,17 +37,27 @@ vars: "cfg_dir" string => "/etc/mysql"; "cfg_file" string => "/etc/mysql/my.cnf"; "bin_dir" string => "/usr/bin"; + "install_db_cmd" string => "$(bin_dir)/mariadb-install-db --user=$(user) > /dev/null "; + "default_datadir" string => "/var/lib/mysql"; + fedora:: + "user" string => "mysql"; "server_pkgs" slist => {"mariadb-server"}; "client_pkgs" slist => {"mariadb-client"}; "type" string => "mariadb"; "service_name" string => "mariadb"; "cfg_dir" string => "/etc/mysql"; "cfg_file" string => "/etc/my.cnf"; - "bin_dir" string => "/usr/bin"; any:: + "bin_dir" string => "/usr/bin"; + "install_db_cmd" string => "$(bin_dir)/mariadb-install-db --user=$(user) > /dev/null"; + "default_datadir" string => "/var/lib/mysql"; + any:: "mysql_cmd" string => "$(bin_dir)/mysql"; "mysqldump_cmd" string => "$(bin_dir)/mysqldump"; + "datadir" string => ifelse(isvariable("cfg[settings][mysqld][datadir]"), + "$(cfg[settings][mysqld][datadir])", + "$(default_datadir)"); files: freebsd:: @@ -108,9 +124,16 @@ files: handle => "myslq_server_cfg_edited", classes => if_repaired("mysql_server_repaired"); +commands: + "$(mysql.install_db_cmd)" + handle=>"mysql_datadir_initialized", + contain => wmde_cmd_useshell, + inform => "false", + depends_on => {"myslq_server_cfg_edited"}; + methods: "any" usebundle => wmde_service("$(mysql.service_name)","mysql_server_kept","mysql_server_repaired"), - depends_on => {"myslq_server_cfg_edited"}; + depends_on => {"mysql_datadir_initialized"}; reports: