forked from omega8cc/provision_civicrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.provision.inc
97 lines (75 loc) · 3.46 KB
/
install.provision.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* implementation of hook_pre_provision_install
*/
function drush_civicrm_pre_provision_install($url = NULL) {
/*
if (d()->type == 'site') {
// if necessary ...
}
*/
}
/**
* implementation of hook_post_provision_install
*/
function drush_civicrm_post_provision_install($url = null) {
if (d()->type == 'site') {
// Check if the CiviCRM code base is present in the platform
// Note: after putting the code there, you must verify the platform.
if (! _provision_civicrm_get_package_path()) {
// drush_log(dt('CiviCRM: not found in package path, skipping installation.'));
return;
}
// Quietly exit if we're trying to install an old/unsupported CiviCRM
// Don't completely fail, the user can install manually (for migrations/upgrades).
$module = _provision_civicrm_get_package_info();
if ($module['version'] < 3) {
drush_log(dt('CiviCRM: CiviCRM version is not supported, too old: ' . check_plain($module['version'])));
return;
}
drush_log(dt("CiviCRM: Starting installation..."));
$db_user = drush_get_option('db_user', NULL, 'site');
$db_passwd = drush_get_option('db_passwd', NULL, 'site');
$db_host = drush_get_option('db_host', NULL, 'site');
$db_name = drush_get_option('db_name', NULL, 'site');
drush_set_option('dbuser', $db_user);
drush_set_option('dbpass', $db_passwd);
drush_set_option('dbhost', $db_host);
drush_set_option('dbname', $db_name);
$sitekey = md5(uniqid( '', true ) . $db_user);
drush_set_option('sitekey', $sitekey);
drush_set_option('civicrm_sitekey', $sitekey, 'site');
// Generates the civicrm.settings.php
if (drush_civicrm_install_validate()) {
drush_civicrm_install();
}
// Install the DB, not sure why the drush module is not doing it
global $crmPath;
$dsn = "mysql://{$db_user}:{$db_passwd}@{$db_host}/{$db_name}?new_link=true";
$drupalRoot = drush_get_context('DRUSH_DRUPAL_ROOT');
// $crmPath = $drupalRoot . '/sites/all/modules/civicrm'; // FIXME
$crmPath = _provision_civicrm_get_package_path();
$sqlPath = $crmPath . DIRECTORY_SEPARATOR . 'sql';
// include civicrm installer helper file (otherwise PEAR DB.php will fail to include parts)
$include_path = $crmPath . "/packages/:" . get_include_path( );
set_include_path( $include_path );
$civicrmInstallerHelper = $crmPath . "/install/civicrm.php";
if ( !file_exists($civicrmInstallerHelper) ) {
drush_log(dt("CiviCRM: installer helper file is missing, searched for @file.", array('@file' => $civicrmInstallerHelper)), 'error');
}
require_once "$civicrmInstallerHelper";
drush_log(dt("CiviCRM: importing @sqlPath civicrm.mysql", array('@sqlPath' => $sqlPath)));
civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm.mysql');
drush_log(dt("CiviCRM: importing @sqlPath civicrm_data.mysql", array('@sqlPath' => $sqlPath)));
civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm_data.mysql');
drush_log(dt("CiviCRM: importing @sqlPath civicrm_acl.mysql", array('@sqlPath' => $sqlPath)));
civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm_acl.mysql');
// Enable civicrm module before setting up civicron role,
// as we need it to expose its permissions.
module_enable(array('civicrm'));
_provision_civicrm_create_civicron_user();
// Fix some paths:
_provision_civicrm_fixresourceurls();
drush_log(dt("CiviCRM: Finished installation."), 'ok');
}
}