Skip to content

Commit 580d815

Browse files
author
wyrie
committed
Implemented gentoo support for Server
1 parent cb8c86a commit 580d815

File tree

3 files changed

+197
-70
lines changed

3 files changed

+197
-70
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file describes the network interfaces available on your system
2+
# and how to activate them. For more information, see interfaces(5).
3+
4+
config_eth0=(
5+
"<tmpl_var name="ip_address"> netmask <tmpl_var name="netmask"> broadcast <tmpl_var name="broadcast">"
6+
<tmpl_if name="additionl_ip_records">
7+
<tmpl_loop name="interfaces">
8+
"<tmpl_var name="ip_address"> netmask <tmpl_var name="netmask"> broadcast <tmpl_var name="broadcast">"
9+
</tmpl_loop>
10+
</tmpl_if>
11+
);
12+
13+
routes_eth0=( "default via <tmpl_var name="gateway">" )

server/mods-available/monitor_core_module.inc.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,34 @@ function monitorSystemUpdate(){
520520
*/
521521
$data['output'] = shell_exec('apt-get -s -q dist-upgrade');
522522
}
523+
elseif (file_exists("/etc/gentoo-release")) {
524+
525+
/*
526+
* first update the portage tree
527+
*/
528+
shell_exec('emerge --sync --quiet');
529+
530+
/*
531+
* Then test the upgrade.
532+
* if there is any output, then there is a needed update
533+
*/
534+
$emergeData = shell_exec('emerge -puDNt --color n --nospinner --quiet world');
535+
if ($emergeData == '')
536+
{
537+
/* There is nothing to update! */
538+
$state = 'ok';
539+
}
540+
else
541+
{
542+
/* There is something to update! */
543+
$state = 'warning';
544+
}
545+
546+
/*
547+
* Fetch the output
548+
*/
549+
$data['output'] = shell_exec('emerge -pvuDNt --color n --nospinner world');
550+
}
523551
else {
524552
/*
525553
* It is not debian/Ubuntu, so there is no data and no state
@@ -1187,52 +1215,62 @@ function _getLogData($log){
11871215
if(@is_file('/etc/debian_version')) $dist = 'debian';
11881216
if(@is_file('/etc/redhat-release')) $dist = 'redhat';
11891217
if(@is_file('/etc/SuSE-release')) $dist = 'suse';
1218+
if(@is_file('/etc/gentoo-release')) $dist = 'gentoo';
11901219

11911220
switch($log) {
11921221
case 'log_mail':
11931222
if($dist == 'debian') $logfile = '/var/log/mail.log';
11941223
if($dist == 'redhat') $logfile = '/var/log/maillog';
11951224
if($dist == 'suse') $logfile = '/var/log/mail.info';
1225+
if($dist == 'gentoo') $logfile = '/var/log/maillog';
11961226
break;
11971227
case 'log_mail_warn':
11981228
if($dist == 'debian') $logfile = '/var/log/mail.warn';
11991229
if($dist == 'redhat') $logfile = '/var/log/maillog';
12001230
if($dist == 'suse') $logfile = '/var/log/mail.warn';
1231+
if($dist == 'gentoo') $logfile = '/var/log/maillog';
12011232
break;
12021233
case 'log_mail_err':
12031234
if($dist == 'debian') $logfile = '/var/log/mail.err';
12041235
if($dist == 'redhat') $logfile = '/var/log/maillog';
12051236
if($dist == 'suse') $logfile = '/var/log/mail.err';
1237+
if($dist == 'gentoo') $logfile = '/var/log/maillog';
12061238
break;
12071239
case 'log_messages':
12081240
if($dist == 'debian') $logfile = '/var/log/messages';
12091241
if($dist == 'redhat') $logfile = '/var/log/messages';
12101242
if($dist == 'suse') $logfile = '/var/log/messages';
1243+
if($dist == 'gentoo') $logfile = '/var/log/messages';
12111244
break;
12121245
case 'log_ispc_cron':
12131246
if($dist == 'debian') $logfile = '/var/log/ispconfig/cron.log';
12141247
if($dist == 'redhat') $logfile = '/var/log/ispconfig/cron.log';
12151248
if($dist == 'suse') $logfile = '/var/log/ispconfig/cron.log';
1249+
if($dist == 'gentoo') $logfile = '/var/log/cron';
12161250
break;
12171251
case 'log_freshclam':
12181252
if($dist == 'debian') $logfile = '/var/log/clamav/freshclam.log';
12191253
if($dist == 'redhat') $logfile = (is_file('/var/log/clamav/freshclam.log') ? '/var/log/clamav/freshclam.log' : '/var/log/freshclam.log');
12201254
if($dist == 'suse') $logfile = '';
1255+
if($dist == 'gentoo') $logfile = '/var/log/clamav/freshclam.log';
12211256
break;
12221257
case 'log_clamav':
12231258
if($dist == 'debian') $logfile = '/var/log/clamav/clamav.log';
12241259
if($dist == 'redhat') $logfile = (is_file('/var/log/clamav/clamd.log') ? '/var/log/clamav/clamd.log' : '/var/log/maillog');
12251260
if($dist == 'suse') $logfile = '';
1261+
if($dist == 'gentoo') $logfile = '/var/log/clamav/clamd.log';
12261262
break;
12271263
case 'log_fail2ban':
12281264
if($dist == 'debian') $logfile = '/var/log/fail2ban.log';
12291265
if($dist == 'redhat') $logfile = '/var/log/fail2ban.log';
12301266
if($dist == 'suse') $logfile = '/var/log/fail2ban.log';
1267+
if($dist == 'gentoo') $logfile = '/var/log/fail2ban.log';
12311268
break;
12321269
case 'log_ispconfig':
12331270
if($dist == 'debian') $logfile = '/var/log/ispconfig/ispconfig.log';
12341271
if($dist == 'redhat') $logfile = '/var/log/ispconfig/ispconfig.log';
12351272
if($dist == 'suse') $logfile = '/var/log/ispconfig/ispconfig.log';
1273+
if($dist == 'gentoo') $logfile = '/var/log/ispconfig/ispconfig.log';
12361274
break;
12371275
default:
12381276
$logfile = '';

server/plugins-available/network_settings_plugin.inc.php

Lines changed: 146 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -80,86 +80,162 @@ function update($event_name,$data) {
8080
$server_config = $app->getconf->get_server_config($conf["server_id"], 'server');
8181

8282
// Configure the debian network card settings
83-
if(is_file('/etc/debian_version') && $server_config['auto_network_configuration'] == 'y') {
84-
copy('/etc/network/interfaces','/etc/network/interfaces~');
83+
if($server_config['auto_network_configuration'] == 'y') {
8584

86-
$app->load('tpl');
85+
if (is_file('/etc/debian_version'))
86+
{
87+
copy('/etc/network/interfaces','/etc/network/interfaces~');
8788

88-
$network_tpl = new tpl();
89-
$network_tpl->newTemplate("debian_network_interfaces.master");
89+
$app->load('tpl');
9090

91-
$network_tpl->setVar('ip_address',$server_config["ip_address"]);
92-
$network_tpl->setVar('netmask',$server_config["netmask"]);
93-
$network_tpl->setVar('gateway',$server_config["gateway"]);
94-
$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
95-
$network_tpl->setVar('network',$this->network($server_config["ip_address"],$server_config["netmask"]));
96-
97-
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
98-
$ip_records = array();
99-
$additionl_ip_records = 0;
100-
$n = 0;
101-
if(is_array($records)) {
102-
foreach($records as $rec) {
103-
/*
104-
* don't insert the main-ip again!
105-
*/
106-
if ($rec['ip_address'] != $server_config["ip_address"])
107-
{
108-
$ip_records[$n] = array(
109-
'id' => $n,
110-
'ip_address' => $rec['ip_address'],
111-
'netmask' => $server_config["netmask"],
112-
'gateway' => $server_config["gateway"],
113-
'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"]),
114-
'network' => $this->network($rec['ip_address'],$server_config["netmask"])
115-
);
116-
$additionl_ip_records = 1;
117-
$n++;
91+
$network_tpl = new tpl();
92+
$network_tpl->newTemplate("debian_network_interfaces.master");
93+
94+
$network_tpl->setVar('ip_address',$server_config["ip_address"]);
95+
$network_tpl->setVar('netmask',$server_config["netmask"]);
96+
$network_tpl->setVar('gateway',$server_config["gateway"]);
97+
$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
98+
$network_tpl->setVar('network',$this->network($server_config["ip_address"],$server_config["netmask"]));
99+
100+
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
101+
$ip_records = array();
102+
$additionl_ip_records = 0;
103+
$n = 0;
104+
if(is_array($records)) {
105+
foreach($records as $rec) {
106+
/*
107+
* don't insert the main-ip again!
108+
*/
109+
if ($rec['ip_address'] != $server_config["ip_address"])
110+
{
111+
$ip_records[$n] = array(
112+
'id' => $n,
113+
'ip_address' => $rec['ip_address'],
114+
'netmask' => $server_config["netmask"],
115+
'gateway' => $server_config["gateway"],
116+
'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"]),
117+
'network' => $this->network($rec['ip_address'],$server_config["netmask"])
118+
);
119+
$additionl_ip_records = 1;
120+
$n++;
121+
}
118122
}
119123
}
120-
}
121-
122-
/*
123-
* If we have more than 1 IP we have to add the main-ip at the end
124-
* of the network-ip-list. If we don't do so, there may be problems
125-
* in multi-server-settings (with the acces from other server to the
126-
* main-server) because the LAST IP in the list is the IP mysql uses
127-
* to determine the host, the user is logging in from.
128-
*/
129-
if ($additionl_ip_records != 0)
124+
125+
/*
126+
* If we have more than 1 IP we have to add the main-ip at the end
127+
* of the network-ip-list. If we don't do so, there may be problems
128+
* in multi-server-settings (with the acces from other server to the
129+
* main-server) because the LAST IP in the list is the IP mysql uses
130+
* to determine the host, the user is logging in from.
131+
*/
132+
if ($additionl_ip_records != 0)
133+
{
134+
$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
135+
$swap["netmask"] = $ip_records[$n-1]["netmask"];
136+
$swap["gateway"] = $ip_records[$n-1]["gateway"];
137+
138+
$ip_records[$n-1] = array(
139+
'id' => $n-1,
140+
'ip_address' => $server_config['ip_address'],
141+
'netmask' => $server_config["netmask"],
142+
'gateway' => $server_config["gateway"],
143+
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"]),
144+
'network' => $this->network($server_config['ip_address'],$server_config["netmask"])
145+
);
146+
$network_tpl->setVar('ip_address',$swap["ip_address"]);
147+
$network_tpl->setVar('netmask',$swap["netmask"]);
148+
$network_tpl->setVar('gateway',$swap["gateway"]);
149+
$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
150+
$network_tpl->setVar('network',$this->network($swap["ip_address"],$swap["netmask"]));
151+
}
152+
153+
$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
154+
$network_tpl->setLoop('interfaces',$ip_records);
155+
file_put_contents('/etc/network/interfaces',$network_tpl->grab());
156+
unset($network_tpl);
157+
158+
$app->log("Changed Network settings",LOGLEVEL_DEBUG);
159+
exec('/etc/init.d/networking force-reload');
160+
}
161+
elseif (is_file('/etc/gentoo-release'))
130162
{
131-
$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
132-
$swap["netmask"] = $ip_records[$n-1]["netmask"];
133-
$swap["gateway"] = $ip_records[$n-1]["gateway"];
163+
copy('/etc/conf.d/net','/etc/conf.d/net~');
164+
165+
$app->load('tpl');
166+
167+
$network_tpl = new tpl();
168+
$network_tpl->newTemplate("gentoo_network_interfaces.master");
134169

135-
$ip_records[$n-1] = array(
136-
'id' => $n-1,
137-
'ip_address' => $server_config['ip_address'],
138-
'netmask' => $server_config["netmask"],
139-
'gateway' => $server_config["gateway"],
140-
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"]),
141-
'network' => $this->network($server_config['ip_address'],$server_config["netmask"])
142-
);
143-
$network_tpl->setVar('ip_address',$swap["ip_address"]);
144-
$network_tpl->setVar('netmask',$swap["netmask"]);
145-
$network_tpl->setVar('gateway',$swap["gateway"]);
146-
$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
147-
$network_tpl->setVar('network',$this->network($swap["ip_address"],$swap["netmask"]));
170+
$network_tpl->setVar('ip_address',$server_config["ip_address"]);
171+
$network_tpl->setVar('netmask',$server_config["netmask"]);
172+
$network_tpl->setVar('gateway',$server_config["gateway"]);
173+
$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
174+
175+
$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
176+
$ip_records = array();
177+
$additionl_ip_records = 0;
178+
$n = 0;
179+
if(is_array($records)) {
180+
foreach($records as $rec) {
181+
/*
182+
* don't insert the main-ip again!
183+
*/
184+
if ($rec['ip_address'] != $server_config["ip_address"])
185+
{
186+
$ip_records[$n] = array(
187+
'id' => $n,
188+
'ip_address' => $rec['ip_address'],
189+
'netmask' => $server_config["netmask"],
190+
'gateway' => $server_config["gateway"],
191+
'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"])
192+
);
193+
$additionl_ip_records = 1;
194+
$n++;
195+
}
196+
}
197+
}
198+
199+
/*
200+
* If we have more than 1 IP we have to add the main-ip at the end
201+
* of the network-ip-list. If we don't do so, there may be problems
202+
* in multi-server-settings (with the acces from other server to the
203+
* main-server) because the LAST IP in the list is the IP mysql uses
204+
* to determine the host, the user is logging in from.
205+
*/
206+
if ($additionl_ip_records != 0)
207+
{
208+
$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
209+
$swap["netmask"] = $ip_records[$n-1]["netmask"];
210+
$swap["gateway"] = $ip_records[$n-1]["gateway"];
211+
212+
$ip_records[$n-1] = array(
213+
'id' => $n-1,
214+
'ip_address' => $server_config['ip_address'],
215+
'netmask' => $server_config["netmask"],
216+
'gateway' => $server_config["gateway"],
217+
'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"])
218+
);
219+
$network_tpl->setVar('ip_address',$swap["ip_address"]);
220+
$network_tpl->setVar('netmask',$swap["netmask"]);
221+
$network_tpl->setVar('gateway',$swap["gateway"]);
222+
$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
223+
}
224+
225+
$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
226+
$network_tpl->setLoop('interfaces',$ip_records);
227+
file_put_contents('/etc/conf.d/net',$network_tpl->grab());
228+
unset($network_tpl);
229+
230+
$app->log("Changed Network settings",LOGLEVEL_DEBUG);
231+
exec('/etc/init.d/net.eth0 restart');
232+
}
233+
else {
234+
$app->log("Network configuration not available for this linux distribution.",LOGLEVEL_DEBUG);
148235
}
149236

150-
$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
151-
$network_tpl->setLoop('interfaces',$ip_records);
152-
file_put_contents('/etc/network/interfaces',$network_tpl->grab());
153-
unset($network_tpl);
154-
155-
$app->log("Changed Network settings",LOGLEVEL_DEBUG);
156-
exec('/etc/init.d/networking force-reload');
157237
} else {
158-
if(is_file('/etc/debian_version')) {
159-
$app->log("Network configuration disabled in server settings.",LOGLEVEL_WARN);
160-
} else {
161-
$app->log("Network configuration not available for this linux distribution.",LOGLEVEL_DEBUG);
162-
}
238+
$app->log("Network configuration disabled in server settings.",LOGLEVEL_WARN);
163239
}
164240

165241
}

0 commit comments

Comments
 (0)