password_recover plugin integration

This commit is contained in:
Tobias Herre 2023-11-08 18:08:24 +01:00
parent 2ce1a16cb1
commit 6a8f8e5b5c
1 changed files with 70 additions and 5 deletions

View File

@ -8,6 +8,7 @@ bundle agent roundcube(cfg)
classes: classes:
"dlbyversion" expression => not (isvariable ("cfg[src_tgz]")); "dlbyversion" expression => not (isvariable ("cfg[src_tgz]"));
"keep_installer" expression => isvariable("cfg[keep_installer]");
"roundcube_untar" expression => not(fileexists("$(install_sub_dir)/index.php")); "roundcube_untar" expression => not(fileexists("$(install_sub_dir)/index.php"));
@ -83,7 +84,8 @@ methods:
"any" usebundle => mysql_table_exists(@(cfg),"users"); "any" usebundle => mysql_table_exists(@(cfg),"users");
config_exists|roundcube_config_repaired:: config_exists|roundcube_config_repaired::
"any" usebundle => rm_rf ("$(install_sub_dir)/installer"); "any" usebundle => rm_rf ("$(install_sub_dir)/installer"),
if => not(keep_installer);
commands: commands:
roundcube_untar|roundcube_tgz_file_repaired:: roundcube_untar|roundcube_tgz_file_repaired::
@ -200,14 +202,18 @@ vars:
vars: vars:
"exx" string => "^\s*\$config\s*\['$(i)'\s*]\s*=\s*(?!33).*$"; "exx" string => "^\s*\$config\s*\['$(i)'\s*]\s*=\s*(?!33).*$";
"thev" string => "$($(v)[$(i)])";
replace_patterns: replace_patterns:
"^\s*\$config\s*\['$(i)'\s*]\s*=\s*(?!$($(v)[$(i)]);$).*" # "^\s*\$config\s*\['$(i)'\s*]\s*=\s*(?!$($(v)[$(i)]);$).*"
"^\s*\$config\s*\['$(i)'\s*]\s*=\s*(?!$(ev[$(i)]);$).*"
comment => "Correct the value '$(i)'", comment => "Correct the value '$(i)'",
#replace_with => value("$config['$(i)']=$($(v)[$(i)])"), #replace_with => value("$config['$(i)']=$($(v)[$(i)])"),
replace_with => value("$config['$(i)']=$($(v)[$(i)]);"), replace_with => value("$config['$(i)']=$($(v)[$(i)]);"),
classes => results("bundle", "replace_attempted_$(i)"); classes => results("bundle", "replace_attempted_$(i)");
reports: reports:
"THE V: $(thev)";
insert_lines: insert_lines:
# If the line doesn't exist, or there is more than one occurrence # If the line doesn't exist, or there is more than one occurrence
@ -239,7 +245,7 @@ vars:
"settings[db_dsnw]" string => "'mysql://$(cfg[db_user]):$(cfg[db_pass])@$(cfg[db_host])/$(cfg[db_name])'"; "settings[db_dsnw]" string => "'mysql://$(cfg[db_user]):$(cfg[db_pass])@$(cfg[db_host])/$(cfg[db_name])'";
"settings[language]" string => "'us_EN'"; "settings[language]" string => "'us_EN'";
"settings[plugins]" string => "['acl', 'archive', 'attachment_reminder', 'emoticons', 'enigma', 'hide_blockquote', 'identicon', 'jqueryui', 'managesieve', 'markasjunk', 'newmail_notifier', 'password', 'vcard_attachments', 'zipdownload']";
"idx" slist => getindices(@(cfg[settings])); "idx" slist => getindices(@(cfg[settings]));
"settings[$(idx)]" string => "$(cfg[settings][$(idx)])"; "settings[$(idx)]" string => "$(cfg[settings][$(idx)])";
@ -294,6 +300,65 @@ files:
edit_line => rc_line_based("$(this.bundle).settings"), edit_line => rc_line_based("$(this.bundle).settings"),
handle => "roundcube_password_config_edited", handle => "roundcube_password_config_edited",
depends_on => {"roundcube_password_config_created"}; depends_on => {"roundcube_password_config_created"};
} }
bundle agent roundcube_install_password_recovery_plugin(param_cfg)
{
classes:
"run_git" expression => not(fileexists("$(roundcube.install_sub_dir)/plugins/password_recovery"));
vars:
"config_file" string => "$(roundcube.install_sub_dir)/plugins/password_recovery/config.inc.php";
"default_cfg" data => '{
"password_recovery_git_url":"https://srcsrv.wikimedia.de/WMDE/roundcube-password_recovery.git -b wmde",
}';
"cfg" data => mergedata(@(default_cfg),@(param_cfg));
"settings[pr_db_dsn]" string => "'mysql://$(cfg[db_user]):$(cfg[db_pass])@$(cfg[db_host])/$(cfg[db_name])'";
"settings[pr_fields]" string => "[ 'altemail' => 'alt_email']";
"settings[pr_default_smtp_server]" string => "'localhost:25'";
"idx" slist => getindices(@(cfg[settings]));
"settings[$(idx)]" string => "$(cfg[settings][$(idx)])";
methods:
"any" usebundle => install_wget, handle=>"roundcube_wget_installed";
commands:
run_git::
"git clone --depth 1 $(cfg[password_recovery_git_url]) $(roundcube.install_sub_dir)/plugins/password_recovery && chown -R $(apache.www_user):$(apache.www_group) $(roundcube.install_sub_dir)/plugins/password_recovery"
contain => wmde_cmd_useshell,
handle => "roundcube_password_recovery_git_cloned",
depends_on => {"roundcube_wget_installed"};
!run_git::
"/usr/bin/true"
inform => "false",
handle => "roundcube_password_recovery_git_cloned";
files:
"$(config_file)"
perms => m("644"),
copy_from => seed_cp("$(def.wmde_lib)/templates/roundcube-password_recovery-config.inc.php.mustache"),
depends_on => {"roundcube_password_recovery_git_cloned"},
handle => "roundcube_password_recover_config_created";
"$(config_file)"
edit_line => rc_line_based("$(this.bundle).settings"),
handle => "roundcube_password_recover_config_edited",
depends_on => {"roundcube_password_recover_config_created"};
reports:
run_git::
"Run git";
!run_git::
"Dont run git";
}