Skip to content

Commit 0bdfb3e

Browse files
authored
Merge pull request hestiacp#2002 from PsychotherapistSam/feature/grav-mediawiki-dokuwiki
Add Grav, MediaWiki and DokuWiki quick-install scripts
2 parents f30e81b + 619a50f commit 0bdfb3e

File tree

10 files changed

+1010
-1
lines changed

10 files changed

+1010
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
55

66
### Features
77

8+
- Add Quick installers for GravCMS, Docuwiki and Mediawiki (#2002) @PsychotherapistSam
9+
810
### Bugfixes
911

1012
- Improve handling upgrade of Roundcube #1917
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#=======================================================================#
2+
# Default Web Domain Template #
3+
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
4+
#=======================================================================#
5+
6+
server {
7+
listen %ip%:%web_ssl_port% ssl http2;
8+
server_name %domain_idn% %alias_idn%;
9+
root %sdocroot%;
10+
index index.php index.html index.htm;
11+
access_log /var/log/nginx/domains/%domain%.log combined;
12+
access_log /var/log/nginx/domains/%domain%.bytes bytes;
13+
error_log /var/log/nginx/domains/%domain%.error.log error;
14+
15+
ssl_certificate %ssl_pem%;
16+
ssl_certificate_key %ssl_key%;
17+
ssl_stapling on;
18+
ssl_stapling_verify on;
19+
20+
include %home%/%user%/conf/web/%domain%/nginx.hsts.conf*;
21+
22+
location / {
23+
try_files $uri $uri/ /index.php?$query_string;
24+
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
25+
expires max;
26+
fastcgi_hide_header "Set-Cookie";
27+
}
28+
29+
location ~ [^/]\.php(/|$) {
30+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
31+
if (!-f $document_root$fastcgi_script_name) {
32+
return 404;
33+
}
34+
35+
fastcgi_pass %backend_lsnr%;
36+
fastcgi_index index.php;
37+
include /etc/nginx/fastcgi_params;
38+
}
39+
}
40+
41+
location /error/ {
42+
alias %home%/%user%/web/%domain%/document_errors/;
43+
}
44+
45+
location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
46+
location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
47+
location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
48+
location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
49+
50+
location ~ /\.(?!well-known\/) {
51+
deny all;
52+
return 404;
53+
}
54+
55+
location /vstats/ {
56+
alias %home%/%user%/web/%domain%/stats/;
57+
include %home%/%user%/web/%domain%/stats/auth.conf*;
58+
}
59+
60+
include /etc/nginx/conf.d/phpmyadmin.inc*;
61+
include /etc/nginx/conf.d/phppgadmin.inc*;
62+
include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
63+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#=======================================================================#
2+
# Default Web Domain Template #
3+
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
4+
#=======================================================================#
5+
6+
server {
7+
listen %ip%:%web_port%;
8+
server_name %domain_idn% %alias_idn%;
9+
root %docroot%;
10+
index index.php index.html index.htm;
11+
access_log /var/log/nginx/domains/%domain%.log combined;
12+
access_log /var/log/nginx/domains/%domain%.bytes bytes;
13+
error_log /var/log/nginx/domains/%domain%.error.log error;
14+
15+
include %home%/%user%/conf/web/%domain%/nginx.forcessl.conf*;
16+
17+
location / {
18+
try_files $uri $uri/ /index.php?$query_string;
19+
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
20+
expires max;
21+
fastcgi_hide_header "Set-Cookie";
22+
}
23+
24+
location ~ [^/]\.php(/|$) {
25+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
26+
if (!-f $document_root$fastcgi_script_name) {
27+
return 404;
28+
}
29+
30+
fastcgi_pass %backend_lsnr%;
31+
fastcgi_index index.php;
32+
include /etc/nginx/fastcgi_params;
33+
}
34+
}
35+
location /error/ {
36+
alias %home%/%user%/web/%domain%/document_errors/;
37+
}
38+
39+
location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
40+
location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
41+
location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
42+
location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }
43+
44+
location ~ /\.(?!well-known\/) {
45+
deny all;
46+
return 404;
47+
}
48+
49+
location /vstats/ {
50+
alias %home%/%user%/web/%domain%/stats/;
51+
include %home%/%user%/web/%domain%/stats/auth.conf*;
52+
}
53+
54+
include /etc/nginx/conf.d/phpmyadmin.inc*;
55+
include /etc/nginx/conf.d/phppgadmin.inc*;
56+
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
57+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
3+
namespace Hestia\WebApp\Installers\DokuWiki;
4+
5+
use Hestia\System\Util;
6+
use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
7+
8+
class DokuWikiSetup extends BaseSetup {
9+
10+
protected $appInfo = [
11+
'name' => 'DokuWiki',
12+
'group' => 'wiki',
13+
'enabled' => true,
14+
'version' => 'stable_2020-07-29',
15+
'thumbnail' => 'dokuwiki-logo.svg'
16+
];
17+
18+
protected $appname = 'dokuwiki';
19+
protected $extractsubdir = "/tmp-dokuwiki";
20+
21+
protected $config = [
22+
'form' => [
23+
'wiki_name' => 'text',
24+
'superuser' => 'text',
25+
'real_name' => 'text',
26+
'email' => 'text',
27+
'password' => 'password',
28+
'initial_ACL_policy' => [
29+
'type' => 'select',
30+
'options' => [
31+
'0: Open Wiki (read, write, upload for everyone)', // 0
32+
'1: Public Wiki (read for everyone, write and upload for registered users)', // 1
33+
'2: Closed Wiki (read, write, upload for registered users only)' // 3
34+
],
35+
],
36+
'content_license' => [
37+
'type' => 'select',
38+
'options' => [
39+
'cc-zero: CC0 1.0 Universal',
40+
'publicdomain: Public Domain',
41+
'cc-by: CC Attribution 4.0 International',
42+
'cc-by-sa: CC Attribution-Share Alike 4.0 International',
43+
'gnufdl: GNU Free Documentation License 1.3',
44+
'cc-by-nc: CC Attribution-Noncommercial 4.0 International',
45+
'cc-by-nc-sa: CC Attribution-Noncommercial-Share Alike 4.0 International',
46+
'0: Do not show any license information',
47+
]
48+
],
49+
],
50+
'resources' => [
51+
'archive' => [ 'src' => 'https://github.com/splitbrain/dokuwiki/archive/refs/tags/release_stable_2020-07-29.zip' ],
52+
],
53+
];
54+
55+
public function install(array $options = null)
56+
{
57+
parent::install($options);
58+
59+
//check if ssl is enabled
60+
$this->appcontext->run('v-list-web-domain', [$this->appcontext->user(), $this->domain, 'json'], $status);
61+
62+
if($status->code !== 0) {
63+
throw new \Exception("Cannot list domain");
64+
}
65+
66+
$sslEnabled = ($status->json[$this->domain]['SSL'] == 'no' ? 0 : 1);
67+
68+
$webDomain = ($sslEnabled ? "https://" : "http://") . $this->domain . "/";
69+
70+
$this->appcontext->runUser('v-copy-fs-directory',[
71+
$this->getDocRoot($this->extractsubdir . "/dokuwiki-release_stable_2020-07-29/."),
72+
$this->getDocRoot()], $result);
73+
74+
// enable htaccess
75+
$this->appcontext->runUser('v-move-fs-file', [$this->getDocRoot(".htaccess.dist"), $this->getDocRoot(".htaccess")], $result);
76+
77+
$installUrl = $webDomain . "install.php";
78+
79+
$cmd = "curl --request POST "
80+
. ($sslEnabled ? "" : "--insecure " )
81+
. "--url $installUrl "
82+
. "--header 'Content-Type: application/x-www-form-urlencoded' "
83+
. "--data l=en "
84+
. "--data 'd[title]=" . $options['wiki_name'] . "' "
85+
. "--data 'd[acl]=on' "
86+
. "--data 'd[superuser]=" . $options['superuser'] . "' "
87+
. "--data 'd[fullname]=" . $options['real_name'] . "' "
88+
. "--data 'd[email]=" . $options['email'] . "' "
89+
. "--data 'd[password]=" . $options['password'] . "' "
90+
. "--data 'd[confirm]=" . $options['password'] . "' "
91+
. "--data 'd[policy]=" . substr($options['initial_ACL_policy'], 0, 1) . "' "
92+
. "--data 'd[license]=" . explode(":", $options['content_license'])[0] . "' "
93+
. "--data submit=";
94+
95+
exec($cmd, $msg, $code);
96+
97+
// remove temp folder
98+
$this->appcontext->runUser('v-delete-fs-file', [$this->getDocRoot("install.php")], $result);
99+
$this->cleanup();
100+
101+
return ($code === 0);
102+
}
103+
}

0 commit comments

Comments
 (0)