function simple_query($query, $answers, $default)
{
    $finished = false;
    do {
        $answers_str = implode(',', $answers);
        swrite($query . ' (' . $answers_str . ') [' . $default . ']: ');
        $input = sread();
        //* Stop the installation
        if ($input == 'quit') {
            swriteln("Installation terminated by user.\n");
            die;
        }
        //* Select the default
        if ($input == '') {
            $answer = $default;
            $finished = true;
        }
        //* Set answer id valid
        if (in_array($input, $answers)) {
            $answer = $input;
            $finished = true;
        }
    } while ($finished == false);
    swriteln();
    return $answer;
}
Beispiel #2
0
 public function __construct()
 {
     //** check apache modules */
     $mods = getapachemodules();
     if (in_array('authz_compat', $mods, true)) {
         swriteln($inst->lng('    WARNING! You are using mod_authz_compat.'));
         swriteln($inst->lng('    Please make sure that your apache config uses the new auth syntax:'));
         swriteln($inst->lng('    <Directory />'));
         swriteln($inst->lng('    Options None'));
         swriteln($inst->lng('    AllowOverride None'));
         swriteln($inst->lng('    Require all denied'));
         swriteln($inst->lng('    </Directory>' . "\n"));
         swriteln($inst->lng('    If it uses the old syntax (deny from all) ISPConfig would fail to work.'));
     }
 }
