From 873735bd1ad417099ded68788f0bcebfb45f07ca Mon Sep 17 00:00:00 2001 From: Thom Pol Date: Mon, 15 Mar 2021 20:37:42 +0100 Subject: [PATCH 1/2] Fix quota on AWS systems (#41) --- lib/os/class.ISPConfigDebianOS.inc.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/os/class.ISPConfigDebianOS.inc.php b/lib/os/class.ISPConfigDebianOS.inc.php index ebf9d5b..90f02cd 100644 --- a/lib/os/class.ISPConfigDebianOS.inc.php +++ b/lib/os/class.ISPConfigDebianOS.inc.php @@ -89,6 +89,16 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { return 'service ' . escapeshellarg($service) . ' ' . $command . ' 2>&1'; } + public function isThisAWS() { + $cmd = "curl --write-out '%{http_code}' --silent --output /dev/null -m 5 http://169.254.169.254/latest/dynamic/instance-identity/"; + $result = $this->exec($cmd); + if($result == "200") { + $thisIsAWS = true; + } else { + $thisIsAWS = false; + } + } + protected function updateMySQLConfig($mysql_root_pw) { ISPConfigLog::info('Writing MySQL config files.', true); $this->replaceContents('/etc/mysql/debian.cnf', array('/^password\s*=.*$/m' => 'password = ' . $mysql_root_pw)); @@ -997,6 +1007,20 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; $this->installPackages($packages); if(ISPConfig::shallInstall('quota')) { + // Check if this is a AWS instance + $this->isThisAWS(); + if($thisIsAWS == true) { + // Necessary quota module is removed from the kernel - we will install it. + ISPConfigLog::info('This is a AWS instance.', true); + $packages = 'linux-modules-extra-aws'; + $this->installPackages($packages); + // Run necessary commands to enable quota + $cmd = 'modprobe quota_v1; modprobe quota_v2'; + $result = $this->exec($cmd); + if($result === false) { + throw new ISPConfigOSException('Command ' . $cmd . ' failed.'); + } + } // check kernel if it is virtual $check = $this->getPackageVersion('linux-image-virtual'); if($check) { -- GitLab From 87663c01a953e0ce6d1c9eb8bd68e0fe9a590724 Mon Sep 17 00:00:00 2001 From: Thom Pol Date: Mon, 15 Mar 2021 21:03:21 +0100 Subject: [PATCH 2/2] Move AWS check --- lib/os/class.ISPConfigDebianOS.inc.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/os/class.ISPConfigDebianOS.inc.php b/lib/os/class.ISPConfigDebianOS.inc.php index 90f02cd..65c8c64 100644 --- a/lib/os/class.ISPConfigDebianOS.inc.php +++ b/lib/os/class.ISPConfigDebianOS.inc.php @@ -89,16 +89,6 @@ class ISPConfigDebianOS extends ISPConfigBaseOS { return 'service ' . escapeshellarg($service) . ' ' . $command . ' 2>&1'; } - public function isThisAWS() { - $cmd = "curl --write-out '%{http_code}' --silent --output /dev/null -m 5 http://169.254.169.254/latest/dynamic/instance-identity/"; - $result = $this->exec($cmd); - if($result == "200") { - $thisIsAWS = true; - } else { - $thisIsAWS = false; - } - } - protected function updateMySQLConfig($mysql_root_pw) { ISPConfigLog::info('Writing MySQL config files.', true); $this->replaceContents('/etc/mysql/debian.cnf', array('/^password\s*=.*$/m' => 'password = ' . $mysql_root_pw)); @@ -1008,7 +998,13 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"'; if(ISPConfig::shallInstall('quota')) { // Check if this is a AWS instance - $this->isThisAWS(); + $cmd = "curl --write-out '%{http_code}' --silent --output /dev/null -m 5 http://169.254.169.254/latest/dynamic/instance-identity/"; + $result = $this->exec($cmd); + if($result == "200") { + $thisIsAWS = true; + } else { + $thisIsAWS = false; + } if($thisIsAWS == true) { // Necessary quota module is removed from the kernel - we will install it. ISPConfigLog::info('This is a AWS instance.', true); -- GitLab