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