Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
    case 'clamav':
        $feature = new ClamAV();
        break;
    case 'spamassassin':
        $feature = new SpamAssassin();
        break;
    case 'postfix':
        $feature = new Postfix();
        break;
    case 'dovecot':
        $feature = new Dovecot();
        break;
    case 'mariadb':
        $feature = new MariaDb();
        break;
    case 'roundcube':
        $feature = new Roundcube();
        break;
    case 'apache':
        $feature = new Apache();
        break;
    default:
        echo "[ERROR] Unknown parameter.\n";
        exit;
}
// Action
$rc = $feature->exportConfiguration($db);
if ($rc === false) {
    echo "[ERROR] Encountered an error while performing system setup.\n";
}
exit;
Ejemplo n.º 3
0
if ($rc === false) {
    echo "[ERROR] Error while exporting Postfix configuration.\n";
    exit(9);
}
// Reload Postfix
if (Config::read('postfix') === 'enabled') {
    $feature->reload();
}
// Dovecot setup
$feature = new Dovecot();
$rc = $feature->exportConfiguration($db);
if ($rc === false) {
    echo "[ERROR] Error while exporting Dovecot configuration.\n";
    exit(9);
}
// Reload Dovecot
if (Config::read('dovecot') === 'enabled') {
    $feature->reload();
}
// Apache setup
$feature = new Apache();
$rc = $feature->exportConfiguration($db);
if ($rc === false) {
    echo "[ERROR] Error while exporting Apache configuration.\n";
    exit(9);
}
// Reload Apache
if (Config::read('apache') === 'enabled') {
    $feature->reload();
}
exit;
Ejemplo n.º 4
0
if ($rc === false) {
    echo "[ERROR] Error while exporting Postfix configuration.\n";
    exit(9);
}
// Reload Postfix
if (Config::read('postfix') === 'enabled') {
    $feature->reload();
}
// Dovecot setup
$feature = new Dovecot();
$rc = $feature->exportVirtualHosts($db);
if ($rc === false) {
    echo "[ERROR] Error while exporting Dovecot configuration.\n";
    exit(9);
}
// Reload Dovecot
if (Config::read('dovecot') === 'enabled') {
    $feature->reload();
}
// Apache setup
$feature = new Apache();
$rc = $feature->exportVirtualHosts($db);
if ($rc === false) {
    echo "[ERROR] Error while exporting Apache configuration.\n";
    exit(9);
}
// Reload Apache
if (Config::read('apache') === 'enabled') {
    $feature->reload();
}
exit;
Ejemplo n.º 5
0
        $feature = new SpamAssassin();
        break;
    case 'postfix':
        $feature = new Postfix();
        break;
    case 'dovecot':
        $feature = new Dovecot();
        break;
    case 'mariadb':
        $feature = new MariaDb();
        break;
    case 'roundcube':
        $feature = new Roundcube();
        break;
    case 'apache':
        $feature = new Apache();
        break;
    default:
        echo "[ERROR] Unknown parameter.\n";
        exit;
}
// Action
if (isset($cmdParameters['e']) || isset($cmdParameters['enable'])) {
    // Set parameter in database
    Config::write($db, $name, 'enabled');
    // Enable feature/daemon
    $feature->enable();
} elseif (isset($cmdParameters['d']) || isset($cmdParameters['disable'])) {
    // Set parameter in database
    Config::write($db, $name, 'disabled');
    // Disable feature/daemon
Ejemplo n.º 6
0
 /**
  * Disable and stop the httpd service
  * @return void
  */
 function disable()
 {
     Log::debug('Disabling feature: apache');
     // Find Roundcube configuration for Apache and delete it
     $cfgFile = Config::read('apache|directoryConfD') . '/roundcubemail.conf';
     if (is_file($cfgFile)) {
         unlink($cfgFile);
     }
     // Reload Apache, if enabled
     if (Config::read('apache') === 'enabled') {
         $feature = new Apache();
         $feature->reload();
     }
 }