GravSetup.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace Hestia\WebApp\Installers\Grav;
  3. use Hestia\System\Util;
  4. use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
  5. class GravSetup extends BaseSetup {
  6. protected $appInfo = [
  7. 'name' => 'Grav',
  8. 'group' => 'cms',
  9. 'enabled' => true,
  10. 'version' => 'latest',
  11. 'thumbnail' => 'grav-symbol.svg'
  12. ];
  13. protected $appname = 'grav';
  14. protected $config = [
  15. 'form' => [
  16. 'admin' => ['type'=>'boolean', 'value'=>false, 'label' => "Create admin account"],
  17. 'username' => ['text'=>'admin'],
  18. 'password' => 'password',
  19. 'email' => 'text'
  20. ],
  21. 'database' => false,
  22. 'resources' => [
  23. 'composer' => [ 'src' => 'getgrav/grav', 'dst' => '/']
  24. ],
  25. 'server' => [
  26. 'nginx' => [
  27. 'template' => 'grav',
  28. ],
  29. 'php' => [
  30. 'supported' => [ '7.4', '8.0','8.1' ],
  31. ]
  32. ],
  33. ];
  34. public function install(array $options = null)
  35. {
  36. parent::install($options);
  37. parent::setup($options);
  38. if ( $options['admin'] == true ){
  39. chdir($this->getDocRoot());
  40. $this -> appcontext -> runUser('v-run-cli-cmd', ["/usr/bin/php".$options['php_version'],
  41. $this->getDocRoot('/bin/gpm'),
  42. 'install admin'
  43. ], $status);
  44. $this -> appcontext -> runUser('v-run-cli-cmd', ["/usr/bin/php".$options['php_version'],
  45. $this->getDocRoot('/bin/plugin'),
  46. 'login new-user',
  47. '-u '.$options['username'],
  48. '-p '.$options['password'],
  49. '-e '.$options['email'],
  50. '-P a',
  51. '-N '.$options['username']
  52. ], $status);
  53. }
  54. return ($status -> code === 1);
  55. }
  56. }