mirror of
https://github.com/myronblair/novacpx
synced 2026-06-30 17:50:41 -05:00
Fix WordPressManager (wrong DB class) and DockerManager (sudo install)
This commit is contained in:
+15
-10
@@ -19,19 +19,24 @@ class DockerManager {
|
|||||||
|
|
||||||
public function install(): string {
|
public function install(): string {
|
||||||
if ($this->isInstalled()) return 'Docker is already installed';
|
if ($this->isInstalled()) return 'Docker is already installed';
|
||||||
|
// Write install script to /tmp then run it via sudo bash (no interactive terminal needed)
|
||||||
$script = <<<'SH'
|
$script = <<<'SH'
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
#!/bin/bash
|
||||||
curl -fsSL https://get.docker.com | sh
|
set -e
|
||||||
systemctl enable --now docker
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
usermod -aG docker www-data
|
curl -fsSL https://get.docker.com -o /tmp/ncpx-get-docker.sh
|
||||||
SH;
|
bash /tmp/ncpx-get-docker.sh
|
||||||
|
rm -f /tmp/ncpx-get-docker.sh
|
||||||
|
systemctl enable --now docker
|
||||||
|
usermod -aG docker www-data
|
||||||
|
SH;
|
||||||
|
$scriptFile = '/tmp/ncpx-docker-install.sh';
|
||||||
|
file_put_contents($scriptFile, $script);
|
||||||
|
chmod($scriptFile, 0700);
|
||||||
$out = [];
|
$out = [];
|
||||||
exec('bash -c ' . escapeshellarg($script) . ' 2>&1', $out, $rc);
|
exec('sudo bash ' . escapeshellarg($scriptFile) . ' 2>&1', $out, $rc);
|
||||||
|
@unlink($scriptFile);
|
||||||
if ($rc !== 0) throw new RuntimeException("Docker install failed: " . implode("\n", $out));
|
if ($rc !== 0) throw new RuntimeException("Docker install failed: " . implode("\n", $out));
|
||||||
// Add sudoers entry so www-data can run docker without password
|
|
||||||
file_put_contents('/etc/sudoers.d/novacpx-docker',
|
|
||||||
"www-data ALL=(root) NOPASSWD: /usr/bin/docker\n");
|
|
||||||
chmod('/etc/sudoers.d/novacpx-docker', 0440);
|
|
||||||
novacpx_log('info', 'DockerManager: Docker CE installed');
|
novacpx_log('info', 'DockerManager: Docker CE installed');
|
||||||
return 'Docker installed successfully';
|
return 'Docker installed successfully';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
class WordPressManager {
|
class WordPressManager {
|
||||||
private PDO $db;
|
private \PDO $db;
|
||||||
private string $wpcli = '/usr/local/bin/wp';
|
private string $wpcli = '/usr/local/bin/wp';
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = Database::getInstance()->getPDO();
|
$this->db = DB::getInstance()->pdo();
|
||||||
$this->ensureWpCli();
|
$this->ensureWpCli();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user