|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Hestia\WebApp\Installers\ThirtyBees; |
| 4 | + |
| 5 | +use Hestia\WebApp\Installers\BaseSetup as BaseSetup; |
| 6 | + |
| 7 | +class ThirtyBeesSetup extends BaseSetup { |
| 8 | + protected $appInfo = [ |
| 9 | + "name" => "ThirtyBees", |
| 10 | + "group" => "ecommerce", |
| 11 | + "enabled" => true, |
| 12 | + "version" => "1.5.1", |
| 13 | + "thumbnail" => "thirtybees-thumb.png", |
| 14 | + ]; |
| 15 | + |
| 16 | + protected $appname = "thirtybees"; |
| 17 | + protected $extractsubdir = "."; |
| 18 | + |
| 19 | + protected $config = [ |
| 20 | + "form" => [ |
| 21 | + "thirtybees_account_first_name" => ["value" => "John"], |
| 22 | + "thirtybees_account_last_name" => ["value" => "Doe"], |
| 23 | + "thirtybees_account_email" => "text", |
| 24 | + "thirtybees_account_password" => "password", |
| 25 | + ], |
| 26 | + "database" => true, |
| 27 | + "resources" => [ |
| 28 | + "archive" => [ |
| 29 | + "src" => |
| 30 | + "https://github.com/thirtybees/thirtybees/releases/download/1.5.1/thirtybees-v1.5.1-php7.4.zip", |
| 31 | + ], |
| 32 | + ], |
| 33 | + "server" => [ |
| 34 | + "nginx" => [ |
| 35 | + "template" => "prestashop", |
| 36 | + ], |
| 37 | + "php" => [ |
| 38 | + "supported" => ["7.4", "8.0"], |
| 39 | + ], |
| 40 | + ], |
| 41 | + ]; |
| 42 | + |
| 43 | + public function install(array $options = null): bool { |
| 44 | + parent::install($options); |
| 45 | + parent::setup($options); |
| 46 | + |
| 47 | + try { |
| 48 | + $this->retrieveResources($options); |
| 49 | + } catch (\Exception $e) { |
| 50 | + // Registrar el error pero continuar con la instalación |
| 51 | + error_log("Error durante la descarga o extracción: " . $e->getMessage()); |
| 52 | + } |
| 53 | + |
| 54 | + // Verificación del estado SSL del dominio |
| 55 | + $status = null; |
| 56 | + $this->appcontext->run( |
| 57 | + "v-list-web-domain", |
| 58 | + [$this->appcontext->user(), $this->domain, "json"], |
| 59 | + $status, |
| 60 | + ); |
| 61 | + |
| 62 | + if ($status->code !== 0) { |
| 63 | + throw new \Exception("No se puede listar el dominio"); |
| 64 | + } |
| 65 | + |
| 66 | + $ssl_enabled = $status->json[$this->domain]["SSL"] == "no" ? 0 : 1; |
| 67 | + |
| 68 | + $php_version = $this->appcontext->getSupportedPHP( |
| 69 | + $this->config["server"]["php"]["supported"], |
| 70 | + ); |
| 71 | + |
| 72 | + $this->appcontext->runUser( |
| 73 | + "v-run-cli-cmd", |
| 74 | + [ |
| 75 | + "/usr/bin/php" . $options["php_version"], |
| 76 | + $this->getDocRoot("/install/index_cli.php"), |
| 77 | + "--db_user=" . $this->appcontext->user() . "_" . $options["database_user"], |
| 78 | + "--db_password=" . $options["database_password"], |
| 79 | + "--db_name=" . $this->appcontext->user() . "_" . $options["database_name"], |
| 80 | + "--firstname=" . $options["thirtybees_account_first_name"], |
| 81 | + "--lastname=" . $options["thirtybees_account_last_name"], |
| 82 | + "--password=" . $options["thirtybees_account_password"], |
| 83 | + "--email=" . $options["thirtybees_account_email"], |
| 84 | + "--domain=" . $this->domain, |
| 85 | + "--ssl=" . $ssl_enabled, |
| 86 | + ], |
| 87 | + $status, |
| 88 | + ); |
| 89 | + |
| 90 | + // Delete install directory |
| 91 | + $installDir = $this->getDocRoot() . "/install"; |
| 92 | + if (is_dir($installDir)) { |
| 93 | + $this->appcontext->runUser("v-delete-fs-directory", [$installDir]); |
| 94 | + } else { |
| 95 | + error_log( |
| 96 | + "No se pudo encontrar el directorio de instalación para eliminar: " . $installDir, |
| 97 | + ); |
| 98 | + } |
| 99 | + |
| 100 | + return $status->code === 0; |
| 101 | + } |
| 102 | +} |
0 commit comments