elgg-install.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. 'dbuser' => getenv('ELGG_DB_USER'),
  13. 'dbpassword' => getenv('ELGG_DB_PASS'),
  14. 'dbname' => getenv('ELGG_DB_NAME'),
  15. 'dbhost' => getenv('ELGG_DB_HOST'),
  16. 'dbprefix' => getenv('ELGG_DB_PREFIX'),
  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. // admin account
  23. 'displayname' => getenv('ELGG_DISPLAY_NAME'),
  24. 'email' => getenv('ELGG_EMAIL'),
  25. 'username' => getenv('ELGG_USERNAME'),
  26. 'password' => getenv('ELGG_PASSWORD'),
  27. 'path' => getenv('ELGG_PATH')
  28. );
  29. if (strlen($params['password']) < 6) {
  30. echo "Elgg Admin password ({$params['password']}) must be at least 6 characters long.\n";
  31. exit(1);
  32. }
  33. $createHtaccess = (file_exists($params['path'].'.htaccess')) ? false : true;
  34. $installer = new ElggInstaller();
  35. $installer->batchInstall($params, $createHtaccess);
  36. /**
  37. * Elgg create symbolic links on instalation with composer
  38. * See "post-install-cmd": "\\Elgg\\Composer\\PostInstall::execute", for details.
  39. * Links are created on your local machine.
  40. * The links need to be changed to the container directories
  41. */
  42. $path_mod_root = getenv('ELGG_PATH').'mod/';
  43. $mods = scandir($path_mod_root);
  44. foreach ($mods as $key => $folder) {
  45. if (is_link($path_mod_root.$folder)) {
  46. unlink($path_mod_root.$folder);
  47. }
  48. }
  49. $path_mod_vendor = getenv('ELGG_PATH').'vendor/elgg/elgg/mod/';
  50. $mods = scandir($path_mod_vendor);
  51. foreach ($mods as $key => $folder) {
  52. if (is_dir($path_mod_vendor.$folder) &&
  53. !is_link($path_mod_root.$folder) &&
  54. !is_dir($path_mod_root.$folder)) {
  55. symlink($path_mod_vendor.$folder, $path_mod_root.$folder);
  56. }
  57. }
  58. echo "Installation is complete.\n";
  59. echo "Open in your browser: {$params['wwwroot']}\n";
  60. echo "Elgg access credentials:\n";
  61. echo "Elgg admin username: {$params['username']}\n";
  62. echo "Elgg admin pass: {$params['password']}\n";
  63. exit(0);