wmdeit-cf-wmdelib/roundcube.cf

146 lines
4.3 KiB
CFEngine3
Raw Normal View History

2023-10-17 07:30:00 +00:00
#
#
#
bundle agent roundcube(cfg)
{
2023-11-01 14:59:28 +00:00
classes:
"dlbyversion" expression => not (isvariable ("cfg[src_tgz]"));
2023-10-17 07:30:00 +00:00
2023-11-01 14:59:28 +00:00
"roundcube_untar" expression => not(fileexists("$(install_sub_dir)/index.php"));
"config_exists" expression => fileexists("$(install_sub_dir)/config/config.inc.php");
2023-10-17 07:30:00 +00:00
"backup_config_exists" expression => fileexists("$(cfg[backup_dir])/config.inc.php");
"run_backups" expression => isvariable("cfg[backup_dir]");
run_backups::
"backup_config_exists" expression => fileexists("$(cfg[backup_dir])/config.inc.php");
"sql_backup_exists" expression => fileexists("$(cfg[backup_dir])/roundcube.sql");
vars:
2023-11-01 14:59:28 +00:00
"dldir" string =>"$(sys.workdir)/data/agent/roundcube";
!(dlbyversion)::
"dlfile" string => "$(sys.workdir)/data/public/$(cfg[src_tgz])";
"dltype" string => "policyhub";
"dlsrc" string => "$(def.hub_public_dir)/$(cfg[src_tgz])";
"install_sub_dir" string => "$(cfg[install_sub_dir])";
dlbyversion::
"tgzname" string => "roundcubemail-$(cfg[version])-complete.tar.gz";
"dlfile" string => "$(dldir)/$(tgzname)";
"install_sub_dir" string => "$(cfg[install_dir])/roundcubemail-$(cfg[version])";
"dltype" string => "wget";
"dlsrc" string => "https://github.com/roundcube/roundcubemail/releases/download/$(cfg[version])/$(tgzname)";
reports:
2023-11-01 16:02:00 +00:00
# dlbyversion::
# "dl by version";
# !dlbyversion::
# "not dl by version";
2023-11-01 14:59:28 +00:00
2023-10-17 07:30:00 +00:00
files:
2023-11-01 14:59:28 +00:00
"$(dldir)/."
create => "true",
handle => "roundcube_agent_dir_created";
methods:
"any" usebundle => download_file("$(dltype)","$(dlsrc)","$(dlfile)","roundcube_tgz_file",'{}'),
handle => "roundcube_tgz_copied",
2023-11-01 16:02:00 +00:00
depends_on => {"roundcube_agent_dir_created"};
# classes => if_repaired ("roundcube_untar");
2023-11-01 14:59:28 +00:00
# "$(dlfile)"
# copy_from => remote_dcp("$(def.hub_public_dir)/$(cfg[src_tgz])","$(sys.policy_hub)"),
# perms => m(644);
2023-10-17 07:30:00 +00:00
2023-11-01 14:59:28 +00:00
files:
2023-10-17 07:30:00 +00:00
"$(cfg[install_dir])/public"
2023-11-01 14:59:28 +00:00
link_from => ln_s("$(install_sub_dir)"),
2023-10-17 07:30:00 +00:00
move_obstructions => "true",
depends_on => {"roundcube_untarred"};
run_backups&(!config_exists)&backup_config_exists::
2023-11-01 14:59:28 +00:00
"$(install_sub_dir)/config/config.inc.php"
2023-10-17 07:30:00 +00:00
copy_from => local_cp("$(cfg[backup_dir])/config.inc.php"),
perms => m("644"),
classes => if_repaired("roundcube_config_repaired"),
depends_on => {"roundcube_untarred"};
run_backups&config_exists::
"$(cfg[backup_dir])/config.inc.php"
2023-11-01 14:59:28 +00:00
copy_from => local_dcp("$(install_sub_dir)/config/config.inc.php"),
2023-11-01 16:02:00 +00:00
depends_on => {"roundcube_untarred"};
2023-10-17 07:30:00 +00:00
methods:
"any" usebundle => mysql_table_exists(@(cfg),"users");
2023-11-01 16:02:00 +00:00
config_exists|roundcube_config_repaired::
2023-11-01 14:59:28 +00:00
"any" usebundle => rm_rf ("$(install_sub_dir)/installer");
2023-10-17 07:30:00 +00:00
commands:
2023-11-01 16:02:00 +00:00
roundcube_untar|roundcube_tgz_file_repaired::
2023-10-17 07:30:00 +00:00
"/usr/bin/tar"
2023-10-22 21:22:23 +00:00
args => "xzf $(dlfile) -C $(cfg[install_dir]) && chown -R $(cfg[www_user]):$(cfg[www_group]) $(cfg[install_dir])",
2023-10-17 07:30:00 +00:00
depends_on => {"roundcube_tgz_copied"},
2023-10-22 21:22:23 +00:00
contain => wmde_cmd_useshell,
2023-10-17 07:30:00 +00:00
handle => "roundcube_untarred";
2023-11-01 16:02:00 +00:00
(!roundcube_untar)&(!roundcube_tgz_file_repaired)::
2023-10-17 07:30:00 +00:00
"/usr/bin/true"
inform => "false",
depends_on => {"roundcube_tgz_copied"},
handle => "roundcube_untarred";
"run_backups&sql_backup_exists&(!mysql_$(cfg[db_name])_users_exists)"::
"$(mysql.mysql_cmd)"
args => "-h$(cfg[db_host]) -u$(cfg[db_user]) -p$(cfg[db_pass]) $(cfg[db_name]) < $(cfg[backup_dir])/roundcube.sql",
contain => wmde_cmd_useshell;
methods:
run_backups::
"any" usebundle => create_mysql_backup_cron_job(@(cfg),"$(cfg[backup_dir])/roundcube.sql","users","true");
!run_backups::
"any" usebundle => create_mysql_backup_cron_job(@(cfg),"$(cfg[backup_dir])/roundcube.sql","users","false");
reports:
# "mysql_$(cfg[db_name])_users_exists"::
# "DB EXISTS! ROUNDCUBE";
# "sql_backup_exists"::
# "SQL_BACKUP_EXISTS FILE $(cfg[backup_dir])/roundcube.sql"
# ;
# run_backups&(!config_exists)&backup_config_exists::
# "ROUNDCUBE CAN RESTORE config";
# "run_backups"::
# "ROUNDCUBE SHOULD RUN BACKUPS";
}
2023-11-01 14:59:28 +00:00
bundle agent download_roundcube(cfg)
{
vars:
"tgzname" string => "roundcubemail-$(cfg[version])-complete.tar.gz";
"dldir" string =>"$(sys.workdir)/data/agent/roundcube";
"dst" string => "$(dldir)/$(tgzname)";
files:
"$(dldir)/."
create => "true",
handle => "roundcube_agentdir_created";
methods:
"any" usebundle => download_file("wget",
"https://github.com/roundcube/roundcubemail/releases/download/$(cfg[version])/$(tgzname)",
"$(dst)","roundcube_tgz_file",'{}');
}