elgg-install.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Docker CLI Elgg installer script
  4. */
  5. $autoload_path = '/var/www/html/vendor/autoload.php';
  6. $autoload_available = include_once($autoload_path);
  7. if (!$autoload_available) {
  8. die("Couldn't include '$autoload_path'. Did you run `composer install`?");
  9. }
  10. $params = array(
  11. // database parameters
  12. 'dbhost' => getenv('ELGG_DB_HOST'),
  13. 'dbprefix' => getenv('ELGG_DB_PREFIX'),
  14. 'dbuser' => getenv('ELGG_DB_USER'),
  15. 'dbpassword' => getenv('ELGG_DB_PASS'),
  16. 'dbname' => getenv('ELGG_DB_NAME'),
  17. // site settings
  18. 'sitename' => getenv('ELGG_SITE_NAME'),
  19. 'siteemail' => getenv('ELGG_SITE_EMAIL'),
  20. 'wwwroot' => getenv('ELGG_WWW_ROOT'),
  21. 'dataroot' => getenv('ELGG_DATA_ROOT'),
  22. 'siteaccess' => getenv('ELGG_SITE_ACCESS'),
  23. // admin account
  24. 'displayname' => getenv('ELGG_DISPLAY_NAME'),
  25. 'email' => getenv('ELGG_EMAIL'),
  26. 'username' => getenv('ELGG_USERNAME'),
  27. 'password' => getenv('ELGG_PASSWORD'),
  28. 'path' => getenv('ELGG_PATH')
  29. );
  30. if (strlen($params['password']) < 6) {
  31. echo "Elgg Admin password ({$params['password']}) must be at least 6 characters long.\n";
  32. exit(1);
  33. }
  34. $createHtaccess = (file_exists($params['path'].'.htaccess')) ? false : true;
  35. $installer = new ElggInstaller();
  36. $installer->batchInstall($params, $createHtaccess);
  37. /**
  38. * Elgg create symbolic links on instalation with composer
  39. * See "post-install-cmd": "\\Elgg\\Composer\\PostInstall::execute", for details.
  40. * Links are created on your local machine.
  41. * The links need to be changed to the container directories
  42. */
  43. $path_mod_root = getenv('ELGG_PATH').'mod/';
  44. $mods = scandir($path_mod_root);
  45. foreach ($mods as $key => $folder) {
  46. if (is_link($path_mod_root.$folder)) {
  47. unlink($path_mod_root.$folder);
  48. }
  49. }
  50. $path_mod_vendor = getenv('ELGG_PATH').'vendor/elgg/elgg/mod/';
  51. $mods = scandir($path_mod_vendor);
  52. foreach ($mods as $key => $folder) {
  53. if (is_dir($path_mod_vendor.$folder) &&
  54. !is_link($path_mod_root.$folder) &&
  55. !is_dir($path_mod_root.$folder)) {
  56. symlink($path_mod_vendor.$folder, $path_mod_root.$folder);
  57. }
  58. }
  59. echo "Installation is complete.\n";
  60. echo "Open in your browser: {$params['wwwroot']}\n";
  61. echo "Elgg access credentials:\n";
  62. echo "Elgg admin username: {$params['username']}\n";
  63. echo "Elgg admin pass: {$params['password']}\n";
  64. exit(0);