Compare commits

..

No commits in common. "ab21a02be7df358448959480d1cb3a2d918f275c" and "562fd42333c4738a6968bd1375038781a3089157" have entirely different histories.

4 changed files with 7 additions and 154 deletions

View File

@ -56,7 +56,6 @@ vars:
"log_dir_group" string => "wheel";
"service_name" string => "apache24";
"service_cfg_name" string => "apache24";
"www_user" string => "www";
"www_group" string => "www";
"mime_types" string => "/usr/local/etc/apache24/mime.types";
@ -79,7 +78,6 @@ vars:
{m:"proxy",f:"mod_proxy"},
{m:"proxy_http",f:"mod_proxy_http"},
{m:"proxy_http2",f:"mod_proxy_http2"},
{m:"remoteip",f:"mod_remoteip"}
]';
@ -278,7 +276,7 @@ files:
methods:
"any" usebundle => wmde_enable_service("apache");
"any" usebundle => wmde_service("$(apache.service_name)","apache_kept","apache_repaired|php_repaired"),
depends_on => @(apache.service_deps) ;
@ -438,95 +436,3 @@ methods:
reports:
}
bundle agent apache_matomo
(site)
{
vars:
"pid" string => "/var/run/matomo-logger-$(site[domain]).pid";
"log" string => "$(apache.log_dir)/$(site[domain])-access.log";
"siteid" string => "$(site[matomoid])";
freebsd::
"analyt_cmd" string => "/usr/local/bin/python3.9 /var/www/matomo/misc/log-analytics/import_logs.py";
debian::
"analyt_cmd" string => "/usr/bin/python3 /var/www/matomo/misc/log-analytics/import_logs.py";
centos::
"analyt_cmd" string => "/usr/bin/python3 /var/www/matomo/misc/log-analytics/import_logs.py";
matomo::
"cmd" string => "/usr/bin/pkill -P `cat $(pid)` ; exec /bin/sh -c 'echo $$ > $(pid); /usr/bin/tail -n+1 -f $(log) | $(analyt_cmd) --token-auth=$(site[matomotoken]) --disable-bulk-tracking --idsite=$(siteid) --url=$(site[matomosite]) --exclude-path=/wp-login.php --exclude-path=/wp-json/* --recorders=1 --recorder-max-payload-size=1 --log-format-name=ncsa_extended --exclude-path=*.php --exclude-path=/wp-admin/* - > /dev/null' ";
!matomo::
"cmd" string => "";
any::
"cmd_esc" string => escape ($(cmd));
# "cmd": "$(cmd_esc)",
"site_str" string => storejson(@(site));
# "site_json" string => '{
# "site" : "$(site_str)"
# }';
"site_json" string => '{
"cmd": "$(cmd)",
"service": "$(apache.service_name)",
"site": $(site_str)
}';
"template_file"
string => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/weblogrot.mustache";
methods:
"any" usebundle => install_logrot;
files:
"$(logrot.dir)/$(site[domain])"
create => "true",
edit_defaults => backup("false"),
edit_template => "$(template_file)",
template_method => "mustache";
# template_data => parsejson("$(site_json)");
matomo::
"$(pid)"
create => "true";
classes:
"matomo" expression => isvariable("site[matomoid]");
commands:
matomo::
"/bin/sh -c "
args => "'kill -0 `cat $(pid)` && echo -start_matomo || echo +start_matomo'",
inform => "false",
module => "true";
methods:
start_matomo::
"call" usebundle => daemonize( "$(cmd)" );
reports:
#start_matomo::
# "MUST START - WHY";
#"ESC ESC $(site_json)";
matomo::
}
body edit_defaults backup( edit_backup )
{
edit_backup => "$(edit_backup)";
}

17
lib.cf
View File

