Commit 580d8151 authored by wyrie's avatar wyrie
Browse files

Implemented gentoo support for Server

parent cb8c86a5
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
config_eth0=(
"<tmpl_var name="ip_address"> netmask <tmpl_var name="netmask"> broadcast <tmpl_var name="broadcast">"
<tmpl_if name="additionl_ip_records">
<tmpl_loop name="interfaces">
"<tmpl_var name="ip_address"> netmask <tmpl_var name="netmask"> broadcast <tmpl_var name="broadcast">"
</tmpl_loop>
</tmpl_if>
);
routes_eth0=( "default via <tmpl_var name="gateway">" )
......@@ -520,6 +520,34 @@ class monitor_core_module {
*/
$data['output'] = shell_exec('apt-get -s -q dist-upgrade');
}
elseif (file_exists("/etc/gentoo-release")) {
/*
* first update the portage tree
*/
shell_exec('emerge --sync --quiet');
/*
* Then test the upgrade.
* if there is any output, then there is a needed update
*/
$emergeData = shell_exec('emerge -puDNt --color n --nospinner --quiet world');
if ($emergeData == '')
{
/* There is nothing to update! */
$state = 'ok';
}
else
{
/* There is something to update! */
$state = 'warning';
}
/*
* Fetch the output
*/
$data['output'] = shell_exec('emerge -pvuDNt --color n --nospinner world');
}
else {
/*
* It is not debian/Ubuntu, so there is no data and no state
......@@ -1187,52 +1215,62 @@ class monitor_core_module {
if(@is_file('/etc/debian_version')) $dist = 'debian';
if(@is_file('/etc/redhat-release')) $dist = 'redhat';
if(@is_file('/etc/SuSE-release')) $dist = 'suse';
if(@is_file('/etc/gentoo-release')) $dist = 'gentoo';
switch($log) {
case 'log_mail':
if($dist == 'debian') $logfile = '/var/log/mail.log';
if($dist == 'redhat') $logfile = '/var/log/maillog';
if($dist == 'suse') $logfile = '/var/log/mail.info';
if($dist == 'gentoo') $logfile = '/var/log/maillog';
break;
case 'log_mail_warn':
if($dist == 'debian') $logfile = '/var/log/mail.warn';
if($dist == 'redhat') $logfile = '/var/log/maillog';
if($dist == 'suse') $logfile = '/var/log/mail.warn';
if($dist == 'gentoo') $logfile = '/var/log/maillog';
break;
case 'log_mail_err':
if($dist == 'debian') $logfile = '/var/log/mail.err';
if($dist == 'redhat') $logfile = '/var/log/maillog';
if($dist == 'suse') $logfile = '/var/log/mail.err';
if($dist == 'gentoo') $logfile = '/var/log/maillog';
break;
case 'log_messages':
if($dist == 'debian') $logfile = '/var/log/messages';
if($dist == 'redhat') $logfile = '/var/log/messages';
if($dist == 'suse') $logfile = '/var/log/messages';
if($dist == 'gentoo') $logfile = '/var/log/messages';
break;
case 'log_ispc_cron':
if($dist == 'debian') $logfile = '/var/log/ispconfig/cron.log';
if($dist == 'redhat') $logfile = '/var/log/ispconfig/cron.log';
if($dist == 'suse') $logfile = '/var/log/ispconfig/cron.log';
if($dist == 'gentoo') $logfile = '/var/log/cron';
break;
case 'log_freshclam':
if($dist == 'debian') $logfile = '/var/log/clamav/freshclam.log';
if($dist == 'redhat') $logfile = (is_file('/var/log/clamav/freshclam.log') ? '/var/log/clamav/freshclam.log' : '/var/log/freshclam.log');
if($dist == 'suse') $logfile = '';
if($dist == 'gentoo') $logfile = '/var/log/clamav/freshclam.log';
break;
case 'log_clamav':
if($dist == 'debian') $logfile = '/var/log/clamav/clamav.log';
if($dist == 'redhat') $logfile = (is_file('/var/log/clamav/clamd.log') ? '/var/log/clamav/clamd.log' : '/var/log/maillog');
if($dist == 'suse') $logfile = '';
if($dist == 'gentoo') $logfile = '/var/log/clamav/clamd.log';
break;
case 'log_fail2ban':
if($dist == 'debian') $logfile = '/var/log/fail2ban.log';
if($dist == 'redhat') $logfile = '/var/log/fail2ban.log';
if($dist == 'suse') $logfile = '/var/log/fail2ban.log';
if($dist == 'gentoo') $logfile = '/var/log/fail2ban.log';
break;
case 'log_ispconfig':
if($dist == 'debian') $logfile = '/var/log/ispconfig/ispconfig.log';
if($dist == 'redhat') $logfile = '/var/log/ispconfig/ispconfig.log';
if($dist == 'suse') $logfile = '/var/log/ispconfig/ispconfig.log';
if($dist == 'gentoo') $logfile = '/var/log/ispconfig/ispconfig.log';
break;
default:
$logfile = '';
......
......@@ -80,86 +80,162 @@ class network_settings_plugin {
$server_config = $app->getconf->get_server_config($conf["server_id"], 'server');
// Configure the debian network card settings
if(is_file('/etc/debian_version') && $server_config['auto_network_configuration'] == 'y') {
copy('/etc/network/interfaces','/etc/network/interfaces~');
if($server_config['auto_network_configuration'] == 'y') {
$app->load('tpl');
if (is_file('/etc/debian_version'))
{
copy('/etc/network/interfaces','/etc/network/interfaces~');
$network_tpl = new tpl();
$network_tpl->newTemplate("debian_network_interfaces.master");
$app->load('tpl');
$network_tpl->setVar('ip_address',$server_config["ip_address"]);
$network_tpl->setVar('netmask',$server_config["netmask"]);
$network_tpl->setVar('gateway',$server_config["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
$network_tpl->setVar('network',$this->network($server_config["ip_address"],$server_config["netmask"]));
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
$ip_records = array();
$additionl_ip_records = 0;
$n = 0;
if(is_array($records)) {
foreach($records as $rec) {
/*
* don't insert the main-ip again!
*/
if ($rec['ip_address'] != $server_config["ip_address"])
{
$ip_records[$n] = array(
'id' => $n,
'ip_address' => $rec['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"]),
'network' => $this->network($rec['ip_address'],$server_config["netmask"])
);
$additionl_ip_records = 1;
$n++;
$network_tpl = new tpl();
$network_tpl->newTemplate("debian_network_interfaces.master");
$network_tpl->setVar('ip_address',$server_config["ip_address"]);
$network_tpl->setVar('netmask',$server_config["netmask"]);
$network_tpl->setVar('gateway',$server_config["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
$network_tpl->setVar('network',$this->network($server_config["ip_address"],$server_config["netmask"]));
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
$ip_records = array();
$additionl_ip_records = 0;
$n = 0;
if(is_array($records)) {
foreach($records as $rec) {
/*
* don't insert the main-ip again!
*/
if ($rec['ip_address'] != $server_config["ip_address"])
{
$ip_records[$n] = array(
'id' => $n,
'ip_address' => $rec['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"]),
'network' => $this->network($rec['ip_address'],$server_config["netmask"])
);
$additionl_ip_records = 1;
$n++;
}
}
}
}
/*
* If we have more than 1 IP we have to add the main-ip at the end
* of the network-ip-list. If we don't do so, there may be problems
* in multi-server-settings (with the acces from other server to the
* main-server) because the LAST IP in the list is the IP mysql uses
* to determine the host, the user is logging in from.
*/
if ($additionl_ip_records != 0)
/*
* If we have more than 1 IP we have to add the main-ip at the end
* of the network-ip-list. If we don't do so, there may be problems
* in multi-server-settings (with the acces from other server to the
* main-server) because the LAST IP in the list is the IP mysql uses
* to determine the host, the user is logging in from.
*/
if ($additionl_ip_records != 0)
{
$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
$swap["netmask"] = $ip_records[$n-1]["netmask"];
$swap["gateway"] = $ip_records[$n-1]["gateway"];
$ip_records[$n-1] = array(
'id' => $n-1,
'ip_address' => $server_config['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"]),
'network' => $this->network($server_config['ip_address'],$server_config["netmask"])
);
$network_tpl->setVar('ip_address',$swap["ip_address"]);
$network_tpl->setVar('netmask',$swap["netmask"]);
$network_tpl->setVar('gateway',$swap["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
$network_tpl->setVar('network',$this->network($swap["ip_address"],$swap["netmask"]));
}
$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
$network_tpl->setLoop('interfaces',$ip_records);
file_put_contents('/etc/network/interfaces',$network_tpl->grab());
unset($network_tpl);
$app->log("Changed Network settings",LOGLEVEL_DEBUG);
exec('/etc/init.d/networking force-reload');
}
elseif (is_file('/etc/gentoo-release'))
{
$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
$swap["netmask"] = $ip_records[$n-1]["netmask"];
$swap["gateway"] = $ip_records[$n-1]["gateway"];
copy('/etc/conf.d/net','/etc/conf.d/net~');
$app->load('tpl');
$network_tpl = new tpl();
$network_tpl->newTemplate("gentoo_network_interfaces.master");
$ip_records[$n-1] = array(
'id' => $n-1,
'ip_address' => $server_config['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"]),
'network' => $this->network($server_config['ip_address'],$server_config["netmask"])
);
$network_tpl->setVar('ip_address',$swap["ip_address"]);
$network_tpl->setVar('netmask',$swap["netmask"]);
$network_tpl->setVar('gateway',$swap["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
$network_tpl->setVar('network',$this->network($swap["ip_address"],$swap["netmask"]));
$network_tpl->setVar('ip_address',$server_config["ip_address"]);
$network_tpl->setVar('netmask',$server_config["netmask"]);
$network_tpl->setVar('gateway',$server_config["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
$ip_records = array();
$additionl_ip_records = 0;
$n = 0;
if(is_array($records)) {
foreach($records as $rec) {
/*
* don't insert the main-ip again!
*/
if ($rec['ip_address'] != $server_config["ip_address"])
{
$ip_records[$n] = array(
'id' => $n,
'ip_address' => $rec['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"])
);
$additionl_ip_records = 1;
$n++;
}
}
}
/*
* If we have more than 1 IP we have to add the main-ip at the end
* of the network-ip-list. If we don't do so, there may be problems
* in multi-server-settings (with the acces from other server to the
* main-server) because the LAST IP in the list is the IP mysql uses
* to determine the host, the user is logging in from.
*/
if ($additionl_ip_records != 0)
{
$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
$swap["netmask"] = $ip_records[$n-1]["netmask"];
$swap["gateway"] = $ip_records[$n-1]["gateway"];
$ip_records[$n-1] = array(
'id' => $n-1,
'ip_address' => $server_config['ip_address'],
'netmask' => $server_config["netmask"],
'gateway' => $server_config["gateway"],
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"])
);
$network_tpl->setVar('ip_address',$swap["ip_address"]);
$network_tpl->setVar('netmask',$swap["netmask"]);
$network_tpl->setVar('gateway',$swap["gateway"]);
$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
}
$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
$network_tpl->setLoop('interfaces',$ip_records);
file_put_contents('/etc/conf.d/net',$network_tpl->grab());
unset($network_tpl);
$app->log("Changed Network settings",LOGLEVEL_DEBUG);
exec('/etc/init.d/net.eth0 restart');
}
else {
$app->log("Network configuration not available for this linux distribution.",LOGLEVEL_DEBUG);
}
$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
$network_tpl->setLoop('interfaces',$ip_records);
file_put_contents('/etc/network/interfaces',$network_tpl->grab());
unset($network_tpl);
$app->log("Changed Network settings",LOGLEVEL_DEBUG);
exec('/etc/init.d/networking force-reload');
} else {
if(is_file('/etc/debian_version')) {
$app->log("Network configuration disabled in server settings.",LOGLEVEL_WARN);
} else {
$app->log("Network configuration not available for this linux distribution.",LOGLEVEL_DEBUG);
}
$app->log("Network configuration disabled in server settings.",LOGLEVEL_WARN);
}
}
......
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