]>
Commit | Line | Data |
---|---|---|
ac1cfefa | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
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. # | |
11 | # # | |
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. # | |
16 | # # | |
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/>. # | |
19 | # # | |
20 | ############################################################################### | |
ac1cfefa MT |
21 | |
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
25 | #use warnings; |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
ac1cfefa | 27 | |
e383179b | 28 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
29 | require "${General::swroot}/lang.pl"; |
30 | require "${General::swroot}/header.pl"; | |
2b38ab5c | 31 | require "/opt/pakfire/lib/functions.pl"; |
ac1cfefa MT |
32 | |
33 | my %cgiparams=(); | |
34 | my %pppsettings=(); | |
35 | my %modemsettings=(); | |
36 | my %netsettings=(); | |
37 | my %ddnssettings=(); | |
38 | my $warnmessage = ''; | |
c85ec3b4 | 39 | my $refresh = ""; |
e383179b | 40 | my $ipaddr=''; |
ac1cfefa MT |
41 | |
42 | &Header::showhttpheaders(); | |
43 | ||
44 | $cgiparams{'ACTION'} = ''; | |
45 | &Header::getcgihash(\%cgiparams); | |
46 | $pppsettings{'VALID'} = ''; | |
47 | $pppsettings{'PROFILENAME'} = 'None'; | |
48 | &General::readhash("${General::swroot}/ppp/settings", \%pppsettings); | |
49 | &General::readhash("${General::swroot}/modem/settings", \%modemsettings); | |
50 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
51 | &General::readhash("${General::swroot}/ddns/settings", \%ddnssettings); | |
52 | ||
f2fdd0c1 CS |
53 | my %color = (); |
54 | my %mainsettings = (); | |
55 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
56 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
57 | ||
ac1cfefa | 58 | my $connstate = &Header::connectionstatus(); |
56b7a3e2 CS |
59 | |
60 | if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'} || $cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { | |
61 | $refresh = "<meta http-equiv='refresh' content='300;'>"; | |
8a5898e7 | 62 | } elsif ($connstate =~ /$Lang::tr{'connecting'}/ || /$Lang::tr{'connection closed'}/ ){ |
ac1cfefa | 63 | $refresh = "<meta http-equiv='refresh' content='5;'>"; |
56b7a3e2 CS |
64 | } elsif ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") { |
65 | $refresh = "<meta http-equiv='refresh' content='30;'>"; | |
ac1cfefa MT |
66 | } |
67 | ||
957363eb CS |
68 | if ($cgiparams{'ACTION'} eq $Lang::tr{'dial profile'}) |
69 | { | |
70 | my $profile = $cgiparams{'PROFILE'}; | |
71 | my %tempcgiparams = (); | |
72 | $tempcgiparams{'PROFILE'} = ''; | |
73 | &General::readhash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
74 | \%tempcgiparams); | |
75 | ||
76 | # make a link from the selected profile to the "default" one. | |
77 | unlink("${General::swroot}/ppp/settings"); | |
78 | link("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
79 | "${General::swroot}/ppp/settings"); | |
80 | system ("/usr/bin/touch", "${General::swroot}/ppp/updatesettings"); | |
81 | ||
82 | # read in the new params "early" so we can write secrets. | |
83 | %cgiparams = (); | |
84 | &General::readhash("${General::swroot}/ppp/settings", \%cgiparams); | |
85 | $cgiparams{'PROFILE'} = $profile; | |
86 | $cgiparams{'BACKUPPROFILE'} = $profile; | |
87 | &General::writehash("${General::swroot}/ppp/settings-$cgiparams{'PROFILE'}", | |
88 | \%cgiparams); | |
89 | ||
90 | # write secrets file. | |
91 | open(FILE, ">/${General::swroot}/ppp/secrets") or die "Unable to write secrets file."; | |
92 | flock(FILE, 2); | |
93 | my $username = $cgiparams{'USERNAME'}; | |
94 | my $password = $cgiparams{'PASSWORD'}; | |
95 | print FILE "'$username' * '$password'\n"; | |
96 | chmod 0600, "${General::swroot}/ppp/secrets"; | |
97 | close FILE; | |
98 | ||
99 | &General::log("$Lang::tr{'profile made current'} $tempcgiparams{'PROFILENAME'}"); | |
100 | $cgiparams{'ACTION'} = "$Lang::tr{'dial'}"; | |
101 | } | |
102 | ||
103 | if ($cgiparams{'ACTION'} eq $Lang::tr{'dial'}) { | |
a56b5be4 | 104 | system('/usr/local/bin/redctrl start > /dev/null') == 0 |
957363eb CS |
105 | or &General::log("Dial failed: $?"); sleep 1;} |
106 | elsif ($cgiparams{'ACTION'} eq $Lang::tr{'hangup'}) { | |
a56b5be4 | 107 | system('/usr/local/bin/redctrl stop > /dev/null') == 0 |
957363eb CS |
108 | or &General::log("Hangup failed: $?"); sleep 1;} |
109 | ||
e383179b MT |
110 | my $c; |
111 | my $maxprofiles = 5; | |
112 | my @profilenames = (); | |
113 | ||
114 | for ($c = 1; $c <= $maxprofiles; $c++) | |
115 | { | |
116 | my %temppppsettings = (); | |
117 | $temppppsettings{'PROFILENAME'} = ''; | |
118 | &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings); | |
119 | $profilenames[$c] = $temppppsettings{'PROFILENAME'}; | |
120 | } | |
121 | my %selected; | |
122 | for ($c = 1; $c <= $maxprofiles; $c++) { | |
123 | $selected{'PROFILE'}{$c} = ''; | |
124 | } | |
125 | $selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'"; | |
126 | my $dialButtonDisabled = "disabled='disabled'"; | |
127 | ||
128 | ||
ac1cfefa MT |
129 | &Header::openpage($Lang::tr{'main page'}, 1, $refresh); |
130 | &Header::openbigbox('', 'center'); | |
131 | &Header::openbox('100%', 'center', &Header::cleanhtml(`/bin/uname -n`,"y")); | |
132 | ||
3489ebac MT |
133 | |
134 | ||
a08a5f33 | 135 | if ( ( $pppsettings{'VALID'} eq 'yes' && $modemsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) { |
986e08d9 MT |
136 | if (open(IPADDR,"${General::swroot}/ddns/ipcache")) { |
137 | $ipaddr = <IPADDR>; | |
138 | close IPADDR; | |
139 | chomp ($ipaddr); | |
140 | } | |
141 | if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) { | |
786f2c8a | 142 | $ipaddr = <IPADDR>; |
986e08d9 MT |
143 | close IPADDR; |
144 | chomp ($ipaddr); | |
145 | } | |
ac1cfefa MT |
146 | } elsif ($modemsettings{'VALID'} eq 'no') { |
147 | print "$Lang::tr{'modem settings have errors'}\n </b></font>\n"; | |
148 | } else { | |
149 | print "$Lang::tr{'profile has errors'}\n </b></font>\n"; | |
150 | } | |
151 | ||
3489ebac MT |
152 | #if ( $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) { |
153 | # $ipaddr = $netsettings{'RED_ADDRESS'}; | |
154 | #} | |
e383179b | 155 | |
a56b5be4 CS |
156 | my $death = 0; |
157 | my $rebirth = 0; | |
158 | ||
159 | if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) { | |
160 | $death = 1; | |
161 | &General::log($Lang::tr{'shutting down ipfire'}); | |
162 | system '/usr/local/bin/ipfirereboot down'; | |
163 | } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) { | |
164 | $rebirth = 1; | |
165 | &General::log($Lang::tr{'rebooting ipfire'}); | |
166 | system '/usr/local/bin/ipfirereboot boot'; | |
167 | } | |
168 | ||
169 | if ($death == 0 && $rebirth == 0) { | |
0ab4385a JPT |
170 | |
171 | if ($mainsettings{'REBOOTQUESTION'} eq "off") { | |
172 | print <<END | |
173 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
174 | <table width='100%'> | |
175 | <tr> | |
176 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td> | |
177 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
178 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td> | |
179 | </tr> | |
180 | </table> | |
181 | </form> | |
c853dcce JPT |
182 | END |
183 | ; | |
0ab4385a JPT |
184 | } else { |
185 | if ($cgiparams{'ACTION'} eq $Lang::tr{'reboot ask'}) { | |
186 | print <<END | |
187 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
188 | <table width='100%'> | |
189 | <tr> | |
190 | <td colspan="3" align='left'><font color="red">$Lang::tr{'reboot sure'}</font></td> | |
191 | </tr> | |
192 | <tr> | |
193 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td> | |
194 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
195 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown ask'}' /></td> | |
196 | </tr> | |
197 | </table> | |
198 | </form> | |
b4ad0027 JPT |
199 | END |
200 | ; | |
0ab4385a | 201 | } elsif ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown ask'}) { |
a56b5be4 | 202 | print <<END |
0ab4385a JPT |
203 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
204 | <table width='100%'> | |
205 | <tr> | |
206 | <td colspan="3" align='right'><font color="red">$Lang::tr{'shutdown sure'}</font></td> | |
207 | </tr> | |
208 | <tr> | |
209 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot ask'}' /></td> | |
210 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
211 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td> | |
212 | </tr> | |
213 | </table> | |
214 | </form> | |
a56b5be4 CS |
215 | END |
216 | ; | |
0ab4385a JPT |
217 | } else { |
218 | print <<END | |
219 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
220 | <table width='100%'> | |
221 | <tr> | |
222 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot ask'}' /></td> | |
223 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' /></td> | |
224 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown ask'}' /></td> | |
225 | </tr> | |
226 | </table> | |
227 | </form> | |
228 | END | |
229 | ; | |
230 | } | |
b4ad0027 | 231 | } |
a56b5be4 | 232 | print <<END; |
e383179b | 233 | |
0ab4385a | 234 | |
e383179b MT |
235 | <!-- Table of networks --> |
236 | <table border='0' width=80%> | |
f2fdd0c1 CS |
237 | <tr> <th bgcolor='$color{'color20'}'>$Lang::tr{'network'} |
238 | <th bgcolor='$color{'color20'}'>IP | |
239 | <th bgcolor='$color{'color20'}'>$Lang::tr{'status'} | |
33e1f48c | 240 | <tr> <td align='center' bgcolor='$Header::colourred' width='25%'><a href="/cgi-bin/pppsetup.cgi"><font size='2' color='white'><b>$Lang::tr{'internet'}</b></font></a><br> |
c85ec3b4 CS |
241 | <td width='30%' align='center'>$ipaddr |
242 | <td width='45%' align='center'>$connstate | |
f3bbb213 | 243 | END |
c85ec3b4 | 244 | if ( $netsettings{'RED_TYPE'} ne "STATIC" && $netsettings{'RED_TYPE'} ne "DHCP" ){ |
f3bbb213 MT |
245 | print `/usr/local/bin/dialctrl.pl show`; |
246 | print <<END; | |
e383179b | 247 | <tr><td colspan='2'> |
957363eb | 248 | <form method='post' action='$ENV{'SCRIPT_NAME'}'>$Lang::tr{'profile'}: |
e383179b MT |
249 | <select name='PROFILE'> |
250 | END | |
251 | for ($c = 1; $c <= $maxprofiles; $c++) | |
252 | { | |
253 | if ($profilenames[$c] ne '') { | |
254 | $dialButtonDisabled = ""; | |
255 | print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n"; | |
256 | } | |
257 | } | |
c6aa4ac1 | 258 | $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipfire.pid' || -e "${General::swroot}/red/active"); |
a08a5f33 | 259 | if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) { |
e383179b MT |
260 | print <<END; |
261 | </select> | |
262 | <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled /> | |
263 | </form> | |
264 | <td align='center'> | |
265 | <table width='100%' border='0'> | |
266 | <tr> | |
957363eb | 267 | <td width='50%' align='right'> <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
e383179b MT |
268 | <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'> |
269 | </form> | |
957363eb | 270 | <td width='50%' align='left'> <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
e383179b MT |
271 | <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'> |
272 | </form> | |
273 | </table> | |
274 | END | |
275 | } else { | |
276 | print "$Lang::tr{'profile has errors'}\n </b></font>\n"; | |
277 | } | |
c85ec3b4 | 278 | } |
786f2c8a MT |
279 | my $HOSTNAME = (gethostbyaddr(pack("C4", split(/\./, $ipaddr)), 2))[0]; |
280 | if ( "$HOSTNAME" ne "" ) { | |
281 | print <<END; | |
c85ec3b4 | 282 | <tr><td><b>Hostname:</b><td align='center'>$HOSTNAME<td> |
786f2c8a MT |
283 | END |
284 | } | |
285 | ||
286 | if ( -e "/var/ipfire/red/remote-ipaddress" ) { | |
287 | my $GATEWAY = `cat /var/ipfire/red/remote-ipaddress`; | |
288 | chomp($GATEWAY); | |
289 | print <<END; | |
c85ec3b4 | 290 | <tr><td><b>Gateway:</b><td align='center'>$GATEWAY<td> |
786f2c8a MT |
291 | END |
292 | } | |
293 | ||
c6aa4ac1 MT |
294 | my $DNS1 = `cat /var/ipfire/red/dns1`; |
295 | my $DNS2 = `cat /var/ipfire/red/dns2`; | |
296 | chomp($DNS1); | |
297 | chomp($DNS1); | |
298 | ||
299 | if ( $DNS1 ) { print <<END; | |
c85ec3b4 | 300 | <tr><td><b>DNS-Server:</b><td align='center'>$DNS1 |
c6aa4ac1 MT |
301 | END |
302 | } | |
303 | if ( $DNS2 ) { print <<END; | |
c85ec3b4 | 304 | <td align='center'>$DNS2 |
c6aa4ac1 MT |
305 | END |
306 | } else { print <<END; | |
307 | <td> | |
308 | END | |
309 | } | |
310 | ||
072cd997 | 311 | if ( $netsettings{'GREEN_DEV'} ) { print <<END; |
33e1f48c | 312 | <tr><td align='center' bgcolor='$Header::colourgreen' width='25%'><a href="/cgi-bin/dhcp.cgi"><font size='2' color='white'><b>$Lang::tr{'lan'}</b></font></a> |
c85ec3b4 CS |
313 | <td width='30%' align='center'>$netsettings{'GREEN_ADDRESS'} |
314 | <td width='45%' align='center'> | |
e383179b | 315 | END |
072cd997 | 316 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE=on` ) { |
ef482d53 | 317 | print $Lang::tr{'advproxy on'}; |
072cd997 | 318 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT=on` ) { print " (transparent)"; } |
ef482d53 | 319 | } else { print $Lang::tr{'advproxy off'}; } |
072cd997 MT |
320 | } |
321 | if ( $netsettings{'BLUE_DEV'} ) { print <<END; | |
33e1f48c | 322 | <tr><td align='center' bgcolor='$Header::colourblue' width='25%'><a href="/cgi-bin/wireless.cgi"><font size='2' color='white'><b>$Lang::tr{'wireless'}</b></font></a><br> |
c85ec3b4 CS |
323 | <td width='30%' align='center'>$netsettings{'BLUE_ADDRESS'} |
324 | <td width='45%' align='center'> | |
e383179b | 325 | END |
072cd997 | 326 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE_BLUE=on` ) { |
ef482d53 | 327 | print $Lang::tr{'advproxy on'}; |
072cd997 | 328 | if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT_BLUE=on` ) { print " (transparent)"; } |
ef482d53 | 329 | } else { print $Lang::tr{'advproxy off'}; } |
072cd997 | 330 | } |
39a7cc11 | 331 | if ( $netsettings{'ORANGE_DEV'} ) { print <<END; |
33e1f48c | 332 | <tr><td align='center' bgcolor='$Header::colourorange' width='25%'><a href="/cgi-bin/dmzholes.cgi"><font size='2' color='white'><b>$Lang::tr{'dmz'}</b></font></a><br> |
c85ec3b4 CS |
333 | <td width='30%' align='center'>$netsettings{'ORANGE_ADDRESS'} |
334 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
e383179b | 335 | END |
072cd997 | 336 | } |
39a7cc11 MT |
337 | if ( `cat /var/ipfire/vpn/settings | grep ^ENABLED=on` || |
338 | `cat /var/ipfire/vpn/settings | grep ^ENABLED_BLUE=on` ) { | |
072cd997 | 339 | my $ipsecip = `cat /var/ipfire/vpn/settings | grep ^VPN_IP= | cut -c 8-`; |
e455cafe MT |
340 | my @status = `/usr/sbin/ipsec auto --status`; |
341 | my %confighash = (); | |
342 | &General::readhasharray("${General::swroot}/vpn/config", \%confighash); | |
072cd997 | 343 | print <<END; |
33e1f48c | 344 | <tr><td align='center' bgcolor='$Header::colourvpn' width='25%'><a href="/cgi-bin/vpnmain.cgi"><font size='2' color='white'><b>$Lang::tr{'vpn'}</b></font></a><br> |
c85ec3b4 CS |
345 | <td width='30%' align='center'>$ipsecip |
346 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
e383179b | 347 | END |
e455cafe MT |
348 | my $id = 0; |
349 | my $gif; | |
350 | foreach my $key (keys %confighash) { | |
351 | if ($confighash{$key}[0] eq 'on') { $gif = 'on.gif'; } else { $gif = 'off.gif'; } | |
352 | ||
353 | if ($id % 2) { | |
9a2a723e | 354 | print "<tr><td align='left' nowrap='nowrap' bgcolor='$color{'color20'}'>$confighash{$key}[1] / " . $Lang::tr{"$confighash{$key}[3]"} . " (" . $Lang::tr{"$confighash{$key}[4]"} . ")</td><td align='center'>$confighash{$key}[11]</td>"; |
e455cafe | 355 | } else { |
9a2a723e | 356 | print "<tr></td><td align='left' nowrap='nowrap' bgcolor='$color{'color22'}'>$confighash{$key}[1] / " . $Lang::tr{"$confighash{$key}[3]"} . " (" . $Lang::tr{"$confighash{$key}[4]"} . ")</td><td align='center'>$confighash{$key}[11]</td>"; |
e455cafe | 357 | } |
fe6cda92 | 358 | |
e455cafe MT |
359 | my $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourred}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b></td></tr></table>"; |
360 | if ($confighash{$key}[0] eq 'off') { | |
361 | $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourblue}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsclosed'}</font></b></td></tr></table>"; | |
362 | } else { | |
363 | foreach my $line (@status) { | |
364 | if ($line =~ /\"$confighash{$key}[1]\".*IPsec SA established/) { | |
f2fdd0c1 | 365 | $active = "<table cellpadding='2' cellspacing='0' bgcolor='${Header::colourgreen}' width='100%'><tr><td align='center'><b><font color='#FFFFFF'>$Lang::tr{'capsopen'}</font></b></td></tr></table>"; |
e455cafe MT |
366 | } |
367 | } | |
368 | } | |
369 | print "<td align='center'>$active</td>"; | |
370 | } | |
072cd997 MT |
371 | } |
372 | if ( `cat /var/ipfire/ovpn/settings | grep ^ENABLED=on` || | |
373 | `cat /var/ipfire/ovpn/settings | grep ^ENABLED_BLUE=on` || | |
374 | `cat /var/ipfire/ovpn/settings | grep ^ENABLED_ORANGE=on`) { | |
375 | my $ovpnip = `cat /var/ipfire/ovpn/settings | grep ^DOVPN_SUBNET= | cut -c 14- | sed -e 's\/\\/255.255.255.0\/\/'`; | |
376 | print <<END; | |
33e1f48c | 377 | <tr><td align='center' bgcolor='$Header::colourovpn' width='25%'><a href="/cgi-bin/ovpnmain.cgi"><font size='2' color='white'><b>OpenVPN</b></font></a><br> |
c85ec3b4 CS |
378 | <td width='30%' align='center'>$ovpnip |
379 | <td width='45%' align='center'><font color=$Header::colourgreen>Online</font> | |
072cd997 MT |
380 | END |
381 | } | |
ac1cfefa MT |
382 | |
383 | # Memory usage warning | |
384 | my @free = `/usr/bin/free`; | |
385 | $free[1] =~ m/(\d+)/; | |
386 | my $mem = $1; | |
387 | $free[2] =~ m/(\d+)/; | |
388 | my $used = $1; | |
389 | my $pct = int 100 * ($mem - $used) / $mem; | |
390 | if ($used / $mem > 90) { | |
391 | $warnmessage .= "<li> $Lang::tr{'high memory usage'}: $pct% !</li>\n"; | |
392 | } | |
393 | ||
394 | # Diskspace usage warning | |
395 | my @temp=(); | |
396 | my $temp2=(); | |
397 | my @df = `/bin/df -B M -x rootfs`; | |
398 | foreach my $line (@df) { | |
399 | next if $line =~ m/^Filesystem/; | |
400 | if ($line =~ m/root/ ) { | |
401 | $line =~ m/^.* (\d+)M.*$/; | |
402 | @temp = split(/ +/,$line); | |
403 | if ($1<5) { | |
404 | # available:plain value in MB, and not %used as 10% is too much to waste on small disk | |
405 | # and root size should not vary during time | |
62f1526a | 406 | $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$1M</b> !</li>\n"; |
ac1cfefa MT |
407 | } |
408 | ||
409 | } else { | |
410 | # $line =~ m/^.* (\d+)m.*$/; | |
411 | $line =~ m/^.* (\d+)\%.*$/; | |
412 | if ($1>90) { | |
413 | @temp = split(/ /,$line); | |
414 | $temp2=int(100-$1); | |
62f1526a | 415 | $warnmessage .= "<li> $Lang::tr{'filesystem full'}: $temp[0] <b>$Lang::tr{'free'}=$temp2%</b> !</li>\n"; |
ac1cfefa MT |
416 | } |
417 | } | |
418 | } | |
419 | ||
c1712013 AF |
420 | # S.M.A.R.T. health warning |
421 | my @files = `/bin/ls /var/run/smartctl_out_hddtemp-*`; | |
422 | foreach my $file (@files) { | |
423 | chomp ($file); | |
424 | my $disk=`echo $file | cut -d"-" -f2`; | |
425 | chomp ($disk); | |
426 | if (`/bin/grep "SAVE ALL DATA" $file`) { | |
62f1526a | 427 | $warnmessage .= "<li> $Lang::tr{'smartwarn1'} /dev/$disk $Lang::tr{'smartwarn2'} !</li>\n\n"; |
c1712013 AF |
428 | } |
429 | } | |
430 | ||
ac1cfefa | 431 | if ($warnmessage) { |
02dc0a76 | 432 | print "<tr><td align='center' bgcolor=$Header::colourred colspan='3'><font color='white'>$warnmessage</font></table>"; |
ac1cfefa | 433 | } |
02dc0a76 MT |
434 | print <<END; |
435 | </table> | |
2b38ab5c JPT |
436 | END |
437 | ; | |
438 | &Pakfire::dblist("upgrade", "notice"); | |
439 | print <<END; | |
f3bbb213 | 440 | |
02dc0a76 | 441 | END |
8de160ff MT |
442 | } else { |
443 | my $message=''; | |
444 | if ($death) { | |
445 | $message = $Lang::tr{'ipfire has now shutdown'}; | |
446 | } else { | |
447 | $message = $Lang::tr{'ipfire has now rebooted'}; | |
448 | } | |
449 | print <<END | |
450 | <div align='center'> | |
451 | <table width='100%' bgcolor='#ffffff'> | |
452 | <tr><td align='center'> | |
94ec137d | 453 | <br /><br /><img src='/images/IPFire.png' /><br /><br /><br /> |
8de160ff MT |
454 | </td></tr> |
455 | </table> | |
456 | <br /> | |
457 | <font size='6'>$message</font> | |
458 | </div> | |
459 | END | |
460 | ; | |
b4ad0027 JPT |
461 | |
462 | } | |
463 | ||
ac1cfefa | 464 | &Header::closebox(); |
ac1cfefa | 465 | &Header::closebigbox(); |
ac1cfefa | 466 | &Header::closepage(); |