Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class installer_base {
var $wb = array();
var $language = 'en';
var $db;
public $conf;
public $install_ispconfig_interface = true;
public $is_update = false; // true if it is an update, falsi if it is a new install
public $min_php = '5.3.3'; // minimal php-version for update / install
protected $mailman_group = 'list';
public function __construct() {
global $conf; //TODO: maybe $conf should be passed to constructor
//$this->conf = $conf;
}
//: TODO Implement the translation function and language files for the installer.
public function lng($text) {
return $text;
}
public function error($msg) {
die('ERROR: '.$msg."\n");
}
public function warning($msg) {
public function simple_query($query, $answers, $default, $name = '') {
global $autoinstall;
if($name != '' && $autoinstall[$name] != '') {
if($autoinstall[$name] == 'default') {
$input = $default;
} else {
$input = $autoinstall[$name];
}
Till Brehm
committed
} elseif($name != '' && $autoupdate[$name] != '') {
if($autoupdate[$name] == 'default') {
$input = $default;
} else {
$input = $autoupdate[$name];
}
} else {
$answers_str = implode(',', $answers);
swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
$input = sread();
}
//* Stop the installation
if($input == 'quit') {
swriteln($this->lng("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;
}
public function free_query($query, $default, $name = '') {
global $autoinstall;
if($name != '' && $autoinstall[$name] != '') {
if($autoinstall[$name] == 'default') {
$input = $default;
} else {
$input = $autoinstall[$name];
}
Till Brehm
committed
} elseif($name != '' && $autoupdate[$name] != '') {
if($autoupdate[$name] == 'default') {
$input = $default;
} else {
$input = $autoupdate[$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;
}
/*
// TODO: this function is not used atmo I think - pedro
function request_language(){
swriteln(lng('Enter your language'));
swriteln(lng('de, en'));
//** Detect PHP-Version
public function get_php_version() {
if(version_compare(PHP_VERSION, $this->min_php, '<')) return false;
else return true;
//** Detect installed applications
public function find_installed_apps() {
global $conf;
if(is_installed('mysql') || is_installed('mysqld')) $conf['mysql']['installed'] = true;
if(is_installed('postfix')) $conf['postfix']['installed'] = true;
if(is_installed('postgrey')) $conf['postgrey']['installed'] = true;
Florian Schaal
committed
if(is_installed('mailman') || is_installed('mmsitepass')) $conf['mailman']['installed'] = true;
Falko Timme
committed
if(is_installed('apache') || is_installed('apache2') || is_installed('httpd') || is_installed('httpd2')) $conf['apache']['installed'] = true;
if(is_installed('getmail')) $conf['getmail']['installed'] = true;
if(is_installed('courierlogger')) $conf['courier']['installed'] = true;
if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
if(is_installed('saslauthd')) $conf['saslauthd']['installed'] = true;
if(is_installed('amavisd-new') || is_installed('amavisd')) $conf['amavis']['installed'] = true;
if(is_installed('clamdscan')) $conf['clamav']['installed'] = true;
if(is_installed('pure-ftpd') || is_installed('pure-ftpd-wrapper')) $conf['pureftpd']['installed'] = true;
if(is_installed('mydns') || is_installed('mydns-ng')) $conf['mydns']['installed'] = true;
if(is_installed('jk_chrootsh')) $conf['jailkit']['installed'] = true;
if(is_installed('pdns_server') || is_installed('pdns_control')) $conf['powerdns']['installed'] = true;
if(is_installed('named') || is_installed('bind') || is_installed('bind9')) $conf['bind']['installed'] = true;
if(is_installed('squid')) $conf['squid']['installed'] = true;
if(is_installed('nginx')) $conf['nginx']['installed'] = true;
if(is_installed('iptables') && is_installed('ufw')) $conf['ufw']['installed'] = true;
if(is_installed('fail2ban-server')) $conf['fail2ban']['installed'] = true;
if(is_installed('vzctl')) $conf['openvz']['installed'] = true;
Florian Schaal
committed
if(is_installed('iptables') && is_installed('bastille-netfilter')) $conf['bastille']['installed'] = true;
if(is_installed('metronome') && is_installed('metronomectl')) $conf['xmpp']['installed'] = true;
if(is_installed('spamassassin')) $conf['spamassassin']['installed'] = true;
Florian Schaal
committed
if(is_installed('vlogger')) $conf['vlogger']['installed'] = true;
if(is_installed('cron')) $conf['cron']['installed'] = true;
if ($conf['services']['web'] && (($conf['apache']['installed'] && is_file($conf['apache']["vhost_conf_enabled_dir"]."/000-ispconfig.vhost")) || ($conf['nginx']['installed'] && is_file($conf['nginx']["vhost_conf_enabled_dir"]."/000-ispconfig.vhost")))) $this->ispconfig_interface_installed = true;
Florian Schaal
committed
public function force_configure_app($service, $enable_force=true) {
Florian Schaal
committed
$force = false;
swriteln("[WARN] autodetect for $service failed");
Florian Schaal
committed
if($enable_force) {
if(strtolower($this->simple_query("Force configure $service", array('y', 'n'), 'n') ) == 'y') {
$force = true;
} else swriteln("Skipping $service\n");
}
Florian Schaal
committed
return $force;
}
public function reconfigure_app($service, $reconfigure_services_answer) {
$reconfigure = false;
if ($reconfigure_services_answer != 'selected') {
$reconfigure = true;
Loading full blame...