From 1cd5758f05aa5f8c2a7b67fecf8acb167aeee962 Mon Sep 17 00:00:00 2001 From: Tobias Herre Date: Fri, 13 Oct 2023 21:08:47 +0200 Subject: [PATCH] Feature to restore database implemented --- vimbadmin.cf | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/vimbadmin.cf b/vimbadmin.cf index 0da1e34..4474de8 100644 --- a/vimbadmin.cf +++ b/vimbadmin.cf @@ -4,11 +4,13 @@ bundle agent vimbadmin(cfg) { -vars: - "r" int => randomint(1,5), - handle => "rand_assigned"; +classes: + "vimbadmin_restore_db_file" expression => isvariable("cfg[restore_db_file]"); - + vimbadmin_restore_db_file:: + "vimbadmin_restore_db" expression => fileexists("$(cfg[restore_db_file])"); + +vars: "vsettings[resources.doctrine2.connection.options.driver]" string => "'$(cfg[db_driver])'"; "vsettings[resources.doctrine2.connection.options.dbname]" string => "'$(cfg[db_name])'"; "vsettings[resources.doctrine2.connection.options.user]" string => "'$(cfg[db_user])'"; @@ -88,11 +90,17 @@ files: commands: - "!mysql_$(cfg[db_name])_admin_exists":: + "(!mysql_$(cfg[db_name])_admin_exists)&(!vimbadmin_restore_db)":: "cd $(cfg[install_dir]) && ./bin/doctrine2-cli.php orm:schema-tool:create " contain => wmde_cmd_useshell, + handle => "vimbadmin_db_initialized", depends_on => {"vimbadmin_appini_edited"}; + "(!mysql_$(cfg[db_name])_admin_exists)&vimbadmin_restore_db":: + "mysql -u $(cfg[db_user]) -p$(cfg[db_pass]) -h$(cfg[db_host]) $(cfg[db_name]) < $(cfg[restore_db_file])" + contain => wmde_cmd_useshell, + depends_on => {"vimbadmin_appini_edited"}; + vimbadmin_reconfigure:: "/bin/sh" @@ -121,6 +129,16 @@ methods: "any" usebundle => mysql_table_exists(@(cfg),"admin"); reports: +# "VIMBADMIN $(cfg[restore_db_file])"; + +# "vimbadmin_restore_db_file":: +# "RESTORE_DB_FILE"; + +# "vimbadmin_restore_db":: +# "RESTORE_DB"; + +# "(!mysql_$(cfg[db_name])_admin_exists)&vimbadmin_restore_db":: +# "Should restore db"; }