From 6a8f8e5b5c030e8e40e612c1e61b6be841657fb5 Mon Sep 17 00:00:00 2001 From: Tobias Herre Date: Wed, 8 Nov 2023 18:08:24 +0100 Subject: [PATCH] password_recover plugin integration --- roundcube.cf | 75 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/roundcube.cf b/roundcube.cf index 3c5b7c1..9ed842d 100644 --- a/roundcube.cf +++ b/roundcube.cf @@ -8,6 +8,7 @@ bundle agent roundcube(cfg) classes: "dlbyversion" expression => not (isvariable ("cfg[src_tgz]")); + "keep_installer" expression => isvariable("cfg[keep_installer]"); "roundcube_untar" expression => not(fileexists("$(install_sub_dir)/index.php")); @@ -83,7 +84,8 @@ methods: "any" usebundle => mysql_table_exists(@(cfg),"users"); 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: roundcube_untar|roundcube_tgz_file_repaired:: @@ -200,14 +202,18 @@ vars: vars: "exx" string => "^\s*\$config\s*\['$(i)'\s*]\s*=\s*(?!33).*$"; + "thev" string => "$($(v)[$(i)])"; + 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)'", #replace_with => value("$config['$(i)']=$($(v)[$(i)])"), replace_with => value("$config['$(i)']=$($(v)[$(i)]);"), classes => results("bundle", "replace_attempted_$(i)"); reports: + "THE V: $(thev)"; insert_lines: # 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[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])); "settings[$(idx)]" string => "$(cfg[settings][$(idx)])"; @@ -294,6 +300,65 @@ files: edit_line => rc_line_based("$(this.bundle).settings"), handle => "roundcube_password_config_edited", 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"; +} + +