]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/services.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
32 #workaround to suppress a warning when a variable is used only once
33 my @dummy = ( ${Header
::colourred
} );
37 my %mainsettings = ();
38 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
39 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
42 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
45 # Maps a nice printable name to the changing part of the pid file, which
46 # is also the name of the program
49 $Lang::tr
{'dhcp server'} => 'dhcpd',
50 $Lang::tr
{'web server'} => 'httpd',
51 $Lang::tr
{'cron server'} => 'fcron',
52 $Lang::tr
{'dns proxy server'} => 'dnsmasq',
53 $Lang::tr
{'logging server'} => 'syslogd',
54 $Lang::tr
{'kernel logging server'} => 'klogd',
55 $Lang::tr
{'ntp server'} => 'ntpd',
56 $Lang::tr
{'secure shell server'} => 'sshd',
57 $Lang::tr
{'vpn'} => 'pluto',
58 $Lang::tr
{'web proxy'} => 'squid',
59 'OpenVPN' => 'openvpn'
62 my $lines=0; # Used to count the outputlines to make different bgcolor
65 if (open(FILE
, "${General::swroot}/red/iface"))
71 $servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}";
72 $servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}";
73 if ($netsettings{'ORANGE_DEV'} ne '') {
74 $servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}";
76 if ($netsettings{'BLUE_DEV'} ne '') {
77 $servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}";
80 &Header
::showhttpheaders
();
81 &Header
::getcgihash
(\
%cgiparams);
82 &Header
::openpage
($Lang::tr
{'status information'}, 1, '');
83 &Header
::openbigbox
('100%', 'left');
85 &Header
::openbox
('100%', 'left', $Lang::tr
{'services'});
89 <table width='80%' cellspacing='1' border='0'>
90 <tr bgcolor='$color{'color20'}'><td align='left'><b>$Lang::tr{'services'}</b></td><td align='center' ><b>$Lang::tr{'status'}</b></td><td align='center'><b>PID</b></td><td align='center'><b>$Lang::tr{'memory'}</b></td></tr>
95 foreach $key (sort keys %servicenames)
99 { print "<tr bgcolor='$color{'color22'}'>\n<td align='left'>$key</td>\n";}
101 { print "<tr bgcolor='$color{'color20'}'>\n<td align='left'>$key</td>\n";}
103 my $shortname = $servicenames{$key};
104 my $status = &isrunning
($shortname);
111 print "</table></div>\n";
115 &Header
::openbox
('100%', 'left', "Addon - $Lang::tr{services}");
117 my $paramstr=$ENV{QUERY_STRING
};
118 my @param=split(/!/, $paramstr);
119 if ($param[1] ne '') {
120 my $temp = `/usr/local/bin/addonctrl @param[0] @param[1]`;
125 <table width='80%' cellspacing='1' border='0'>
126 <tr bgcolor='$color{'color20'}'>
127 <td align='center'><b>Addon</b></td>
128 <td align='center'><b>Boot</b></td>
129 <td align='center' colspan=2><b>$Lang::tr{'action'}</b></td>
130 <td align='center'><b>$Lang::tr{'status'}</b></td>
131 <td align='center'><b>PID</b></td>
132 <td align='center'><b>$Lang::tr{'memory'}</b></td>
137 my $lines=0; # Used to count the outputlines to make different bgcolor
139 # Generate list of installed addon pak's
140 my @pak = `find /opt/pakfire/db/installed/meta-* | cut -d"-" -f2`;
145 # Check which of the paks are services
146 my @svc = `find /etc/init.d/$_ | cut -d"/" -f4`;
149 # blacklist some packages
151 # alsa has trouble with the volume saving and was not really stopped
159 print "<tr bgcolor='$color{'color22'}'>";
163 print "<tr bgcolor='$color{'color20'}'>";
165 print "<td align='left'>$_</td> ";
166 my $status = isautorun
($_);
168 print "<td align='center'><A HREF=services.cgi?$_!start><img alt='$Lang::tr{'start'}' title='$Lang::tr{'start'}' src='/images/go-up.png' border='0' /></A></td>";
169 print "<td align='center'><A HREF=services.cgi?$_!stop><img alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/go-down.png' border='0' /></A></td> ";
170 my $status = &isrunningaddon
($_);
171 $status =~ s/\\e\[[0-1]\;[0-9]+m//g;
180 print "</table></div>\n";
183 &Header
::closebigbox
();
184 &Header
::closepage
();
189 my $status = "<td align='center'></td>";
190 my $init = `find /etc/rc.d/rc3.d/S??${cmd}`;
193 $status = "<td align='center'><A HREF=services.cgi?$_!disable><img alt='$Lang::tr{'deactivate'}' title='$Lang::tr{'deactivate'}' src='/images/on.gif' border='0' width='16' height='16' /></A></td>";
195 $init = `find /etc/rc.d/rc3.d/off/S??${cmd}`;
198 $status = "<td align='center'><A HREF=services.cgi?$_!enable><img alt='$Lang::tr{'activate'}' title='$Lang::tr{'activate'}' src='/images/off.gif' border='0' width='16' height='16' /></A></td>";
207 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td><td colspan='2'></td>";
216 if (open(FILE
, "/var/run/${cmd}.pid")){
217 $pid = <FILE
>; chomp $pid;
219 if (open(FILE
, "/proc/${pid}/status")){
221 if (/^Name:\W+(.*)/) {$testcmd = $1; }
225 if (open(FILE
, "/proc/${pid}/statm")){
227 @memory = split(/ /,$temp);
230 if ($testcmd =~ /$exename/){$status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td><td align='center'>$pid</td><td align='center'>$memory[0] KB</td>";}
238 my $status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td><td colspan='2'></td>";
244 my $testcmd = `/usr/local/bin/addonctrl $_ status`;
246 if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){
247 $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
248 $testcmd =~ s/[a-z_]//gi; $testcmd =~ s/\[[0-1]\;[0-9]+//gi; $testcmd =~ s/[\(\)\.]//gi; $testcmd =~ s/ //gi; $testcmd =~ s/\e//gi;
250 my @pid = split(/\s/,$testcmd);
251 $status .="<td align='center'>$pid[0]</td>";
257 if (open(FILE
, "/proc/$_/statm")){
259 @memory = split(/ /,$temp);
263 $status .="<td align='center'>$memory KB</td>";
265 else {$status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td><td colspan='2'></td>";}