Beispiel #3
0
$inst->configure_dbserver();
//if(@is_dir('/etc/Bastille')) {
//* Configure Firewall
swriteln('Configuring Firewall');
$inst->configure_firewall();
//}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$conf['apache']['vhost_port'] = get_ispconfig_port_number();
$inst->install_ispconfig();
//** Configure Crontab
swriteln('Updating Crontab');
$inst->install_crontab();
//** Restart services:
swriteln('Restarting services ...');
if ($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'] . '/' . $conf['mysql']['init_script'])) {
    system($conf['init_scripts'] . '/' . $conf['mysql']['init_script'] . ' reload');
}
if ($conf['services']['mail']) {
    if ($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'] . '/' . $conf['postfix']['init_script'])) {
        system($conf['init_scripts'] . '/' . $conf['postfix']['init_script'] . ' restart');
    }
    if ($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'] . '/' . $conf['saslauthd']['init_script'])) {
        system($conf['init_scripts'] . '/' . $conf['saslauthd']['init_script'] . ' restart');
    }
    if ($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'] . '/' . $conf['amavis']['init_script'])) {
        system($conf['init_scripts'] . '/' . $conf['amavis']['init_script'] . ' restart');
    }
    if ($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'] . '/' . $conf['clamav']['init_script'])) {
        system($conf['init_scripts'] . '/' . $conf['clamav']['init_script'] . ' restart');
Beispiel #4
0
function updateDbAndIni()
{
    global $inst, $conf;
    //* Update $conf array with values from the server.ini that shall be preserved
    $tmp = $inst->db->queryOneRecord("SELECT * FROM " . $conf["mysql"]["database"] . ".server WHERE server_id = " . $conf['server_id']);
    $ini_array = ini_to_array(stripslashes($tmp['config']));
    $current_db_version = isset($tmp['dbversion']) ? intval($tmp['dbversion']) : 0;
    if (!is_array($ini_array) or count($ini_array) == 0) {
        die('Unable to read server configuration from database.');
    }
    $conf['services']['mail'] = $tmp['mail_server'] == 1 ? true : false;
    $conf['services']['web'] = $tmp['web_server'] == 1 ? true : false;
    $conf['services']['dns'] = $tmp['dns_server'] == 1 ? true : false;
    $conf['services']['file'] = $tmp['file_server'] == 1 ? true : false;
    $conf['services']['db'] = $tmp['db_server'] == 1 ? true : false;
    $conf['services']['vserver'] = $tmp['vserver_server'] == 1 ? true : false;
    $conf['services']['proxy'] = isset($tmp['proxy_server']) && $tmp['proxy_server'] == 1 ? true : false;
    $conf['services']['firewall'] = isset($tmp['firewall_server']) && $tmp['firewall_server'] == 1 ? true : false;
    $conf['postfix']['vmail_mailbox_base'] = $ini_array['mail']['homedir_path'];
    if (isset($ini_array['web']['server_type']) && $ini_array['web']['server_type'] != '') {
        $conf['webserver']['server_type'] = $ini_array['web']['server_type'];
        if ($conf['webserver']['server_type'] == 'nginx') {
            $conf['apache']['installed'] = false;
        } else {
            $conf['nginx']['installed'] = false;
        }
    } else {
        $conf['webserver']['server_type'] = 'apache';
        $conf['nginx']['installed'] = false;
    }
    //* Do incremental DB updates only on installed ISPConfig versions >= 3.0.3
    if (version_compare('3.0.3', ISPC_APP_VERSION, '<=')) {
        swriteln($inst->lng('Starting incremental database update.'));
        //* get the version of the db schema from the server table
        $found = true;
        while ($found == true) {
            $next_db_version = intval($current_db_version + 1);
            $sql_patch_filename = realpath(dirname(__FILE__) . '/../') . '/sql/incremental/upd_' . str_pad($next_db_version, 4, '0', STR_PAD_LEFT) . '.sql';
            $php_patch_filename = realpath(dirname(__FILE__) . '/../') . '/patches/upd_' . str_pad($next_db_version, 4, '0', STR_PAD_LEFT) . '.php';
            // comma separated list of version numbers were a update has to be done silently
            $silent_update_versions = '75';
            if (is_file($sql_patch_filename)) {
                //* Load php patch file and instantiate object
                if (is_file($php_patch_filename)) {
                    $php_patch_class_name = 'upd_' . str_pad($next_db_version, 4, '0', STR_PAD_LEFT);
                    include_once $php_patch_filename;
                    if (class_exists($php_patch_class_name)) {
                        $php_patch = new $php_patch_class_name();
                    } else {
                        swriteln($inst->lng('WARNING: PHP patch file') . ': ' . $php_patch_filename . ' ' . $inst->lng('contains errors.'));
                    }
                }
                //* Exec onBeforeSQL function
                if (isset($php_patch) && is_object($php_patch)) {
                    $php_patch->onBeforeSQL();
                    swriteln($inst->lng('Executing PHP patch file') . ': ' . $php_patch_filename);
                }
                //* Load patch file into database
                if (!empty($conf["mysql"]["admin_password"])) {
                    $cmd = "mysql --default-character-set=" . escapeshellarg($conf['mysql']['charset']) . " --force -h " . escapeshellarg($conf['mysql']['host']) . " -u " . escapeshellarg($conf['mysql']['admin_user']) . " -p" . escapeshellarg($conf['mysql']['admin_password']) . " " . escapeshellarg($conf['mysql']['database']) . " < " . $sql_patch_filename;
                } else {
                    $cmd = "mysql --default-character-set=" . escapeshellarg($conf['mysql']['charset']) . " --force -h " . escapeshellarg($conf['mysql']['host']) . " -u " . escapeshellarg($conf['mysql']['admin_user']) . " " . escapeshellarg($conf['mysql']['database']) . " < " . $sql_patch_filename;
                }
                if (in_array($next_db_version, explode(',', $silent_update_versions))) {
                    $cmd .= ' > /dev/null 2> /dev/null';
                }
                system($cmd);
                swriteln($inst->lng('Loading SQL patch file') . ': ' . $sql_patch_filename);
                //* Exec onAfterSQL function
                if (isset($php_patch) && is_object($php_patch)) {
                    $php_patch->onAfterSQL();
                }
                $current_db_version = $next_db_version;
                if (isset($php_patch)) {
                    unset($php_patch);
                }
            } else {
                $found = false;
            }
        }
        //* update the database version in server table
        $inst->db->query("UPDATE " . $conf["mysql"]["database"] . ".server SET dbversion = '" . $current_db_version . "' WHERE server_id = " . $conf['server_id']);
        if ($inst->db->dbHost != $inst->dbmaster->dbHost) {
            $inst->dbmaster->query("UPDATE " . $conf["mysql"]["master_database"] . ".server SET dbversion = '" . $current_db_version . "' WHERE server_id = " . $conf['server_id']);
        }
        //* If ISPConfig Version < 3.0.3, we will do a full db update
    } else {
        swriteln($inst->lng('Starting full database update.'));
        //** Delete the old database
        if (!$inst->db->query('DROP DATABASE IF EXISTS ' . $conf['mysql']['database'])) {
            $inst->error('Unable to drop MySQL database: ' . $conf['mysql']['database'] . '.');
        }
        //** Create the mysql database
        $inst->configure_database();
        //** empty all databases
        $db_tables = $inst->db->getTables();
        foreach ($db_tables as $table) {
            $inst->db->query("TRUNCATE {$table}");
        }
        //** load old data back into database
        if (!empty($conf["mysql"]["admin_password"])) {
            system("mysql --default-character-set=" . escapeshellarg($conf['mysql']['charset']) . " --force -h " . escapeshellarg($conf['mysql']['host']) . " -u " . escapeshellarg($conf['mysql']['admin_user']) . " -p" . escapeshellarg($conf['mysql']['admin_password']) . " " . escapeshellarg($conf['mysql']['database']) . " < existing_db.sql");
        } else {
            system("mysql --default-character-set=" . escapeshellarg($conf['mysql']['charset']) . " --force -h " . escapeshellarg($conf['mysql']['host']) . " -u " . escapeshellarg($conf['mysql']['admin_user']) . " " . escapeshellarg($conf['mysql']['database']) . " < existing_db.sql");
        }
        //** Get the database version number based on the patchfile
        $found = true;
        while ($found == true) {
            $next_db_version = intval($current_db_version + 1);
            $patch_filename = realpath(dirname(__FILE__) . '/../') . '/sql/incremental/upd_' . str_pad($next_db_version, 4, '0', STR_PAD_LEFT) . '.sql';
            if (is_file($patch_filename)) {
                $current_db_version = $next_db_version;
            } else {
                $found = false;
            }
        }
        //* update the database version in server table
        $inst->db->query("UPDATE " . $conf["mysql"]["database"] . ".server SET dbversion = '" . $current_db_version . "' WHERE server_id = " . $conf['server_id']);
        if ($inst->db->dbHost != $inst->dbmaster->dbHost) {
            $inst->dbmaster->query("UPDATE " . $conf["mysql"]["master_database"] . ".server SET dbversion = '" . $current_db_version . "' WHERE server_id = " . $conf['server_id']);
        }
        if ($conf['powerdns']['installed']) {
            swriteln($inst->lng('Starting full PowerDNS database update.'));
            //** Delete the old PowerDNS database
            if (!$inst->db->query('DROP DATABASE IF EXISTS ' . $conf['powerdns']['database'])) {
                $inst->error('Unable to drop MySQL database: ' . $conf['powerdns']['database'] . '.');
            }
            //** Create the mysql database
            $inst->configure_powerdns();
            //** load old data back into the PowerDNS database
            if (!empty($conf["mysql"]["admin_password"])) {
                system("mysql --default-character-set=" . escapeshellarg($conf['mysql']['charset']) . " --force -h " . escapeshellarg($conf['mysql']['host']) . " -u " . escapeshellarg($conf['mysql']['admin_user']) . " -p" . escapeshellarg($conf['mysql']['admin_password']) . " " . escapeshellarg($conf['powerdns']['database']) . " < existing_powerdns_db.sql");
            } else {
                system("mysql --default-character-set=" . escapeshellarg($conf['mysql']['charset']) . " --force -h " . escapeshellarg($conf['mysql']['host']) . " -u " . escapeshellarg($conf['mysql']['admin_user']) . " " . escapeshellarg($conf['powerdns']['database']) . " < existing_powerdns_db.sql");
            }
        }
    }
    //** Update server ini
    $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM " . $conf["mysql"]["database"] . ".server WHERE server_id = " . $conf['server_id']);
    $old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config']));
    unset($tmp_server_rec);
    $tpl_ini_array = ini_to_array(rf('tpl/server.ini.master'));
    //* Update further distribution specific parameters for server config here
    //* HINT: Every line added here has to be added in installer_base.lib.php too!!
    $tpl_ini_array['jailkit']['jailkit_chroot_app_programs'] = $conf['jailkit']['jailkit_chroot_app_programs'];
    $tpl_ini_array['fastcgi']['fastcgi_phpini_path'] = $conf['fastcgi']['fastcgi_phpini_path'];
    $tpl_ini_array['fastcgi']['fastcgi_starter_path'] = $conf['fastcgi']['fastcgi_starter_path'];
    $tpl_ini_array['fastcgi']['fastcgi_bin'] = $conf['fastcgi']['fastcgi_bin'];
    $tpl_ini_array['server']['hostname'] = $conf['hostname'];
    $tpl_ini_array['server']['ip_address'] = @gethostbyname($conf['hostname']);
    $tpl_ini_array['web']['website_basedir'] = $conf['web']['website_basedir'];
    $tpl_ini_array['web']['website_path'] = $conf['web']['website_path'];
    $tpl_ini_array['web']['website_symlinks'] = $conf['web']['website_symlinks'];
    $tpl_ini_array['cron']['crontab_dir'] = $conf['cron']['crontab_dir'];
    $tpl_ini_array['web']['security_level'] = 20;
    $tpl_ini_array['web']['user'] = $conf['apache']['user'];
    $tpl_ini_array['web']['group'] = $conf['apache']['group'];
    $tpl_ini_array['web']['php_ini_path_apache'] = $conf['apache']['php_ini_path_apache'];
    $tpl_ini_array['web']['php_ini_path_cgi'] = $conf['apache']['php_ini_path_cgi'];
    $tpl_ini_array['mail']['pop3_imap_daemon'] = $conf['dovecot']['installed'] == true ? 'dovecot' : 'courier';
    $tpl_ini_array['mail']['mail_filter_syntax'] = $conf['dovecot']['installed'] == true ? 'sieve' : 'maildrop';
    $tpl_ini_array['dns']['bind_user'] = $conf['bind']['bind_user'];
    $tpl_ini_array['dns']['bind_group'] = $conf['bind']['bind_group'];
    $tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir'];
    $tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
    $tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
    $tpl_ini_array['web']['nginx_vhost_conf_dir'] = $conf['nginx']['vhost_conf_dir'];
    $tpl_ini_array['web']['nginx_vhost_conf_enabled_dir'] = $conf['nginx']['vhost_conf_enabled_dir'];
    $tpl_ini_array['web']['nginx_user'] = $conf['nginx']['user'];
    $tpl_ini_array['web']['nginx_group'] = $conf['nginx']['group'];
    $tpl_ini_array['web']['nginx_cgi_socket'] = $conf['nginx']['cgi_socket'];
    $tpl_ini_array['web']['php_fpm_init_script'] = $conf['nginx']['php_fpm_init_script'];
    $tpl_ini_array['web']['php_fpm_ini_path'] = $conf['nginx']['php_fpm_ini_path'];
    $tpl_ini_array['web']['php_fpm_pool_dir'] = $conf['nginx']['php_fpm_pool_dir'];
    $tpl_ini_array['web']['php_fpm_start_port'] = $conf['nginx']['php_fpm_start_port'];
    $tpl_ini_array['web']['php_fpm_socket_dir'] = $conf['nginx']['php_fpm_socket_dir'];
    if ($conf['nginx']['installed'] == true) {
        $tpl_ini_array['web']['server_type'] = 'nginx';
        $tpl_ini_array['global']['webserver'] = 'nginx';
    }
    //* update the new template with the old values
    if (is_array($old_ini_array)) {
        foreach ($old_ini_array as $tmp_section_name => $tmp_section_content) {
            foreach ($tmp_section_content as $tmp_var_name => $tmp_var_content) {
                $tpl_ini_array[$tmp_section_name][$tmp_var_name] = $tmp_var_content;
            }
        }
    }
    $new_ini = array_to_ini($tpl_ini_array);
    $sql = "UPDATE " . $conf["mysql"]["database"] . ".server SET config = '" . mysql_real_escape_string($new_ini) . "' WHERE server_id = " . $conf['server_id'];
    $inst->db->query($sql);
    if ($inst->db->dbHost != $inst->dbmaster->dbHost) {
        $sql = "UPDATE " . $conf["mysql"]["master_database"] . ".server SET config = '" . mysql_real_escape_string($new_ini) . "' WHERE server_id = " . $conf['server_id'];
        $inst->dbmaster->query($sql);
    }
    unset($old_ini_array);
    unset($tpl_ini_array);
    unset($new_ini);
    //** Update system ini
    $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM " . $conf["mysql"]["database"] . ".sys_ini WHERE sysini_id = 1");
    $old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config']));
    unset($tmp_server_rec);
    $tpl_ini_array = ini_to_array(rf('tpl/system.ini.master'));
    // update the new template with the old values
    if (is_array($old_ini_array)) {
        foreach ($old_ini_array as $tmp_section_name => $tmp_section_content) {
            foreach ($tmp_section_content as $tmp_var_name => $tmp_var_content) {
                $tpl_ini_array[$tmp_section_name][$tmp_var_name] = $tmp_var_content;
            }
        }
    }
    $new_ini = array_to_ini($tpl_ini_array);
    $tmp = $inst->db->queryOneRecord('SELECT count(sysini_id) as number FROM ' . $conf["mysql"]["database"] . '.sys_ini WHERE 1');
    if ($tmp['number'] == 0) {
        $inst->db->query("INSERT INTO " . $conf["mysql"]["database"] . ".sys_ini (sysini_id, config) VALUES (1,'" . mysql_real_escape_string($new_ini) . "')");
    } else {
        $inst->db->query("UPDATE " . $conf["mysql"]["database"] . ".sys_ini SET config = '" . mysql_real_escape_string($new_ini) . "' WHERE sysini_id = 1");
    }
    unset($old_ini_array);
    unset($tpl_ini_array);
    unset($new_ini);
}
Beispiel #5
0
 function OuterHTML()
 {
     $res = '';
     $res = swriteln($res, '<form' . ($this->settings['action'] != '' ? ' action="' . $this->settings['action'] . '"' : '') . ($this->settings['method'] != '' ? ' method="' . $this->settings['method'] . '"' : '') . ($this->settings['enctype'] != '' ? ' enctype="' . $this->settings['enctype'] . '"' : '') . ' onsubmit="form_' . $this->settings['name'] . '_check (this); return false;">');
     $res = swriteln($res, $this->InnerHTML());
     $res = swriteln($res, '</form>');
     return $res;
 }
function get_distname()
{
    $distname = '';
    $distver = '';
    $distid = '';
    $distbaseid = '';
    //** Debian or Ubuntu
    if (file_exists('/etc/debian_version')) {
        if (strstr(trim(file_get_contents('/etc/issue')), 'Ubuntu')) {
            if (strstr(trim(file_get_contents('/etc/issue')), 'LTS')) {
                $lts = " LTS";
            } else {
                $lts = "";
            }
            $issue = file_get_contents('/etc/issue');
            $distname = 'Ubuntu';
            $distid = 'debian40';
            $distbaseid = 'debian';
            $ver = explode(' ', $issue);
            $ver = array_filter($ver);
            $ver = next($ver);
            $mainver = explode('.', $ver);
            $mainver = array_filter($mainver);
            $mainver = current($mainver) . '.' . next($mainver);
            switch ($mainver) {
                case "15.04":
                    $relname = "(Vivid Vervet)";
                    break;
                case "14.10":
                    $relname = "(Utopic Unicorn)";
                    break;
                case "14.04":
                    $relname = "(Trusty Tahr)";
                    break;
                case "13.10":
                    $relname = "(Saucy Salamander)";
                    break;
                case "13.04":
                    $relname = "(Raring Ringtail)";
                    break;
                case "12.10":
                    $relname = "(Quantal Quetzal)";
                    break;
                case "12.04":
                    $relname = "(Precise Pangolin)";
                    break;
                case "11.10":
                    $relname = "(Oneiric Ocelot)";
                    break;
                case "11.14":
                    $relname = "(Natty Narwhal)";
                    break;
                case "10.10":
                    $relname = "(Maverick Meerkat)";
                    break;
                case "10.04":
                    $relname = "(Lucid Lynx)";
                    break;
                case "9.10":
                    $relname = "(Karmic Koala)";
                    break;
                case "9.04":
                    $relname = "(Jaunty Jackpole)";
                    break;
                case "8.10":
                    $relname = "(Intrepid Ibex)";
                    break;
                case "8.04":
                    $relname = "(Hardy Heron)";
                    break;
                case "7.10":
                    $relname = "(Gutsy Gibbon)";
                    break;
                case "7.04":
                    $relname = "(Feisty Fawn)";
                    break;
                case "6.10":
                    $relname = "(Edgy Eft)";
                    break;
                case "6.06":
                    $relname = "(Dapper Drake)";
                    break;
                case "5.10":
                    $relname = "(Breezy Badger)";
                    break;
                case "5.04":
                    $relname = "(Hoary Hedgehog)";
                    break;
                case "4.10":
                    $relname = "(Warty Warthog)";
                    break;
                default:
                    $relname = "UNKNOWN";
            }
            $distver = $ver . $lts . " " . $relname;
            swriteln("Operating System: " . $distver . "\n");
        } elseif (trim(file_get_contents('/etc/debian_version')) == '4.0') {
            $distname = 'Debian';
            $distver = '4.0';
            $distid = 'debian40';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian 4.0 or compatible\n");
        } elseif (strstr(trim(file_get_contents('/etc/debian_version')), '5.0')) {
            $distname = 'Debian';
            $distver = 'Lenny';
            $distid = 'debian40';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian Lenny or compatible\n");
        } elseif (strstr(trim(file_get_contents('/etc/debian_version')), '6.0') || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') {
            $distname = 'Debian';
            $distver = 'Squeeze/Sid';
            $distid = 'debian60';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian 6.0 (Squeeze/Sid) or compatible\n");
        } elseif (strstr(trim(file_get_contents('/etc/debian_version')), '7.0') || substr(trim(file_get_contents('/etc/debian_version')), 0, 2) == '7.' || trim(file_get_contents('/etc/debian_version')) == 'wheezy/sid') {
            $distname = 'Debian';
            $distver = 'Wheezy/Sid';
            $distid = 'debian60';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian 7.0 (Wheezy/Sid) or compatible\n");
        } elseif (strstr(trim(file_get_contents('/etc/debian_version')), '8') || substr(trim(file_get_contents('/etc/debian_version')), 0, 1) == '8') {
            $distname = 'Debian';
            $distver = 'Jessie';
            $distid = 'debian60';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian 8.0 (Jessie) or compatible\n");
        } else {
            $distname = 'Debian';
            $distver = 'Unknown';
            $distid = 'debian40';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian or compatible, unknown version.\n");
        }
    } elseif (file_exists('/etc/SuSE-release')) {
        if (stristr(file_get_contents('/etc/SuSE-release'), '11.0')) {
            $distname = 'openSUSE';
            $distver = '11.0';
            $distid = 'opensuse110';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE 11.0 or compatible\n");
        } elseif (stristr(file_get_contents('/etc/SuSE-release'), '11.1')) {
            $distname = 'openSUSE';
            $distver = '11.1';
            $distid = 'opensuse110';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE 11.1 or compatible\n");
        } elseif (stristr(file_get_contents('/etc/SuSE-release'), '11.2')) {
            $distname = 'openSUSE';
            $distver = '11.2';
            $distid = 'opensuse112';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE 11.2 or compatible\n");
        } else {
            $distname = 'openSUSE';
            $distver = 'Unknown';
            $distid = 'opensuse112';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE or compatible, unknown version.\n");
        }
    } elseif (file_exists('/etc/redhat-release')) {
        $content = file_get_contents('/etc/redhat-release');
        if (stristr($content, 'Fedora release 9 (Sulphur)')) {
            $distname = 'Fedora';
            $distver = '9';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Fedora 9 or compatible\n");
        } elseif (stristr($content, 'Fedora release 10 (Cambridge)')) {
            $distname = 'Fedora';
            $distver = '10';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Fedora 10 or compatible\n");
        } elseif (stristr($content, 'Fedora release 10')) {
            $distname = 'Fedora';
            $distver = '11';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Fedora 11 or compatible\n");
        } elseif (stristr($content, 'CentOS release 5.2 (Final)')) {
            $distname = 'CentOS';
            $distver = '5.2';
            $distid = 'centos52';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 5.2 or compatible\n");
        } elseif (stristr($content, 'CentOS release 5.3 (Final)')) {
            $distname = 'CentOS';
            $distver = '5.3';
            $distid = 'centos53';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 5.3 or compatible\n");
        } elseif (stristr($content, 'CentOS release 5')) {
            $distname = 'CentOS';
            $distver = 'Unknown';
            $distid = 'centos53';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 5 or compatible\n");
        } elseif (stristr($content, 'CentOS Linux release 6')) {
            $distname = 'CentOS';
            $distver = 'Unknown';
            $distid = 'centos53';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 6 or compatible\n");
        } elseif (stristr($content, 'CentOS Linux release 7')) {
            $distname = 'CentOS';
            $distver = 'Unknown';
            $distid = 'centos70';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 7 or compatible\n");
        } else {
            $distname = 'Redhat';
            $distver = 'Unknown';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Redhat or compatible, unknown version.\n");
        }
    } elseif (file_exists('/etc/gentoo-release')) {
        $content = file_get_contents('/etc/gentoo-release');
        preg_match_all('/([0-9]{1,2})/', $content, $version);
        $distname = 'Gentoo';
        $distver = $version[0][0] . $version[0][1];
        $distid = 'gentoo';
        $distbaseid = 'gentoo';
        swriteln("Operating System: Gentoo {$distver} or compatible\n");
    } else {
        die('Unrecognized GNU/Linux distribution');
    }
    return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid);
}
Beispiel #7
0
            $conf['nginx']['vhost_port'] = $ispconfig_vhost_port;
        }
        unset($ispconfig_vhost_port);
        if (strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface', array('y', 'n'), 'y')) == 'y') {
            $inst->make_ispconfig_ssl_cert();
        }
        $inst->install_ispconfig_interface = true;
    } else {
        $inst->install_ispconfig_interface = false;
    }
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    if ($conf['apache']['installed'] == true && $conf['apache']['init_script'] != '' && @is_file($conf['init_scripts'] . '/' . $conf['apache']['init_script'])) {
        system($conf['init_scripts'] . '/' . $conf['apache']['init_script'] . ' restart');
    }
    //* Reload is enough for nginx
    if ($conf['nginx']['installed'] == true) {
        if ($conf['nginx']['php_fpm_init_script'] != '' && @is_file($conf['init_scripts'] . '/' . $conf['nginx']['php_fpm_init_script'])) {
            system($conf['init_scripts'] . '/' . $conf['nginx']['php_fpm_init_script'] . ' reload');
        }
        if ($conf['nginx']['init_script'] != '' && @is_file($conf['init_scripts'] . '/' . $conf['nginx']['init_script'])) {
            system($conf['init_scripts'] . '/' . $conf['nginx']['init_script'] . ' reload');
        }
    }
}
//* << $install_mode / 'Standard' or Genius
Beispiel #8
0
 function HeadSource()
 {
     $result = '';
     $result = swriteln($result, '<title>' . $this->GetSetting('title') . '</title>');
     // Styles
     $result .= $this->MetasSource();
     $p = config_get('document-root') . '/styles/';
     foreach ($this->CSStyles as $s) {
         $result = swriteln($result, $this->FromTemplate('link', array('rel' => 'stylesheet', 'type' => "text/css", 'href' => $p . $s . '.css')));
     }
     // favicon
     $ico = $this->GetIcon();
     if ($ico != '') {
         $result = swriteln($result, $this->FromTemplate('link', array('rel' => 'icon', 'href' => $ico, 'type' => 'image/x-icon')));
         $result = swriteln($result, $this->FromTemplate('link', array('rel' => 'SHORTCUT ICON', 'href' => $ico)));
     }
     $rss = $this->GetRSS();
     if ($rss['href'] != '') {
         $result = swriteln($result, $this->FromTemplate('link', array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => $rss['title'], 'href' => $rss['href'])));
     }
     $result .= $this->ScriptsSource();
     return $result;
 }
