Commit cac71457 authored by Marius Burkard's avatar Marius Burkard
Browse files

- added loading/installing extra modules for virtual kernel (Quota)

parent 72fee8b5
......@@ -224,6 +224,7 @@ Possible arguments are:
--no-roundcube ->Do not install roundcube webmail.
--no-pma ->Do not install PHPMyAdmin on this server.
--no-mailman ->Do not install Mailman mailing list manager.
--no-quota ->Disable file system quota
--i-know-what-i-am-doing
->Prevent the autoinstaller to ask for confirmation before continuing to reconfigure the server.
';
......@@ -243,7 +244,7 @@ Possible arguments are:
$valid_args = array(
'help', 'debug', 'interactive',
'use-nginx', 'use-amavis', 'use-php', 'use-ftp-ports', 'channel', 'lang',
'no-web', 'no-mail', 'no-dns', 'no-firewall', 'no-roundcube', 'no-pma', 'no-mailman',
'no-web', 'no-mail', 'no-dns', 'no-firewall', 'no-roundcube', 'no-pma', 'no-mailman', 'no-quota',
'i-know-what-i-am-doing'
);
......
......@@ -150,7 +150,7 @@ class ISPConfigLog {
if(!$fp) {
throw new ISPConfigLogException('Could not open logfile ' . $log_file . '.');
}
if(!@fwrite($fp, strftime("%d.%m.%Y-%H:%M:%S", time()) . ' - ' . $caller['file'] . ':' . $caller['line'] . ': [' . self::PRIORITY_TEXT[$priority] . '] ' . $message . "\n")) {
if(!@fwrite($fp, strftime("%d.%m.%Y-%H:%M:%S", time()) . ' - ' . $caller['file'] . ':' . $caller['line'] . ': [' . self::PRIORITY_TEXT[$priority] . '] ' . PXBashColor::getCleanString($message) . "\n")) {
throw new ISPConfigLogException('Could not write to logfile ' . $log_file . '.');
}
fclose($fp);
......
......@@ -867,19 +867,53 @@ mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"';
);
$this->installPackages($packages);
ISPConfigLog::info('Adding quota to fstab.', true);
$replacements = array(
'/^(\S+\s+\/\s+ext\d)\s+(\S+)\s+(\d\s+\d)\s*$/m' => array(
'replace' => '$1 $2,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 $3',
'ifnot' => 'usrjquota='
)
);
$this->replaceContents('/etc/fstab', $replacements);
$cmd = 'mount -o remount / 2>&1 && quotaoff -avug 2>&1 && quotacheck -avugm 2>&1 && quotaon -avug 2>&1';
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
if(ISPConfig::shallInstall('quota')) {
// check kernel if it is virtual
$check = $this->getPackageVersion('linux-image-virtual');
if($check) {
ISPConfigLog::info('Installing extra quota package for virtual kernel.', true);
$this->installPackages('linux-image-extra-virtual');
// check kernel version from dpkg vs version running
$check = $this->getPackageVersion('linux-image-extra-virtual');
$running_version = php_uname('r');
if(!is_dir('/lib/modules/' . $running_version . '/kernel/fs/quota/') || !is_file('/lib/modules/' . $running_version . '/kernel/fs/quota/quota_v2.ko')) {
$running_version = preg_replace('/^([0-9\.]+(?:-\d+)?)(?:-.*?)?$/', '$1', $running_version);
try {
$this->installPackages('linux-image-extra-virtual=' . $running_version . '*');
} catch (Exception $ex) {
// ignore it
}
// check if quota module is available
if(!$this->exec('modinfo quota_v1 quota_v2 2>&1')) {
ISPConfigLog::error('The running kernel version (' . $running_version . ') does not match your installed kernel modules (' . $check . '). Currently there is no quota available! Please reboot your server to load the new kernel and run the autoinstaller again or start it with --no-quota to disable quota completely.', true);
throw new ISPConfigOSException('Installation aborted due to missing dependencies.');
}
}
ISPConfigLog::info('Enabling quota modules for virtual kernel.', true);
$cmd = 'modprobe quota_v2 quota_v1 2>&1';
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Enabling quota modules failed.');
}
}
ISPConfigLog::info('Adding quota to fstab.', true);
$replacements = array(
'/^(\S+\s+\/\s+ext\d)\s+(\S+)\s+(\d\s+\d)\s*$/m' => array(
'replace' => '$1 $2,usrjquota=quota.user,grpjquota=quota.group,jqfmt=vfsv0 $3',
'ifnot' => 'usrjquota='
)
);
$this->replaceContents('/etc/fstab', $replacements);
$cmd = 'mount -o remount / 2>&1 && quotaoff -avug 2>&1 && quotacheck -avugm 2>&1 && quotaon -avug 2>&1';
$result = $this->exec($cmd);
if($result === false) {
throw new ISPConfigOSException('Command ' . $cmd . ' failed.');
}
}
if(ISPConfig::shallInstall('web')) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment