| 33 |
'#size' => 20, |
'#size' => 20, |
| 34 |
'#required' => TRUE, |
'#required' => TRUE, |
| 35 |
); |
); |
| 36 |
|
$form['druplet_jailkit'] = array( |
| 37 |
|
'#type' => 'checkbox', |
| 38 |
|
'#title' => t('Jail SFTP users using JailKit (Advanced)'), |
| 39 |
|
'#description' => t('This option allows for separate SFTP accounts to be set up for each Druplet. You must install JailKit for this to work. See the README.txt file for more information.'), |
| 40 |
|
'#default_value' => variable_get('druplet_jailkit', FALSE), |
| 41 |
|
); |
| 42 |
|
|
| 43 |
return system_settings_form($form); |
return system_settings_form($form); |
| 44 |
} |
} |
| 269 |
} |
} |
| 270 |
fclose($file); |
fclose($file); |
| 271 |
|
|
| 272 |
// 9) Chown the sites directory and settings.php file to apache |
if (variable_get('druplet_jailkit', FALSE)) { |
| 273 |
|
|
| 274 |
|
// 9) Create and Jail a System User |
| 275 |
|
$group = variable_get('druplet_group', 'druplet'); |
| 276 |
|
$site_name = $site->subdomain; |
| 277 |
|
$host = $site->host; |
| 278 |
|
$command = "sudo /usr/sbin/useradd -g $group $site_name"; |
| 279 |
|
if ($error = shell_exec($command)) { |
| 280 |
|
drupal_set_message(t('The user could not be added, likely because Apache does not have access to useradd.')); |
| 281 |
|
} |
| 282 |
|
|
| 283 |
|
// jail user |
| 284 |
|
$command = "sudo /usr/sbin/jk_jailuser -m -j /home/jail $site_name"; |
| 285 |
|
if ($error = shell_exec($command)) { |
| 286 |
|
drupal_set_message(t('User was not jailed. Do you have JailKit installed? http://olivier.sessink.nl/jailkit')); |
| 287 |
|
} |
| 288 |
|
|
| 289 |
|
// change user password |
| 290 |
|
$password = crypt($site->db_password); |
| 291 |
|
$command = "sudo usermod -p '$password' $site_name"; |
| 292 |
|
if ($error = shell_exec($command)) { |
| 293 |
|
drupal_set_message(t('The user\'s password could not be changed, likely because Apache does not have access to usermod.')); |
| 294 |
|
} |
| 295 |
|
|
| 296 |
|
// 10) Create directory in user jail and bind it to the site directory |
| 297 |
|
|
| 298 |
|
$command = "sudo mkdir /home/jail/home/$site_name/$site_name.$host"; |
| 299 |
|
if ($error = shell_exec($command)) { |
| 300 |
|
drupal_set_message(t('Directory could not be created in jail.')); |
| 301 |
|
} |
| 302 |
|
|
| 303 |
|
// bind site directory to user's home directory |
| 304 |
|
$command = "sudo mount --bind /var/www/html/sites/$site_name.$host /home/jail/home/$site_name/$site_name.$host"; |
| 305 |
|
if ($error = shell_exec($command)) { |
| 306 |
|
drupal_set_message(t('User jail could not be bound to site directory.')); |
| 307 |
|
} |
| 308 |
|
} |
| 309 |
|
|
| 310 |
|
// 11) Chown the sites directory and settings.php file to apache |
| 311 |
// chown site directory to user |
// chown site directory to user |
| 312 |
$command = "sudo chown -R $site_name /var/www/html/sites/$site_name.$host"; |
$command = "sudo chown -R $site_name /var/www/html/sites/$site_name.$host"; |
| 313 |
if ($error = shell_exec($command)) { |
if ($error = shell_exec($command)) { |
| 320 |
drupal_set_message(t('Fatal Error.')); |
drupal_set_message(t('Fatal Error.')); |
| 321 |
} |
} |
| 322 |
|
|
| 323 |
// 10) Run installation profile |
// 12) Run installation profile |
| 324 |
|
|
| 325 |
global $db_url; |
global $db_url; |
| 326 |
$default_url = $db_url; |
$default_url = $db_url; |
| 331 |
|
|
| 332 |
require_once $_SERVER['DOCUMENT_ROOT'] .'/includes/install.inc'; |
require_once $_SERVER['DOCUMENT_ROOT'] .'/includes/install.inc'; |
| 333 |
|
|
| 334 |
// 10b) Verify existence of all required modules. |
// 12b) Verify existence of all required modules. |
| 335 |
$modules = drupal_verify_profile($site->profile, NULL); |
$modules = drupal_verify_profile($site->profile, NULL); |
| 336 |
|
|
| 337 |
// 10c) Perform actual installation defined in the profile. |
// 12c) Perform actual installation defined in the profile. |
| 338 |
drupal_install_profile($site->profile, $modules); |
drupal_install_profile($site->profile, $modules); |
| 339 |
variable_set('install_profile', $site->profile); |
variable_set('install_profile', $site->profile); |
| 340 |
drupal_maintenance_theme(); |
drupal_maintenance_theme(); |
| 396 |
$header = array(t('Parameter'), t('Value')); |
$header = array(t('Parameter'), t('Value')); |
| 397 |
$rows = array(); |
$rows = array(); |
| 398 |
$rows[] = array(t('Site URL'), l($site_url, $site_url, NULL, NULL, NULL, TRUE)); |
$rows[] = array(t('Site URL'), l($site_url, $site_url, NULL, NULL, NULL, TRUE)); |
| 399 |
|
if (variable_get('druplet_jailkit', TRUE)) { |
| 400 |
|
$rows[] = array(t('SFTP Host'), $subdomain .'.'. $host); |
| 401 |
|
$rows[] = array(t('SFTP Username'), $subdomain); |
| 402 |
|
$rows[] = array(t('SFTP Password'), $node->db_password); |
| 403 |
|
} |
| 404 |
$rows[] = array(t('phpMyAdmin URL'), l($phpmyadmin_url, $phpmyadmin_url, NULL, NULL, NULL, TRUE)); |
$rows[] = array(t('phpMyAdmin URL'), l($phpmyadmin_url, $phpmyadmin_url, NULL, NULL, NULL, TRUE)); |
| 405 |
$rows[] = array(t('Database'), $node->db_name); |
$rows[] = array(t('Database'), $node->db_name); |
| 406 |
$rows[] = array(t('DB Username'), $node->db_user); |
$rows[] = array(t('DB Username'), $node->db_user); |