forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMediaWikiSetup.php
More file actions
92 lines (78 loc) · 2.41 KB
/
MediaWikiSetup.php
File metadata and controls
92 lines (78 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace Hestia\WebApp\Installers\MediaWiki;
use Hestia\System\Util;
use Hestia\WebApp\Installers\BaseSetup as BaseSetup;
class MediaWikiSetup extends BaseSetup {
protected $appInfo = [
"name" => "MediaWiki",
"group" => "cms",
"enabled" => true,
"version" => "1.39.2",
"thumbnail" => "MediaWiki-2020-logo.svg", //Max size is 300px by 300px
];
protected $appname = "mediawiki";
protected $extractsubdir = "/tmp-mediawiki";
protected $config = [
"form" => [
"admin_username" => ["type" => "text", "value" => "admin"],
"admin_password" => "password",
"language" => ["type" => "text", "value" => "en"],
],
"database" => true,
"resources" => [
"archive" => [
"src" => "https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.2.zip",
],
],
"server" => [
"nginx" => [
"template" => "default",
],
"php" => [
"supported" => ["7.4", "8.0"],
],
],
];
public function install(array $options = null) {
parent::install($options);
parent::setup($options);
//check if ssl is enabled
$this->appcontext->run(
"v-list-web-domain",
[$this->appcontext->user(), $this->domain, "json"],
$status,
);
if ($status->code !== 0) {
throw new \Exception("Cannot list domain");
}
$sslEnabled = $status->json[$this->domain]["SSL"] == "no" ? 0 : 1;
$webDomain = ($sslEnabled ? "https://" : "http://") . $this->domain;
$this->appcontext->runUser(
"v-copy-fs-directory",
[$this->getDocRoot($this->extractsubdir . "/mediawiki-1.39.2/."), $this->getDocRoot()],
$result,
);
$this->appcontext->runUser(
"v-run-cli-cmd",
[
"/usr/bin/php" . $options["php_version"],
$this->getDocRoot("maintenance/install.php"),
"--dbserver=localhost",
"--dbname=" . $this->appcontext->user() . "_" . $options["database_name"],
"--installdbuser=" . $this->appcontext->user() . "_" . $options["database_user"],
"--installdbpass=" . $options["database_password"],
"--dbuser=" . $this->appcontext->user() . "_" . $options["database_user"],
"--dbpass=" . $options["database_password"],
"--server=" . $webDomain,
"--scriptpath=", // must NOT be /
"--lang=" . $options["language"],
"--pass=" . $options["admin_password"],
"MediaWiki", // A Space here would trigger the next argument and preemptively set the admin username
$options["admin_username"],
],
$status,
);
$this->cleanup();
return $status->code === 0;
}
}