Beispiel #9
0
function get_distname()
{
    $distname = '';
    $distver = '';
    $distid = '';
    $distbaseid = '';
    //** Debian or Ubuntu
    if (file_exists('/etc/debian_version')) {
        if (trim(file_get_contents('/etc/debian_version')) == '4.0') {
            $distname = 'Debian';
            $distver = '4.0';
            $distid = 'debian40';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian 4.0 or compatible\n");
        } elseif (strstr(trim(file_get_contents('/etc/debian_version')), '5.0')) {
            $distname = 'Debian';
            $distver = 'Lenny';
            $distid = 'debian40';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian Lenny or compatible\n");
        } elseif (strstr(trim(file_get_contents('/etc/debian_version')), '6.0') || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') {
            $distname = 'Debian';
            $distver = 'Squeeze/Sid';
            $distid = 'debian60';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian 6.0 (Squeeze/Sid) or compatible\n");
        } else {
            $distname = 'Debian';
            $distver = 'Unknown';
            $distid = 'debian40';
            $distbaseid = 'debian';
            swriteln("Operating System: Debian or compatible, unknown version.\n");
        }
    } elseif (file_exists('/etc/SuSE-release')) {
        if (stristr(file_get_contents('/etc/SuSE-release'), '11.0')) {
            $distname = 'openSUSE';
            $distver = '11.0';
            $distid = 'opensuse110';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE 11.0 or compatible\n");
        } elseif (stristr(file_get_contents('/etc/SuSE-release'), '11.1')) {
            $distname = 'openSUSE';
            $distver = '11.1';
            $distid = 'opensuse110';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE 11.1 or compatible\n");
        } elseif (stristr(file_get_contents('/etc/SuSE-release'), '11.2')) {
            $distname = 'openSUSE';
            $distver = '11.2';
            $distid = 'opensuse112';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE 11.2 or compatible\n");
        } else {
            $distname = 'openSUSE';
            $distver = 'Unknown';
            $distid = 'opensuse112';
            $distbaseid = 'opensuse';
            swriteln("Operating System: openSUSE or compatible, unknown version.\n");
        }
    } elseif (file_exists('/etc/redhat-release')) {
        $content = file_get_contents('/etc/redhat-release');
        if (stristr($content, 'Fedora release 9 (Sulphur)')) {
            $distname = 'Fedora';
            $distver = '9';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Fedora 9 or compatible\n");
        } elseif (stristr($content, 'Fedora release 10 (Cambridge)')) {
            $distname = 'Fedora';
            $distver = '10';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Fedora 10 or compatible\n");
        } elseif (stristr($content, 'Fedora release 10')) {
            $distname = 'Fedora';
            $distver = '11';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Fedora 11 or compatible\n");
        } elseif (stristr($content, 'CentOS release 5.2 (Final)')) {
            $distname = 'CentOS';
            $distver = '5.2';
            $distid = 'centos52';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 5.2 or compatible\n");
        } elseif (stristr($content, 'CentOS release 5.3 (Final)')) {
            $distname = 'CentOS';
            $distver = '5.3';
            $distid = 'centos53';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 5.3 or compatible\n");
        } elseif (stristr($content, 'CentOS release 5')) {
            $distname = 'CentOS';
            $distver = 'Unknown';
            $distid = 'centos53';
            $distbaseid = 'fedora';
            swriteln("Operating System: CentOS 5 or compatible\n");
        } else {
            $distname = 'Redhat';
            $distver = 'Unknown';
            $distid = 'fedora9';
            $distbaseid = 'fedora';
            swriteln("Operating System: Redhat or compatible, unknown version.\n");
        }
    } elseif (file_exists('/etc/gentoo-release')) {
        $content = file_get_contents('/etc/gentoo-release');
        preg_match_all('/([0-9]{1,2})/', $content, $version);
        $distname = 'Gentoo';
        $distver = $version[0][0] . $version[0][1];
        $distid = 'gentoo';
        $distbaseid = 'gentoo';
        swriteln("Operating System: Gentoo {$distver} or compatible\n");
    } else {
        die('Unrecognized GNU/Linux distribution');
    }
    return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid);
}
 public function free_query($query, $default)
 {
     swrite($this->lng($query) . ' [' . $default . ']: ');
     $input = sread();
     //* Stop the installation
     if ($input == 'quit') {
         swriteln($this->lng("Installation terminated by user.\n"));
         die;
     }
     $answer = $input == '' ? $default : $input;
     swriteln();
     return $answer;
 }
 public function free_query($query, $default, $name = '')
 {
     global $autoinstall;
     if ($name != '' && $autoinstall[$name] != '') {
         if ($autoinstall[$name] == 'default') {
             $input = $default;
         } else {
             $input = $autoinstall[$name];
         }
     } else {
         swrite($this->lng($query) . ' [' . $default . ']: ');
         $input = sread();
     }
     //* Stop the installation
     if ($input == 'quit') {
         swriteln($this->lng("Installation terminated by user.\n"));
         die;
     }
     $answer = $input == '' ? $default : $input;
     swriteln();
     return $answer;
 }