166 lines
5.1 KiB
CFEngine3
166 lines
5.1 KiB
CFEngine3
#
|
|
#
|
|
#
|
|
|
|
bundle agent vimbadmin(cfg)
|
|
{
|
|
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:
|
|
"pkgs" slist => {
|
|
"git"
|
|
};
|
|
|
|
|
|
"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])'";
|
|
"vsettings[resources.doctrine2.connection.options.password]" string => "'$(cfg[db_pass])'";
|
|
"vsettings[resources.doctrine2.connection.options.host]" string => "'$(cfg[db_host])'";
|
|
"vsettings[securitysalt]" string => "'$(cfg[security_salt])'";
|
|
"vsettings[resources.auth.oss.rememberme.salt]" string => "'$(cfg[rememberme_salt])'";
|
|
"vsettings[defaults.mailbox.password_salt]" string => "'$(cfg[password_salt])'";
|
|
"vsettings[skipInstallPingback]" string => "1";
|
|
"vsettings[server.email.name]" string => "$(cfg[server_email_name])";
|
|
"vsettings[server.email.address]" string => "$(cfg[server_email_address])";
|
|
"vsettings[resources.mail.transport.type]" string => "'smtp'";
|
|
"vsettings[resources.mail.transport.host]" string => "'127.0.0.1'";
|
|
"vsettings[defaults.mailbox.password_scheme]" string => "crypt:sha256";
|
|
#
|
|
classes:
|
|
"vimbadmin_checked_out" expression => fileexists("$(cfg[dst_dir])/.git");
|
|
"pull_it" expression => eval("1 == $(r)","class","infix"),
|
|
depends_on => {"rand_assigned"};
|
|
|
|
|
|
"vimbadmin_reconfigure" expression =>
|
|
or(
|
|
not(fileexists("$(sys.workdir)/data/agent/vimbadmin/configured.txt")),
|
|
not(fileexists("$(cfg[install_dir])/public"))
|
|
);
|
|
vars:
|
|
"clone_cmd" string => "$(git.exe) clone $(cfg[clone_args]) $(cfg[src]) $(cfg[dst_dir])";
|
|
|
|
|
|
files:
|
|
|
|
"$(sys.workdir)/data/public/."
|
|
create => "true",
|
|
perms => m(755),
|
|
handle => "vimbadmin_workdir_created";
|
|
|
|
"$(sys.workdir)/data/public/vimbadmin.tgz"
|
|
copy_from => remote_dcp("$(cfg[src_tgz])","$(sys.policy_hub)"),
|
|
handle => "vimbadmin_tgz_copied",
|
|
depends_on => {"vimbadmin_workdir_created"},
|
|
perms => m(644),
|
|
classes => if_repaired(vimbadmin_reconfigure);
|
|
|
|
"$(cfg[install_dir])/public/.htaccess"
|
|
copy_from => seed_cp("$(cfg[install_dir])/public/.htaccess.dist"),
|
|
perms => m("644"),
|
|
depends_on => {"vimbadmin_untarred"},
|
|
handle => "vimbadmin_htaccess_copied";
|
|
|
|
|
|
"$(cfg[install_dir])/application/configs/application.ini"
|
|
copy_from => seed_cp("$(cfg[install_dir])/application/configs/application.ini.dist"),
|
|
perms => m("644"),
|
|
depends_on => {"vimbadmin_untarred"},
|
|
handle => "vimbadmin_appini_copied";
|
|
|
|
|
|
|
|
"$(cfg[install_dir])/application/configs/application.ini"
|
|
edit_line => set_variable_values("vimbadmin.vsettings"),
|
|
handle => "vimbadmin_appini_edited",
|
|
depends_on => { "vimbadmin_appini_copied" };
|
|
|
|
|
|
|
|
vimbadmin_reconfigure::
|
|
"$(sys.workdir)/data/agent/vimbadmin/configured.txt"
|
|
depends_on => { "vimbadmin_tgz_copied" },
|
|
delete => tidy;
|
|
|
|
"$(sys.workdir)/data/agent/vimbadmin/configured.txt"
|
|
depends_on => { "vimbadmin_composed" },
|
|
create => "true",
|
|
content => "ok";
|
|
|
|
|
|
|
|
commands:
|
|
|
|
"(!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"
|
|
args => "-c '/usr/bin/tar xf $(sys.workdir)/data/public/vimbadmin.tgz --strip-components=1 -C $(cfg[install_dir])'",
|
|
handle => "vimbadmin_untarred",
|
|
contain => vimbadmin_cmd;
|
|
|
|
"/bin/sh"
|
|
# args => "-c 'cd $(cfg[install_dir]) && $(php_composer.exe) -q -n create-project --prefer-dist --no-dev opensolutions/vimbadmin'",
|
|
args => "-c 'export HOME=$(cfg[install_dir]) && cd $(cfg[install_dir]) && $(php_composer.exe) update -q --no-cache && $(php_composer.exe) install --no-cache -q --prefer-dist --no-dev'",
|
|
handle => "vimbadmin_composed",
|
|
depends_on => {
|
|
"vimbadmin_pkgs_installed"
|
|
},
|
|
contain => vimbadmin_cmd;
|
|
|
|
#"/bin/sh"
|
|
#args => '-c $(php
|
|
|
|
!vimbadmin_reconfigure::
|
|
"/usr//bin/true"
|
|
inform => "false",
|
|
handle => "vimbadmin_untarred";
|
|
|
|
|
|
|
|
methods:
|
|
"any" usebundle => wmde_install_packages(@(pkgs),"vimbadmin");
|
|
"any" usebundle => php_composer;
|
|
"any" usebundle => mysql_table_exists(@(cfg),"admin");
|
|
|
|
vimbadmin_restore_db_file::
|
|
"any" usebundle => create_mysql_backup_cron_job(@(cfg),"$(cfg[restore_db_file])","admin","true");
|
|
|
|
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";
|
|
}
|
|
|
|
|
|
body contain vimbadmin_cmd
|
|
{
|
|
|
|
exec_owner => "$(apache.www_user)";
|
|
exec_group => "$(apache.www_group)";
|
|
useshell=>"useshell";
|
|
|
|
}
|