@ -103,22 +103,7 @@ body service_method wmde
}
bundle agent wmde_enable_service(bundlename)
{
vars:
freebsd::
# "cha" string => "$(bundlename).service_cfg_name";
"filename" string => "/etc/rc.conf.d/$($(bundlename).service_cfg_name)";
files:
freebsd::
"$(filename)"
create => "true",
perms => m("644"),
content => "$($(bundlename).service_cfg_name)_enable=YES";
reports:
# "FREEBSD: $(filename) $(cha)";
}
bundle agent wmde_service(service_name,start_cond, restart_cond)
{

View File

@ -9,8 +9,7 @@ vars:
"default_cfg" data => '{
"bind_address":"127.0.0.1",
"user":"mysql",
"port":"3306",
"backup_dir":"/var/backups"
"port":"3306"
}';
"cfg" data => mergedata(@(default_cfg),@(cfg_param));
@ -72,11 +71,10 @@ files:
"$(cfg_file)"
#create => "true",
create => "true",
perms => m("644"),
copy_from => seed_cp("$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/my.cnf.mustache"),
# edit_template => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/my.cnf.mustache",
# template_method => "mustache",
edit_template => "$(sys.workdir)/inputs/$(def.wmde_libdir)/templates/my.cnf.mustache",
template_method => "mustache",
handle => "mysql_cfg_created",
depends_on => {"mysql_cfg_dir_created"},
classes => if_repaired("mysql_repaired");
@ -125,7 +123,6 @@ vars:
"j" string => storejson(@(cfg));
methods:
"any" usebundle => mysql(@(cfg));
"any" usebundle => wmde_install_packages(@(mysql.server_pkgs),"mysql_server");
files:
@ -318,38 +315,25 @@ bundle agent create_mysql_db(cfg)
{
classes:
"type_$(mysql.type)" ;
# "do_restore" expression => isvariable("cfg[restore]");
"do_restore" expression => strcmp("$(cfg[restore])","true");
vars:
"db_name" string => "$(cfg[db_name])";
"db_user" string => "$(cfg[db_user])";
"host" string => "$(cfg[db_user_host])";
"db_pass" string => "$(cfg[db_pass])";
type_mariadb::
"args" string => "-e \"CREATE DATABASE IF NOT EXISTS $(db_name); GRANT ALL PRIVILEGES ON $(db_name).* TO '$(db_user)'@'$(host)' IDENTIFIED BY '$(db_pass)'; \" ";
type_mysql8::
"args" string => "-e \"CREATE DATABASE IF NOT EXISTS $(db_name); CREATE USER IF NOT EXISTS '$(db_user)'@'$(host)'; ALTER USER '$(db_user)'@'$(host)' IDENTIFIED BY '$(db_pass)'; GRANT RELOAD ON *.* to '$(db_user)'@'$(host)'; GRANT ALL PRIVILEGES ON $(db_name).* TO '$(db_user)'@'$(host)';\" ";
methods:
do_restore::
"any" usebundle => restore_mysql_db_conditional(@(cfg),"$(mysql.cfg[backup_dir])/$(cfg[db_name])-dmp.sql"),
depends_on => {"mysql_$(cfg[db_name])_created"};
commands:
"$(mysql.mysql_cmd)"
args => "$(args)",
handle => "mysql_$(cfg[db_name])_created",
inform => "false";
reports:
do_restore::
"DO RESTORE";
!do_restore::
"DO_NOT_RESTORE";
}
@ -362,25 +346,3 @@ commands:
contain => wmde_cmd_useshell;
}
bundle agent restore_mysql_db_conditional(cfg,file)
{
classes:
"backup_exists" expression => fileexists("$(file)");
vars:
"table_exists" string => "mysql_$(cfg[db_name])_$(cfg[check_table])_exists";
methods:
"any" usebundle => mysql_table_exists(@(cfg),"$(cfg[check_table])");
"!$(table_exists)&backup_exists"::
"any" usebundle => restore_mysql_db(@(cfg),"$(file)");
reports:
"conditional $(cfg[check_table])_exists";
"FILE: $(file)";
"$(table_exists)"::
"$(table_exists) exists";
"!$(table_exists)&backup_exists"::
"$(table_exists) does not existsi, can restore";
}

2
php.cf
View File

@ -226,7 +226,7 @@ vars:
centos::
"cli_exe" string => "/usr/bin/php";
"version" string => "8.0";
"version" string => "8.2";
"fpm_pkgs" slist => { "php-fpm" };
"fpm_service_name" string => "php$(version)-fpm";
"fpm_socket" string => "/run/php-fpm/www.sock";