]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/pakfire.cgi
Hddtemp DB angepasst frcon logging deaktiviert
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / pakfire.cgi
CommitLineData
3ea75603 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###############################################################################
3ea75603
MT
21
22use strict;
23
24# enable only the following on debugging purpose
cb5e9c6c
CS
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
3ea75603 27
986e08d9 28require '/var/ipfire/general-functions.pl';
3ea75603
MT
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
1bd42c89 31require "/opt/pakfire/lib/functions.pl";
3ea75603
MT
32
33my %pakfiresettings=();
34my $errormessage = '';
cb5e9c6c
CS
35my %color = ();
36my %mainsettings = ();
3ea75603
MT
37
38&Header::showhttpheaders();
39
40$pakfiresettings{'ACTION'} = '';
41$pakfiresettings{'VALID'} = '';
42
1bd42c89
MT
43$pakfiresettings{'INSPAKS'} = '';
44$pakfiresettings{'DELPAKS'} = '';
99e6df8e 45$pakfiresettings{'AUTOUPDATE'} = 'off';
377560fb 46$pakfiresettings{'AUTOUPGRADE'} = 'off';
99e6df8e 47$pakfiresettings{'UUID'} = 'on';
3ea75603
MT
48
49&Header::getcgihash(\%pakfiresettings);
d40aff35 50
cb5e9c6c
CS
51&General::readhash("${General::swroot}/main/settings", \%mainsettings);
52&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
3ea75603 53
1bd42c89
MT
54&Header::openpage($Lang::tr{'pakfire configuration'}, 1);
55&Header::openbigbox('100%', 'left', '', $errormessage);
3ea75603 56
957363eb 57if ($pakfiresettings{'ACTION'} eq 'install'){
908a3eb7 58 $pakfiresettings{'INSPAKS'} =~ s/\|/\ /g;
5b2a12ff 59 if ("$pakfiresettings{'FORCE'}" eq "on") {
750c1528 60 my $command = "/usr/local/bin/pakfire install --non-interactive --no-colors $pakfiresettings{'INSPAKS'} &>/dev/null &";
908a3eb7
MT
61 system("$command");
62 sleep(2);
5b2a12ff
MT
63 } else {
64 &Header::openbox("100%", "center", "Abfrage");
74693811 65 my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'INSPAKS'}`;
5b2a12ff 66 print <<END;
bac7231b 67 <table><tr><td colspan='2'>$Lang::tr{'pakfire install package'}.$pakfiresettings{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'}
5b2a12ff
MT
68 <pre>
69END
70 foreach (@output) {
71 print "$_\n";
72 }
73 print <<END;
74 </pre>
bac7231b 75 <tr><td colspan='2'>$Lang::tr{'pakfire accept all'}
5b2a12ff
MT
76 <tr><td colspan='2'>&nbsp;
77 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
78 <input type='hidden' name='INSPAKS' value='$pakfiresettings{'INSPAKS'}' />
79 <input type='hidden' name='FORCE' value='on' />
80 <input type='hidden' name='ACTION' value='install' />
81 <input type='image' alt='$Lang::tr{'install'}' src='/images/go-next.png' />
82 </form>
83 <td align='left'>
84 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
85 <input type='hidden' name='ACTION' value='' />
86 <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
87 </form>
88 </table>
89END
90 &Header::closebox();
91 &Header::closebigbox();
92 &Header::closepage();
93 exit;
94 }
95} elsif ($pakfiresettings{'ACTION'} eq 'remove') {
96
74693811
CS
97 $pakfiresettings{'DELPAKS'} =~ s/\|/\ /g;
98 if ("$pakfiresettings{'FORCE'}" eq "on") {
99 my $command = "/usr/local/bin/pakfire remove --non-interactive --no-colors $pakfiresettings{'DELPAKS'} &>/dev/null &";
100 system("$command");
101 sleep(2);
102 } else {
103 &Header::openbox("100%", "center", "Abfrage");
104 my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'DELPAKS'}`;
105 print <<END;
106 <table><tr><td colspan='2'>$Lang::tr{'pakfire uninstall package'}.$pakfiresettings{'DELPAKS'}.$Lang::tr{'pakfire possible dependency'}
107 <pre>
108END
109 foreach (@output) {
110 print "$_\n";
111 }
112 print <<END;
113 </pre>
114 <tr><td colspan='2'>$Lang::tr{'pakfire accept all'}
115 <tr><td colspan='2'>&nbsp;
116 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
117 <input type='hidden' name='DELPAKS' value='$pakfiresettings{'DELPAKS'}' />
118 <input type='hidden' name='FORCE' value='on' />
119 <input type='hidden' name='ACTION' value='remove' />
120 <input type='image' alt='$Lang::tr{'uninstall'}' src='/images/go-next.png' />
121 </form>
122 <td align='left'>
123 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
124 <input type='hidden' name='ACTION' value='' />
125 <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
126 </form>
127 </table>
128END
129 &Header::closebox();
130 &Header::closebigbox();
131 &Header::closepage();
132 exit;
133 }
134
5b2a12ff
MT
135} elsif ($pakfiresettings{'ACTION'} eq 'update') {
136
377560fb 137 system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null");
5b2a12ff 138
186e3d2c 139} elsif ($pakfiresettings{'ACTION'} eq 'upgrade') {
5b2a12ff 140
377560fb 141 system("/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null");
5b2a12ff
MT
142
143} elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") {
144
377560fb
MT
145 if ($pakfiresettings{'AUTOUPDATE'} == "on") {
146 system("/usr/local/bin/pakfire enable updates");
147 } else {
148 system("/usr/local/bin/pakfire disable updates");
149 }
150
151 if ($pakfiresettings{'AUTOUPGRADE'} == "on") {
152 system("/usr/local/bin/pakfire enable upgrades");
153 } else {
154 system("/usr/local/bin/pakfire disable upgrades");
155 }
4b122800 156
377560fb 157 &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
3ea75603
MT
158}
159
160&General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings);
161
3ea75603
MT
162my %selected=();
163my %checked=();
164
1bd42c89
MT
165$checked{'AUTOUPDATE'}{'off'} = '';
166$checked{'AUTOUPDATE'}{'on'} = '';
167$checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
377560fb
MT
168$checked{'AUTOUPGRADE'}{'off'} = '';
169$checked{'AUTOUPGRADE'}{'on'} = '';
170$checked{'AUTOUPGRADE'}{$pakfiresettings{'AUTOUPGRADE'}} = "checked='checked'";
4b122800
MT
171$checked{'UUID'}{'off'} = '';
172$checked{'UUID'}{'on'} = '';
173$checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'";
3ea75603
MT
174
175# DPC move error message to top so it is seen!
176if ($errormessage) {
177 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
178 print "<font class='base'>$errormessage&nbsp;</font>\n";
179 &Header::closebox();
5b2a12ff
MT
180}
181
186e3d2c
MT
182my $return = `pidof pakfire`;
183chomp($return);
184if ($return) {
ca4c317c 185 &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" );
5b2a12ff
MT
186 print <<END;
187 <table>
188 <tr><td>
186e3d2c 189 <img src='/images/indicator.gif' alt='$Lang::tr{'aktiv'}' />&nbsp;
5b2a12ff 190 <td>
bac7231b 191 $Lang::tr{'pakfire working'}
5b2a12ff
MT
192 <tr><td colspan='2' align='center'>
193 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
194 <input type='image' alt='$Lang::tr{'reload'}' src='/images/view-refresh.png' />
195 </form>
186e3d2c
MT
196 <tr><td colspan='2' align='left'><pre>
197END
750c1528
MT
198 my @output = `tail -20 /var/log/pakfire.log`;
199 foreach (@output) {
200 print "$_";
201 }
202 print <<END;
203 </pre>
204 </table>
5b2a12ff
MT
205END
206 &Header::closebox();
207 &Header::closebigbox();
208 &Header::closepage();
209 exit;
210}
3ea75603 211
377560fb
MT
212my $core_release = `cat /opt/pakfire/db/core/mine`;
213chomp($core_release);
214my $core_update_age = &General::age("/opt/pakfire/db/core/mine");
215my $corelist_update_age = &General::age("/opt/pakfire/db/lists/core-list.db");
216my $server_update_age = &General::age("/opt/pakfire/db/lists/server-list.db");
217my $packages_update_age = &General::age("/opt/pakfire/db/lists/packages_list.db");
218
1bd42c89
MT
219&Header::openbox("100%", "center", "Pakfire");
220
221print <<END;
d40aff35 222 <table width='95%' cellpadding='5' >
c5d106c1 223 <tr><td width="50%" bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire system state'}:</b>
377560fb 224 <td width="50%">
c5d106c1
CS
225 <tr><td align="center">$Lang::tr{'pakfire core update level'}: $core_release<hr />
226 $Lang::tr{'pakfire last update'} $core_update_age ago<br />
227 $Lang::tr{'pakfire last serverlist update'} $server_update_age ago<br />
228 $Lang::tr{'pakfire last core list update'} $corelist_update_age ago<br />
229 $Lang::tr{'pakfire last package update'} $packages_update_age ago
377560fb
MT
230 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
231 <input type='hidden' name='ACTION' value='update' />
232 <input type='submit' value='Liste aktualisieren' /><br />
233 </form>
234 <td align="center">
235 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
236 <select name="UPDPAKS" size="5" disabled>
237END
238 &Pakfire::dblist("upgrade", "forweb");
239 print <<END;
240 </select>
241 <br />
242 <input type='hidden' name='ACTION' value='upgrade' />
243 <input type='image' alt='$Lang::tr{'upgrade'}' src='/images/document-save.png' />
244 </form>
245
246 <tr><td colspan="2"><!-- Just an empty line -->&nbsp;
247 <tr><td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire available addons'}</b>
248 <td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire installed addons'}</b>
249 <tr><td align="center">
5d22ef4e 250 <p>$Lang::tr{'pakfire install description'}</p>
377560fb 251 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1bd42c89
MT
252 <select name="INSPAKS" size="10" multiple>
253END
254 &Pakfire::dblist("notinstalled", "forweb");
255
256print <<END;
257 </select>
377560fb 258 <br />
1bd42c89
MT
259 <input type='hidden' name='ACTION' value='install' />
260 <input type='image' alt='$Lang::tr{'install'}' src='/images/list-add.png' />
1bd42c89 261 </form>
377560fb
MT
262
263 <td align="center">
5d22ef4e 264 <p>$Lang::tr{'pakfire uninstall description'}</p>
377560fb 265 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1bd42c89 266 <select name="DELPAKS" size="10" multiple>
957363eb 267END
5b2a12ff
MT
268
269 &Pakfire::dblist("installed", "forweb");
270
271print <<END;
377560fb
MT
272 </select>
273 <br />
274 <input type='hidden' name='ACTION' value='remove' />
275 <input type='image' alt='$Lang::tr{'remove'}' src='/images/list-remove.png' />
276 </form>
277 </table>
4b122800
MT
278END
279
377560fb
MT
280&Header::closebox();
281&Header::openbox("100%", "center", "$Lang::tr{'settings'}");
4b122800
MT
282
283print <<END;
1bd42c89 284 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
d40aff35
CS
285 <table width='95%'>
286 <tr><td colspan='2' bgcolor='$color{'color20'}'><b>$Lang::tr{'basic options'}</b></td></tr>
287 <tr><td align='left' width='40%'>$Lang::tr{'pakfire update daily'}</td><td align="left">
288 on <input type='radio' name='AUTOUPDATE' value='on' $checked{'AUTOUPDATE'}{'on'} />/
289 <input type='radio' name='AUTOUPDATE' value='off' $checked{'AUTOUPDATE'}{'off'} /> off </td></tr>
290 <tr><td align='left' width='40%'>$Lang::tr{'pakfire core update auto'}</td><td align="left">
291 on <input type='radio' name='AUTOUPGRADE' value='on' $checked{'AUTOUPGRADE'}{'on'} />/
292 <input type='radio' name='AUTOUPGRADE' value='off' $checked{'AUTOUPGRADE'}{'off'} /> off </td></tr>
293 <tr><td align='left' width='40%'>$Lang::tr{'pakfire register'}</td><td align="left">
294 on <input type='radio' name='UUID' value='on' $checked{'UUID'}{'on'} />/
295 <input type='radio' name='UUID' value='off' $checked{'UUID'}{'off'} /> off </td></tr>
296 <tr><td width='100%' colspan="2" align="center"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" /></td></tr>
1bd42c89
MT
297 </table>
298 </form>
299END
300
3ea75603 301&Header::closebox();
3ea75603 302&Header::closebigbox();
3ea75603 303&Header::closepage();