/** * Disable and stop the MariaDB service * @return void */ function disable() { Log::debug('Disabling feature: mariadb'); // SystemD controller - stop mariadb exec('/usr/bin/systemctl -q stop mariadb 2>/dev/null'); // SystemD controller - disable mariadb exec('/usr/bin/systemctl -q disable mariadb 2>/dev/null'); Log::debug('Disabling feature: roundcube (dependency)'); // Disable Roundcube which depends on MariaDB & Dovecot $feature = new Roundcube(); $feature->disable(); }
/** * Run installation and setup * @param DatabaseSqlite3 &$db Database object * @return boolean */ public function run(&$db) { // Set object access to database $this->db = $db; Log::debug('Starting operating system setup'); // Get operating system information if (is_file('/etc/os-release')) { // Generic release file $os = file_get_contents('/etc/os-release'); // Grab Linux distribution name $id = array(); $rc = preg_match('/\\nID="?([^"\\n]*)"?\\n/', $os, $id); if ($rc !== 1 || !isset($id[1])) { Log::error('Error while trying to detect the Linux distribution name'); return false; } else { $id = $id[1]; } // Grab Linux distribution version $version = array(); $rc = preg_match('/\\nVERSION_ID="?([^"\\n]*)"?\\n/', $os, $version); if ($rc !== 1 || !isset($version[1])) { Log::error('Error while trying to detect the Linux distribution version'); return false; } else { $version = (int) $version[1]; } // Verify supported CentOS 7 if ($id !== "centos" || $version !== 7) { Log::error('Operating system distribution and/or version not supported by this setup module'); return false; } $rc = preg_match('/\\nPRETTY_NAME="?([^"\\n]*)"?\\n/', $os, $fullId); if ($rc !== 1 || isset($fullId[1])) { Log::debug('Detected: ' . $fullId[1]); } } else { Log::error('File not found: /etc/os-release'); // Generic release file not found return false; } // Requirements for the setup procedure if (class_exists('PDO', false) === false) { Log::error('The PDO package is required by the setup procedure. Please install it by running "yum install php-pdo".'); exit(9); } if (function_exists('mb_substr') === false) { Log::error('The multibyte package is required by the setup procedure. Please install it by running "yum install php-mbstring".'); exit(9); } // Required repositories $rc = $this->_repository(); if ($rc === false) { return false; } // Required packages $rc = $this->_package(); if ($rc === false) { return false; } // Setup SELinux $rc = $this->_selinux($this->db); if ($rc === false) { return false; } // Load and setup external features // PHP $feature = new Php(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // OpenDKIM $feature = new OpenDKIM(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable OpenDKIM if (Config::read('opendkim') === 'enabled') { $feature->enable(); } else { $feature->disable(); } // NSD $feature = new Nsd(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable NSD if (Config::read('nsd') === 'enabled') { $feature->enable(); } else { $feature->disable(); } // ClamAV $feature = new ClamAV(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable ClamAV if (Config::read('clamav') === 'enabled') { $feature->enable(); } else { $feature->disable(); } // Spamassassin $feature = new SpamAssassin(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable Spamassassin if (Config::read('spamassassin') === 'enabled') { $feature->enable(); } else { $feature->disable(); } // Postfix $feature = new Postfix(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable Postfix if (Config::read('postfix') === 'enabled') { $feature->enable(); } else { $feature->disable(); } // Dovecot $feature = new Dovecot(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable Dovecot if (Config::read('dovecot') === 'enabled') { $feature->enable(); } else { $feature->disable(); } // MariaDB $feature = new MariaDb(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable MariaDB if (Config::read('mariadb') === 'enabled') { $feature->enable(); } else { $feature->disable(); } // Roundcube webmail $feature = new Roundcube(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Disable Roundcube if needed, else leave enabled by default if (Config::read('roundcube') === 'disabled') { $feature->disable(); } // Apache $feature = new Apache(); $rc = $feature->exportConfiguration($this->db); if ($rc === false) { return false; } // Enable or disable Apache if (Config::read('apache') === 'enabled') { $feature->enable(); } else { $feature->disable(); } return true; }