From f9e254189849fc4d76c98b67974f13c2fc69ed84 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:20:54 -0500
Subject: [PATCH 01/11] Delete META-INF directory
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
META-INF/extension.xml | 12 ------------
1 file changed, 12 deletions(-)
delete mode 100644 META-INF/extension.xml
diff --git a/META-INF/extension.xml b/META-INF/extension.xml
deleted file mode 100644
index 14ac657..0000000
--- a/META-INF/extension.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
- HumHub Extension
- 1.0
- Install HumHub on Plesk
- ArchBlood
- Green Meteor
- Proprietary
-
-
-
-
From a37bfa51c38fcfee6caaf5de6d8ad6185a444857 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:21:05 -0500
Subject: [PATCH 02/11] Delete conf directory
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
conf/panel.ini | 2 --
1 file changed, 2 deletions(-)
delete mode 100644 conf/panel.ini
diff --git a/conf/panel.ini b/conf/panel.ini
deleted file mode 100644
index 742f41c..0000000
--- a/conf/panel.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[ext-humhub]
-extension = "/usr/local/psa/admin/plib/modules/install/humhub-extension.php"
From 9c93733c6e023e04b107bcb0422516c4c49a8b2b Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:21:14 -0500
Subject: [PATCH 03/11] Delete install directory
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
install/config.json | 7 --
install/humhub-extension.php | 197 -----------------------------------
2 files changed, 204 deletions(-)
delete mode 100644 install/config.json
delete mode 100644 install/humhub-extension.php
diff --git a/install/config.json b/install/config.json
deleted file mode 100644
index ed0c801..0000000
--- a/install/config.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "dbName": "humhub_prod_db",
- "dbUser": "humhub_prod",
- "dbPass": "change-me",
- "installationPath": "/var/www/humhub",
- "domain": "humhub.example.com"
-}
diff --git a/install/humhub-extension.php b/install/humhub-extension.php
deleted file mode 100644
index f46ef47..0000000
--- a/install/humhub-extension.php
+++ /dev/null
@@ -1,197 +0,0 @@
-config = json_decode($configJson, true);
- } else {
- throw new Exception("Config file not found: $configFile");
- }
- }
-
- public function install()
- {
- try {
- $this->log("Starting installation...");
-
- // Installation logic
- $this->downloadHumHub();
- $this->extractHumHub();
- $this->setPermissions();
- $this->createSymlink();
- $this->createDatabase();
-
- $this->log("HumHub installed successfully.");
-
- // Open a new tab to the HumHub installation URL
- echo "";
- } catch (Exception $e) {
- $this->log("Installation failed: " . $e->getMessage());
- }
- }
-
- public function uninstall()
- {
- try {
- $this->log("Starting uninstallation...");
-
- // Uninstallation logic
- $this->removeSymlink();
- $this->deleteDatabase();
-
- $this->log("HumHub uninstalled successfully.");
- } catch (Exception $e) {
- $this->log("Uninstallation failed: " . $e->getMessage());
- }
- }
-
- private function downloadHumHub()
- {
- $this->log("Downloading HumHub...");
- // Download HumHub
- $humhubVersion = '1.15.4'; // Specify the desired version of HumHub
- $humhubUrl = "https://download.humhub.com/downloads/install/humhub-$humhubVersion.zip";
- $zipFilePath = '/tmp/humhub.zip';
- file_put_contents($zipFilePath, fopen($humhubUrl, 'r'));
- }
-
- private function extractHumHub()
- {
- $this->log("Extracting HumHub...");
- // Extract HumHub
- $zip = new ZipArchive;
- $zipFilePath = '/tmp/humhub.zip';
- if ($zip->open($zipFilePath) === TRUE) {
- $zip->extractTo($this->config['installationPath']);
- $zip->close();
- } else {
- throw new Exception("Failed to extract HumHub.");
- }
- }
-
- private function setPermissions()
- {
- $this->log("Setting permissions...");
- // Set correct permissions
- chmod($this->config['installationPath'], 0755);
- }
-
- private function createSymlink()
- {
- $this->log("Creating symlink...");
- // Create a symbolic link for Apache
- exec("ln -s {$this->config['installationPath']} /var/www/html/humhub");
- }
-
- private function removeSymlink()
- {
- $this->log("Removing symlink...");
- // Remove the symbolic link
- exec("rm -rf /var/www/html/humhub");
- }
-
- private function createDatabase()
- {
- $this->log("Creating database and user...");
- // Create MySQL database and user
- $dbConnection = new mysqli('localhost', 'root', 'root_password');
- if ($dbConnection->connect_error) {
- throw new Exception('Database connection failed: ' . $dbConnection->connect_error);
- }
-
- // Create database
- $sql = "CREATE DATABASE IF NOT EXISTS {$this->config['dbName']}";
- if ($dbConnection->query($sql) === TRUE) {
- // Create user and grant privileges
- $sql = "CREATE USER IF NOT EXISTS '{$this->config['dbUser']}'@'localhost' IDENTIFIED BY '{$this->config['dbPass']}'";
- $sql .= ";GRANT ALL PRIVILEGES ON {$this->config['dbName']}.* TO '{$this->config['dbUser']}'@'localhost'";
- if ($dbConnection->multi_query($sql) === TRUE) {
- $this->log("Database created and user privileges granted successfully.");
- } else {
- throw new Exception("Error creating user and granting privileges: " . $dbConnection->error);
- }
- } else {
- throw new Exception("Error creating database: " . $dbConnection->error);
- }
-
- $dbConnection->close();
- }
-
- private function deleteDatabase()
- {
- $this->log("Deleting database and user...");
- // Delete MySQL database and user
- $dbConnection = new mysqli('localhost', 'root', 'root_password');
- if ($dbConnection->connect_error) {
- throw new Exception('Database connection failed: ' . $dbConnection->connect_error);
- }
-
- // Drop database
- $sql = "DROP DATABASE IF EXISTS {$this->config['dbName']}";
- if ($dbConnection->query($sql) === TRUE) {
- // Drop user
- $sql = "DROP USER IF EXISTS '{$this->config['dbUser']}'@'localhost'";
- if ($dbConnection->query($sql) === TRUE) {
- $this->log("Database and user deleted successfully.");
- } else {
- throw new Exception("Error deleting user: " . $dbConnection->error);
- }
- } else {
- throw new Exception("Error deleting database: " . $dbConnection->error);
- }
-
- $dbConnection->close();
- }
-
- private function log($message)
- {
- // Log messages to a file
- $logDir = '/var/log/';
- $logFile = $logDir . 'humhub-extension.log';
-
- // Create log directory if it doesn't exist
- if (!file_exists($logDir)) {
- mkdir($logDir, 0777, true);
- }
-
- // Create log file if it doesn't exist
- if (!file_exists($logFile)) {
- file_put_contents($logFile, '');
- }
-
- // Append message to log file
- file_put_contents($logFile, date('[Y-m-d H:i:s] ') . $message . PHP_EOL, FILE_APPEND);
- }
-}
-
-// Instantiate the HumHubExtension class
-$humHubExtension = new HumHubExtension();
-
-// Check command-line arguments
-if ($argc < 2) {
- echo "Usage: php humhub-extension.php [install|uninstall]" . PHP_EOL;
- exit(1);
-}
-
-// Determine action based on command-line argument
-$action = $argv[1];
-switch ($action) {
- case 'install':
- $humHubExtension->install();
- break;
- case 'uninstall':
- $humHubExtension->uninstall();
- break;
- default:
- echo "Invalid action. Usage: php humhub-extension.php [install|uninstall]" . PHP_EOL;
- exit(1);
-}
-
-?>
From bce6a82af5b8e7d7224f3e04809677127321b235 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:22:27 -0500
Subject: [PATCH 04/11] Create meta.xml
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
meta.xml | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 meta.xml
diff --git a/meta.xml b/meta.xml
new file mode 100644
index 0000000..632ac3a
--- /dev/null
+++ b/meta.xml
@@ -0,0 +1,22 @@
+
+
+ humhub-extension
+ 1.1
+ 1
+ HumHub Installer
+
+ A Plesk extension for downloading, configuring, and setting up HumHub.
+
+
+ Green Meteor
+ hello@greenmeteor.net
+
+
+ admin
+
+
+
+ 8.1.0
+
+
+
From e4378dc5e3b29901e9dd83d24375c0e074f5ee97 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:23:08 -0500
Subject: [PATCH 05/11] Create Controller.php
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
plib/Controller.php | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 plib/Controller.php
diff --git a/plib/Controller.php b/plib/Controller.php
new file mode 100644
index 0000000..0c06157
--- /dev/null
+++ b/plib/Controller.php
@@ -0,0 +1,32 @@
+view->pageTitle = "HumHub Installer";
+ $this->view->content = Helper::getFormHtml();
+ }
+
+ public function installAction()
+ {
+ $domain = $this->_request->getParam('domain');
+ $dbUser = $this->_request->getParam('dbUser');
+ $dbPass = $this->_request->getParam('dbPass');
+ $dbName = $this->_request->getParam('dbName');
+
+ $task = new InstallTask($domain, $dbUser, $dbPass, $dbName);
+ $result = $task->run();
+
+ if ($result['success']) {
+ $this->_helper->json(['success' => true, 'message' => 'HumHub installation completed!']);
+ } else {
+ $this->_helper->json(['success' => false, 'message' => $result['message']]);
+ }
+ }
+}
From 9b2bdd510c7581f88fb4e3d00653293a75ff02a4 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:23:45 -0500
Subject: [PATCH 06/11] Create Helper.php
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
plib/Helper.php | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 plib/Helper.php
diff --git a/plib/Helper.php b/plib/Helper.php
new file mode 100644
index 0000000..52db7f8
--- /dev/null
+++ b/plib/Helper.php
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ';
+ }
+}
From 3debda51d6b0d1f06347d46e10d6765228f75554 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:32:23 -0500
Subject: [PATCH 07/11] Create InstallTask.php
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
plib/InstallTask.php | 108 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
create mode 100644 plib/InstallTask.php
diff --git a/plib/InstallTask.php b/plib/InstallTask.php
new file mode 100644
index 0000000..92952d6
--- /dev/null
+++ b/plib/InstallTask.php
@@ -0,0 +1,108 @@
+domain = $domain;
+ $this->dbUser = $dbUser;
+ $this->dbPass = $dbPass;
+ $this->dbName = $dbName;
+ }
+
+ public function run()
+ {
+ try {
+ // Create database, download, and configure HumHub
+ $this->createDatabase();
+ $this->downloadHumHub();
+ $this->configureHumHub();
+
+ return ['success' => true];
+ } catch (pm_Exception $e) {
+ return ['success' => false, 'message' => $e->getMessage()];
+ }
+ }
+
+ private function createDatabase()
+ {
+ $dbManager = new pm_ApiRpc;
+ $dbManager->call('database', 'addDb', [
+ 'name' => $this->dbName,
+ 'type' => 'mysql',
+ 'domain' => $this->domain,
+ 'dbuser' => [
+ 'name' => $this->dbUser,
+ 'password' => $this->dbPass,
+ ],
+ ]);
+ }
+
+ private function downloadHumHub()
+ {
+ $humhubUrl = 'https://download.humhub.com/downloads/install/humhub-1.17.0.zip';
+ $domainObj = pm_Domain::getByName($this->domain);
+ $installPath = $domainObj->getDocumentRoot();
+
+ $fileManager = new pm_ServerFileManager;
+ $fileManager->downloadFile($humhubUrl, "$installPath/humhub.zip");
+ $fileManager->unpackArchive("$installPath/humhub.zip", $installPath);
+ $fileManager->removeFile("$installPath/humhub.zip");
+ }
+
+ private function configureHumHub()
+ {
+ $domainObj = pm_Domain::getByName($this->domain);
+ $configPath = $domainObj->getDocumentRoot() . '/protected/config/dynamic.php';
+
+ $dynamicConfig = [
+ 'components' => [
+ 'db' => [
+ 'class' => 'yii\\db\\Connection',
+ 'dsn' => 'mysql:host=localhost;dbname=' . $this->dbName,
+ 'username' => $this->dbUser,
+ 'password' => $this->dbPass,
+ ],
+ 'user' => [],
+ 'mailer' => [
+ 'transport' => [
+ 'dsn' => 'native://default',
+ ],
+ ],
+ 'cache' => [
+ 'class' => 'yii\\caching\\ApcCache',
+ 'keyPrefix' => 'humhub',
+ 'useApcu' => true,
+ ],
+ ],
+ 'params' => [
+ 'installer' => [
+ 'db' => [
+ 'installer_hostname' => 'localhost',
+ 'installer_database' => $this->dbName,
+ ],
+ ],
+ 'config_created_at' => time(),
+ 'horImageScrollOnMobile' => 1,
+ 'databaseInstalled' => true,
+ 'installed' => true,
+ ],
+ 'name' => $this->domain,
+ ];
+
+ // Write the configuration file
+ file_put_contents($configPath, "");
+ }
+}
From 19764c2cfa9cdae9086ecddcdc8e716dae52c7c0 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:32:56 -0500
Subject: [PATCH 08/11] Create style.css
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
resources/public/style.css | 39 ++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 resources/public/style.css
diff --git a/resources/public/style.css b/resources/public/style.css
new file mode 100644
index 0000000..0ccaa08
--- /dev/null
+++ b/resources/public/style.css
@@ -0,0 +1,39 @@
+body {
+ font-family: Arial, sans-serif;
+ margin: 0;
+ padding: 0;
+}
+
+h1 {
+ background-color: #0078d7;
+ color: white;
+ padding: 15px;
+}
+
+form {
+ margin: 20px;
+}
+
+label {
+ display: block;
+ margin-top: 10px;
+}
+
+input {
+ width: 100%;
+ padding: 8px;
+ margin-top: 5px;
+}
+
+button {
+ background-color: #0078d7;
+ color: white;
+ padding: 10px;
+ border: none;
+ cursor: pointer;
+ margin-top: 20px;
+}
+
+button:hover {
+ background-color: #005bb5;
+}
From e47e734ff221b242c4605b844e7b0eb3407f7cbf Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:33:43 -0500
Subject: [PATCH 09/11] Create event_handler.php
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
hooks/event_handler.php | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 hooks/event_handler.php
diff --git a/hooks/event_handler.php b/hooks/event_handler.php
new file mode 100644
index 0000000..40febf2
--- /dev/null
+++ b/hooks/event_handler.php
@@ -0,0 +1,5 @@
+
Date: Tue, 28 Jan 2025 03:36:53 -0500
Subject: [PATCH 10/11] Create index.html
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
resources/public/index.html | 12 ++++++++++++
1 file changed, 12 insertions(+)
create mode 100644 resources/public/index.html
diff --git a/resources/public/index.html b/resources/public/index.html
new file mode 100644
index 0000000..822210d
--- /dev/null
+++ b/resources/public/index.html
@@ -0,0 +1,12 @@
+
+
+
+
+ HumHub Installer
+
+
+
+ Welcome to the HumHub Installer
+ Use the Plesk extension interface to install HumHub on your selected domain.
+
+
From 6487aaaf8862fe4e0a6e15c4ce64c4bcfe492217 Mon Sep 17 00:00:00 2001
From: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
Date: Tue, 28 Jan 2025 03:37:28 -0500
Subject: [PATCH 11/11] Update Helper.php
Signed-off-by: ArchBlood <35392110+ArchBlood@users.noreply.github.com>
---
plib/Helper.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plib/Helper.php b/plib/Helper.php
index 52db7f8..cb70a4b 100644
--- a/plib/Helper.php
+++ b/plib/Helper.php
@@ -7,7 +7,7 @@ class Helper
public static function getFormHtml()
{
return '
-