OpencartSetup.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. require_once("BaseSetup.php");
  3. class OpencartSetup extends BaseSetup {
  4. protected $appname = 'opencart';
  5. protected $extractsubdir="/tmp-opencart";
  6. protected $config = [
  7. 'form' => [
  8. 'opencart_account_username' => ['value'=>'ocadmin'],
  9. 'opencart_account_email' => 'text',
  10. 'opencart_account_password' => 'password',
  11. ],
  12. 'database' => true,
  13. 'resources' => [
  14. 'archive' => [ 'src' => 'https://github.com/opencart/opencart/releases/download/3.0.3.2/opencart-3.0.3.2.zip' ],
  15. ],
  16. ];
  17. public function install(array $options) : bool {
  18. parent::install($options);
  19. $this->appcontext->runUser('v-copy-fs-directory',[
  20. $this->getDocRoot($this->extractsubdir . "/upload/."),
  21. $this->getDocRoot()], $result);
  22. $this->appcontext->runUser('v-copy-fs-file',[$this->getDocRoot("config-dist.php"), $this->getDocRoot("config.php")]);
  23. $this->appcontext->runUser('v-copy-fs-file',[$this->getDocRoot("admin/config-dist.php"), $this->getDocRoot("admin/config.php")]);
  24. $this->appcontext->runUser('v-run-cli-cmd', [
  25. "/usr/bin/php",
  26. $this->getDocRoot("/install/cli_install.php"),
  27. "install",
  28. "--db_username " . $this->appcontext->user() . '_' .$options['database_user'],
  29. "--db_password " . $options['database_password'],
  30. "--db_database " . $this->appcontext->user() . '_' .$options['database_name'],
  31. "--username " . $options['opencart_account_username'],
  32. "--password " . $options['opencart_account_password'],
  33. "--email " . $options['opencart_account_email'],
  34. "--http_server " . "http://" . $this->domain . "/"], $status);
  35. $this->appcontext->runUser('v-change-fs-file-permission',[$this->getDocRoot("config.php"), '640']);
  36. $this->appcontext->runUser('v-change-fs-file-permission',[$this->getDocRoot("admin/config.php"), '640']);
  37. // remove install folder
  38. $this->appcontext->runUser('v-delete-fs-directory', [$this->getDocRoot("/install")]);
  39. $this->cleanup();
  40. return ($status->code === 0);
  41. }
  42. }