Download by version is possible

This commit is contained in:
Tube 2023-11-01 15:59:28 +01:00
parent ee8b036231
commit 9d503a50a2
1 changed files with 64 additions and 14 deletions

View File

@ -5,12 +5,13 @@
bundle agent roundcube(cfg)
{
classes:
"dlbyversion" expression => not (isvariable ("cfg[src_tgz]"));
"roundcube_untar" expression => not(fileexists("$(cfg[install_sub_dir])/index.php"));
"config_exists" expression => fileexists("$(cfg[install_sub_dir])/config/config.inc.php");
"roundcube_untar" expression => not(fileexists("$(install_sub_dir)/index.php"));
"config_exists" expression => fileexists("$(install_sub_dir)/config/config.inc.php");
"backup_config_exists" expression => fileexists("$(cfg[backup_dir])/config.inc.php");
@ -22,21 +23,51 @@ classes:
"sql_backup_exists" expression => fileexists("$(cfg[backup_dir])/roundcube.sql");
vars:
"dlfile" string => "$(sys.workdir)/data/public/$(cfg[src_tgz])";
files:
"$(dlfile)"
copy_from => remote_dcp("$(def.hub_public_dir)/$(cfg[src_tgz])","$(sys.policy_hub)"),
handle => "roundcube_tgz_copied",
classes => if_repaired ("roundcube_untar"),
perms => m(644);
"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:
dlbyversion::
"dl by version";
!dlbyversion::
"not dl by version";
files:
"$(dldir)/."
create => "true",
handle => "roundcube_agent_dir_created";
methods:
"any" usebundle => download_file("$(dltype)","$(dlsrc)","$(dlfile)","roundcube_tgz_file",'{}'),
handle => "roundcube_tgz_copied",
depends_on => {"roundcube_agent_dir_created"},
classes => if_repaired ("roundcube_untar");
# "$(dlfile)"
# copy_from => remote_dcp("$(def.hub_public_dir)/$(cfg[src_tgz])","$(sys.policy_hub)"),
# perms => m(644);
files:
"$(cfg[install_dir])/public"
link_from => ln_s("$(cfg[install_sub_dir])"),
link_from => ln_s("$(install_sub_dir)"),
move_obstructions => "true",
depends_on => {"roundcube_untarred"};
run_backups&(!config_exists)&backup_config_exists::
"$(cfg[install_sub_dir])/config/config.inc.php"
"$(install_sub_dir)/config/config.inc.php"
copy_from => local_cp("$(cfg[backup_dir])/config.inc.php"),
perms => m("644"),
classes => if_repaired("roundcube_config_repaired"),
@ -44,14 +75,14 @@ files:
run_backups&config_exists::
"$(cfg[backup_dir])/config.inc.php"
copy_from => local_dcp("$(cfg[install_sub_dir])/config/config.inc.php"),
copy_from => local_dcp("$(install_sub_dir)/config/config.inc.php"),
depends_on => {"roundcube_untarred"};
methods:
"any" usebundle => mysql_table_exists(@(cfg),"users");
config_exists|roundcube_configr_repaired::
"any" usebundle => rm_rf ("$(cfg[install_sub_dir])/installer");
"any" usebundle => rm_rf ("$(install_sub_dir)/installer");
commands:
roundcube_untar::
@ -94,3 +125,22 @@ reports:
# "ROUNDCUBE SHOULD RUN BACKUPS";
}
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",'{}');
}