-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.devmaster.inc
More file actions
231 lines (204 loc) · 8.63 KB
/
install.devmaster.inc
File metadata and controls
231 lines (204 loc) · 8.63 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?php
/**
* @file install the hostmaster system
*/
/**
* Validation hook for devmaster-install
*/
function drush_devudo_provision_devmaster_install_validate($site = NULL) {
// set defaults for this whole script
// those are settings that are not prompted to the user but still overridable
drush_set_default('version', provision_version());
$version = drush_get_option('version');
drush_set_default('profile', 'devmaster');
$profile = drush_get_option('profile');
$aegir_root = drush_set_default('aegir_root', drush_server_home());
drush_set_default('root', $aegir_root . '/' . $profile . '-' . $version);
drush_set_default('r', drush_get_option('root'));
drush_set_default('script_user', provision_current_user());
drush_set_default('web_group', _provision_default_web_group());
drush_set_default('http_service_type', 'apache');
drush_set_default('drush_make_version', '6.x-2.3');
drush_set_default('aegir_db_user', 'root');
drush_set_default('client_name', 'admin');
$aegir_db_user = drush_get_option('aegir_db_user');
drush_set_default('makefile', dirname(__FILE__) . '/build-devmaster.make');
drush_print("DEVUDO DEVSHOP automated install script");
drush_print("==============================================================================");
if (!$site || !drush_get_option('aegir_host', NULL) || !drush_get_option('aegir_db_pass', NULL) || filter_var(drush_get_option('client_email'), FILTER_VALIDATE_EMAIL)) {
drush_print("Some settings have not been provided and will now be prompted.
Don't worry: you will get to review those settings after the final install");
}
// now we prompt the user for settings if not provided or not sane
if (!$site) {
$site = drush_prompt(dt("Aegir frontend URL"), provision_fqdn());
}
drush_set_option('site', $site);
drush_set_default('aegir_host', provision_fqdn());
drush_set_default('aegir_db_host', 'localhost');
if (is_null(drush_get_option('aegir_db_pass', NULL))) {
// XXX: may not be portable everywhere?
system('stty -echo');
drush_set_option('aegir_db_pass', drush_prompt(dt('MySQL privileged user ("!root") password', array('!root' => $aegir_db_user))));
system('stty echo');
print "\n"; // add a newline since the user's didn't print
}
if (drush_get_option('aegir_host') == 'localhost') {
$default_email = 'webmaster@example.com';
} else {
$default_email = 'webmaster@' . drush_get_option('aegir_host');
}
drush_set_default('client_email', $default_email);
while (!filter_var(drush_get_option('client_email'), FILTER_VALIDATE_EMAIL) && !drush_get_context('DRUSH_AFFIRMATIVE')) {
drush_set_option('client_email', drush_prompt(dt("Admin user e-mail"), $default_email));
}
drush_print(dt('
This script will operate the following changes in your system:
1. Create server-level configuration directories
2. Download drush_make
3. Create the Hostmaster frontend platform
4. Install the frontend site
5. Setup the dispatcher (a user cron job)
We are making the following assumptions:
* you have read and are following the install instructions at:
http://community.aegirproject.org/installing
* the FQDN of this machine is valid and resolves
* you are executing this script as your "aegir" user
The following settings will be used:
Aegir frontend URL: !site
Master server FQDN: !fqdn
Aegir root: !home
Aegir user: !user
Web group: !web
Web server: !web_server
Aegir DB host: !db_host
Aegir DB user: !db_user
Aegir DB password: !db_pass
Drush make version: !drush_make
Aegir version: !version
Aegir platform path: !root
Aegir makefile: !makefile
Aegir profile: !profile
Admin email: !email
Working Copy: !working
', array('!site' => $site,
'!fqdn' => drush_get_option('aegir_host'),
'!home' => drush_get_option('aegir_root'),
'!user' => drush_get_option('script_user'),
'!web' => drush_get_option('web_group'),
'!web_server' => drush_get_option('http_service_type'),
'!db_host' => drush_get_option('aegir_db_host'),
'!db_user' => drush_get_option('aegir_db_user'),
'!db_pass' => is_null(drush_get_option('aegir_db_pass', NULL, 'process')) ? '<previously set>' : '<prompted>',
'!drush_make' => drush_get_option('drush_make_version'),
'!version' => drush_get_option('version'),
'!root' => drush_get_option(array('r', 'root')),
'!profile' => drush_get_option('profile'),
'!makefile' => drush_get_option('makefile'),
'!email' => drush_get_option('client_email'),
'!working' => drush_get_option('working-copy'),
)));
if (!drush_confirm(dt('Do you really want to proceed with the install'))) {
return drush_set_error('PROVISION_CANCEL_INSTALL', dt('Installation aborted by user'));
}
return TRUE;
}
/**
* Drush command to install hostmaster.
*/
function drush_devudo_provision_devmaster_install($site = NULL) {
$version = drush_get_option('version');
$site = drush_get_option('site', provision_fqdn());
$aegir_root = drush_get_option('aegir_root');
$platform = drush_get_option(array('r', 'root'));
$aegir_db_user = drush_get_option('aegir_db_user');
$aegir_db_pass = drush_get_option('aegir_db_pass');
$server = '@server_master';
$master_context = array(
'context_type' => 'server',
// files
'remote_host' => drush_get_option('aegir_host'),
'aegir_root' => $aegir_root,
'script_user' => drush_get_option('script_user'),
// apache or nginx or..
'http_service_type' => drush_get_option('http_service_type'),
'web_group' => drush_get_option('web_group'),
'master_url' => "http://" . $site,
);
$master_db = sprintf("mysql://%s:%s@%s", urlencode($aegir_db_user), urlencode($aegir_db_pass), drush_get_option('aegir_db_host'));
if (drush_get_option('aegir_host') == drush_get_option('aegir_db_host')) {
$master_context['db_service_type'] = 'mysql';
$master_context['master_db'] = $master_db;
$dbserver = $server;
} else {
$dbserver = '@server_' . drush_get_option('aegir_db_host');
$dbserver_context = array(
'remote_host' => drush_get_option('aegir_db_host'),
'context_type' => 'server',
'db_service_type' => 'mysql',
'master_db' => $master_db,
);
drush_backend_invoke_args("provision-save", array($dbserver), $dbserver_context);
provision_backend_invoke($dbserver, 'provision-verify');
}
drush_backend_invoke_args("provision-save", array($server), $master_context);
provision_backend_invoke($server, 'provision-verify');
// exit if an error has occured.
if (drush_get_error()) {
return false;
}
if (drush_get_option('backend-only')) {
return;
}
if (!function_exists('drush_make_drush_command')) {
drush_backend_invoke('dl', array('drush_make-' . drush_get_option('drush_make_version'), 'destination' => $aegir_root . '/.drush/'));
}
$platform_name = '@platform_hostmaster';
drush_backend_invoke_args("provision-save", array($platform_name), array(
'context_type' => 'platform',
'server' => $server,
'web_server' => $server,
'root' => $platform,
'makefile' => drush_get_option('makefile'),
));
// propagate working-copy args downward
$options = array();
if (drush_get_option('working-copy')) {
$options['working-copy'] = 1;
}
provision_backend_invoke($platform_name, 'provision-verify', array(), $options);
// exit if an error has occured.
if (drush_get_error()) {
return false;
}
$site_name = '@hostmaster';
drush_backend_invoke_args("provision-save", array($site_name), array(
'context_type' => 'site',
'platform' => $platform_name,
'db_server' => $dbserver,
'uri' => $site,
'client_name' => drush_get_option('client_name'),
'profile' => drush_get_option('profile'),
));
$data = provision_backend_invoke($site_name, 'provision-install', array(), array('client_email' => drush_get_option('client_email')));
provision_backend_invoke($site_name, 'provision-verify');
// exit if an error has occured.
if (drush_get_error()) {
return false;
}
drush_print(dt("Initializing the hosting system"));
provision_backend_invoke($site_name, 'hosting-setup');
drush_print("");
drush_print("==============================================================================");
drush_print("");
drush_print("");
drush_print(dt("Congratulations, DEVSHOP has now been installed."));
drush_print("");
drush_print(dt("You should now log in to the DEVSHOP frontend by opening the following link in your web browser:"));
drush_print("");
drush_print($data['context']['login_link']);
drush_print("");
drush_print("");
drush_print("==============================================================================");
drush_print("");
}