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
96 lines (82 loc) · 2.66 KB
/
Copy pathMediaWikiSetup.php
File metadata and controls
96 lines (82 loc) · 2.66 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
93
94
95
96
<?php
namespace Hestia\WebApp\Installers\MediaWiki;
use Hestia\System\Util;
use Hestia\WebApp\Installers\BaseSetup as BaseSetup;
use function Hestiacp\quoteshellarg\quoteshellarg;
class MediaWikiSetup extends BaseSetup {
protected $appInfo = [
"name" => "MediaWiki",
"group" => "cms",
"enabled" => true,
"version" => "1.41.1",
"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.41/mediawiki-1.41.1.zip",
],
],
"server" => [
"nginx" => [
"template" => "default",
],
"php" => [
"supported" => ["8.0", "8.1", "8.2"],
],
],
];
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.41.1/."), $this->getDocRoot()],
$result,
);
$this->appcontext->runUser(
"v-run-cli-cmd",
[
"/usr/bin/php" . $options["php_version"],
quoteshellarg($this->getDocRoot("maintenance/install.php")),
"--dbserver=" . quoteshellarg($options["database_host"]),
"--dbname=" .
quoteshellarg($this->appcontext->user() . "_" . $options["database_name"]),
"--installdbuser=" .
quoteshellarg($this->appcontext->user() . "_" . $options["database_user"]),
"--installdbpass=" . quoteshellarg($options["database_password"]),
"--dbuser=" .
quoteshellarg($this->appcontext->user() . "_" . $options["database_user"]),
"--dbpass=" . quoteshellarg($options["database_password"]),
"--server=" . quoteshellarg($webDomain),
"--scriptpath=", // must NOT be /
"--lang=" . quoteshellarg($options["language"]),
"--pass=" . quoteshellarg($options["admin_password"]),
"MediaWiki", // A Space here would trigger the next argument and preemptively set the admin username
quoteshellarg($options["admin_username"]),
],
$status,
);
$this->cleanup();
return $status->code === 0;
}
}