install.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. $_ENV["SNAPPYMAIL_INCLUDE_AS_API"] = true;
  3. require_once "/var/lib/snappymail/index.php";
  4. $oConfig = \RainLoop\Api::Config();
  5. // Change default login data / key
  6. $oConfig->Set("security", "admin_login", $argv[1]);
  7. $oConfig->Set("security", "admin_panel_key", $argv[1]);
  8. $oConfig->SetPassword($argv[2]);
  9. // Allow Contacts to be saved in database
  10. $oConfig->Set("contacts", "enable", "On");
  11. $oConfig->Set("contacts", "allow_sync", "On");
  12. $oConfig->Set("contacts", "type", "mysql");
  13. $oConfig->Set("contacts", "pdo_dsn", "mysql:host=127.0.0.1;port=3306;dbname=snappymail");
  14. $oConfig->Set("contacts", "pdo_user", "snappymail");
  15. $oConfig->Set("contacts", "pdo_password", $argv[3]);
  16. // Plugins
  17. $oConfig->Set("plugins", "enable", "On");
  18. \SnappyMail\Repository::installPackage("plugin", "change-password");
  19. \SnappyMail\Repository::installPackage("plugin", "change-password-hestia");
  20. $sFile = APP_PRIVATE_DATA . "configs/plugin-change-password.json";
  21. if (!file_exists($sFile)) {
  22. file_put_contents(
  23. "$sFile",
  24. json_encode(
  25. [
  26. "plugin" => [
  27. "pass_min_length" => 8,
  28. "pass_min_strength" => 60,
  29. "driver_hestia_enabled" => true,
  30. "driver_hestia_allowed_emails" => "*",
  31. "hestia_host" => gethostname(),
  32. "hestia_port" => $argv[4], // $BACKEND_PORT
  33. ],
  34. ],
  35. JSON_PRETTY_PRINT,
  36. ),
  37. );
  38. }
  39. \SnappyMail\Repository::enablePackage("change-password");
  40. \SnappyMail\Repository::installPackage("plugin", "add-x-originating-ip-header");
  41. \SnappyMail\Repository::enablePackage("add-x-originating-ip-header");
  42. $sFile = APP_PRIVATE_DATA . "configs/plugin-add-x-originating-ip-header.json";
  43. if (!file_exists($sFile)) {
  44. file_put_contents(
  45. "$sFile",
  46. json_encode(
  47. [
  48. "plugin" => [
  49. "check_proxy" => true,
  50. ],
  51. ],
  52. JSON_PRETTY_PRINT,
  53. ),
  54. );
  55. }
  56. $oConfig->Save();
  57. $sFile = APP_PRIVATE_DATA . "domains/hestia.json";
  58. if (!file_exists($sFile)) {
  59. $config = json_decode(APP_PRIVATE_DATA . "domains/default.json", true);
  60. $config["IMAP"]["shortLogin"] = true;
  61. $config["SMTP"]["shortLogin"] = true;
  62. file_put_contents($sFile, json_encode($config, JSON_PRETTY_PRINT));
  63. }