Skip to content

Commit f13f15f

Browse files
authored
Allow Quick Install Apps to change template used by default setting (hestiacp#2344)
* Enable Create DB on debfault * Add support for changing template in Quick Install Allow apps to change template domains. Currently users need to manually edit the template before installing Worpdress (Nginx + PHP-FPM) so the are able to use rewrite rules)
1 parent 0661bfd commit f13f15f

File tree

10 files changed

+61
-4
lines changed

10 files changed

+61
-4
lines changed

web/src/app/System/HestiaApp.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public function databaseAdd(string $dbname, string $dbuser, string $dbpass)
149149
unlink($v_password);
150150
return $status;
151151
}
152+
153+
public function changeWebTemplate(string $domain, string $template){
154+
$status = $this->runUser('v-change-web-domain-tpl', [$domain, $template]);
155+
}
152156

153157
public function getWebDomainIp(string $domain)
154158
{

web/src/app/WebApp/AppWizard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AppWizard {
1313
private $errors;
1414

1515
private $database_config = [
16-
'database_create' => ['type'=>'boolean', 'value'=>false],
16+
'database_create' => ['type'=>'boolean', 'value'=>true],
1717
'database_name' => ['type'=>'text', 'placeholder' => 'auto'],
1818
'database_user' => ['type'=>'text', 'placeholder' => 'auto'],
1919
'database_password' => ['type'=>'password', 'placeholder' => 'auto'],

web/src/app/WebApp/Installers/BaseSetup.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,24 @@ public function retrieveResources($options)
7070
}
7171
return true;
7272
}
73-
73+
public function setup( array $options=null)
74+
{
75+
if ( $_SESSION['WEB_SYSTEM'] == "nginx" )
76+
{
77+
if( isset($this -> config['server']['nginx']['template']) ){
78+
$this -> appcontext -> changeWebTemplate($this -> domain, $this -> config['server']['nginx']['template']);
79+
}else{
80+
$this -> appcontext -> changeWebTemplate($this -> domain, 'default');
81+
}
82+
}else{
83+
if( isset($this -> config['server']['apache2']['template']) ){
84+
$this -> appcontext -> changeWebTemplate($this -> domain, $this -> config['server']['apache2']['template']);
85+
}else{
86+
$this -> appcontext -> changeWebTemplate($this -> domain, 'default');
87+
}
88+
}
89+
}
90+
7491
public function install(array $options=null)
7592
{
7693
$this->appcontext->runUser('v-delete-fs-file', [$this->getDocRoot('robots.txt')]);

web/src/app/WebApp/Installers/Drupal/DrupalSetup.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class DrupalSetup extends BaseSetup {
2626
'resources' => [
2727
'composer' => [ 'src' => 'drupal/recommended-project', 'dst' => '/' ],
2828
],
29+
'server' => [
30+
'nginx' => [
31+
'template' => 'drupal-composer'
32+
],
33+
],
2934
];
3035

3136
public function install(array $options=null) : bool

web/src/app/WebApp/Installers/Grav/GravSetup.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class GravSetup extends BaseSetup {
2828
'resources' => [
2929
'composer' => [ 'src' => 'getgrav/grav', 'dst' => '/']
3030
],
31+
'server' => [
32+
'nginx' => [
33+
'template' => 'grav',
34+
],
35+
],
3136
];
3237

3338
public function install(array $options = null)

web/src/app/WebApp/Installers/Laravel/LaravelSetup.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class LaravelSetup extends BaseSetup {
2323
'resources' => [
2424
'composer' => [ 'src' => 'laravel/laravel', 'dst' => '/'],
2525
],
26+
'server' => [
27+
'nginx' => [
28+
'template' => 'laravel',
29+
],
30+
],
2631
];
2732

2833
public function install(array $options=null) : bool

web/src/app/WebApp/Installers/Nextcloud/NextcloudSetup.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class NextcloudSetup extends BaseSetup
2525
'resources' => [
2626
'archive' => [ 'src' => 'https://download.nextcloud.com/server/releases/nextcloud-22.2.0.tar.bz2' ]
2727
],
28+
'server' => [
29+
'nginx' => [
30+
'template' => 'owncloud',
31+
],
32+
],
2833
];
2934

3035
public function install(array $options = null): bool

web/src/app/WebApp/Installers/Opencart/OpencartSetup.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class OpencartSetup extends BaseSetup
2727
'resources' => [
2828
'archive' => [ 'src' => 'https://github.com/opencart/opencart/releases/download/3.0.3.8/opencart-3.0.3.8.zip' ],
2929
],
30+
'server' => [
31+
'nginx' => [
32+
'template' => 'opencart',
33+
],
34+
],
3035
];
3136

3237
public function install(array $options = null): bool

web/src/app/WebApp/Installers/Prestashop/PrestashopSetup.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class PrestashopSetup extends BaseSetup
2828
'resources' => [
2929
'archive' => [ 'src' => 'https://github.com/PrestaShop/PrestaShop/releases/download/1.7.7.8/prestashop_1.7.7.8.zip' ],
3030
],
31+
'server' => [
32+
'nginx' => [
33+
'template' => 'prestashop',
34+
],
35+
],
3136

3237
];
3338

web/src/app/WebApp/Installers/Wordpress/WordpressSetup.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ class WordpressSetup extends BaseSetup {
3131
'resources' => [
3232
'archive' => [ 'src' => 'https://wordpress.org/latest.tar.gz' ],
3333
],
34+
'server' => [
35+
'nginx' => [
36+
'template' => 'wordpress',
37+
],
38+
],
3439

3540
];
3641

3742
public function install(array $options = null)
3843
{
3944
parent::install($options);
40-
45+
parent::setup($options);
4146
$this->appcontext->runUser('v-open-fs-file',[$this->getDocRoot("wp-config-sample.php")], $result);
4247

4348
$distconfig = preg_replace( [
@@ -67,7 +72,8 @@ public function install(array $options = null)
6772
. "&admin_password=" . rawurlencode($options['wordpress_account_password'])
6873
. "&admin_password2=". rawurlencode($options['wordpress_account_password'])
6974
. "&admin_email=" . rawurlencode($options['wordpress_account_email'])), $output, $return_var);
70-
75+
76+
7177
return ($return_var === 0);
7278
}
7379
}

0 commit comments

Comments
 (0)