PrestashopSetup.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace Hestia\WebApp\Installers\Prestashop;
  3. use Hestia\WebApp\Installers\BaseSetup as BaseSetup;
  4. class PrestashopSetup extends BaseSetup {
  5. protected $appInfo = [
  6. "name" => "Prestashop",
  7. "group" => "ecommerce",
  8. "enabled" => true,
  9. "version" => "8.0.4",
  10. "thumbnail" => "prestashop-thumb.png",
  11. ];
  12. protected $appname = "prestashop";
  13. protected $extractsubdir = "/tmp-prestashop";
  14. protected $config = [
  15. "form" => [
  16. "prestashop_account_first_name" => ["value" => "John"],
  17. "prestashop_account_last_name" => ["value" => "Doe"],
  18. "prestashop_account_email" => "text",
  19. "prestashop_account_password" => "password",
  20. ],
  21. "database" => true,
  22. "resources" => [
  23. "archive" => [
  24. "src" =>
  25. "https://github.com/PrestaShop/PrestaShop/releases/download/8.0.4/prestashop_8.0.4.zip",
  26. ],
  27. ],
  28. "server" => [
  29. "nginx" => [
  30. "template" => "prestashop",
  31. ],
  32. "php" => [
  33. "supported" => ["8.0", "8.1"],
  34. ],
  35. ],
  36. ];
  37. public function install(array $options = null): bool {
  38. parent::install($options);
  39. parent::setup($options);
  40. $this->appcontext->archiveExtract(
  41. $this->getDocRoot($this->extractsubdir . "/prestashop.zip"),
  42. $this->getDocRoot(),
  43. );
  44. //check if ssl is enabled
  45. $this->appcontext->run(
  46. "v-list-web-domain",
  47. [$this->appcontext->user(), $this->domain, "json"],
  48. $status,
  49. );
  50. if ($status->code !== 0) {
  51. throw new \Exception("Cannot list domain");
  52. }
  53. if ($status->json[$this->domain]["SSL"] == "no") {
  54. $ssl_enabled = 0;
  55. } else {
  56. $ssl_enabled = 1;
  57. }
  58. $php_version = $this->appcontext->getSupportedPHP(
  59. $this->config["server"]["php"]["supported"],
  60. );
  61. $this->appcontext->runUser(
  62. "v-run-cli-cmd",
  63. [
  64. "/usr/bin/php" . $options["php_version"],
  65. $this->getDocRoot("/install/index_cli.php"),
  66. "--db_user=" . $this->appcontext->user() . "_" . $options["database_user"],
  67. "--db_password=" . $options["database_password"],
  68. "--db_name=" . $this->appcontext->user() . "_" . $options["database_name"],
  69. "--firstname=" . $options["prestashop_account_first_name"],
  70. "--lastname=" . $options["prestashop_account_last_name"],
  71. "--password=" . $options["prestashop_account_password"],
  72. "--email=" . $options["prestashop_account_email"],
  73. "--domain=" . $this->domain,
  74. "--ssl=" . $ssl_enabled,
  75. ],
  76. $status,
  77. );
  78. // remove install folder
  79. $this->appcontext->runUser("v-delete-fs-directory", [$this->getDocRoot("/install")]);
  80. $this->cleanup();
  81. return $status->code === 0;
  82. }
  83. }