]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/pakfire.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2011 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";
31 require "/opt/pakfire/lib/functions.pl";
33 my %pakfiresettings=();
34 my $errormessage = '';
36 my %mainsettings = ();
38 &Header
::showhttpheaders
();
40 $pakfiresettings{'ACTION'} = '';
41 $pakfiresettings{'VALID'} = '';
43 $pakfiresettings{'INSPAKS'} = '';
44 $pakfiresettings{'DELPAKS'} = '';
45 $pakfiresettings{'AUTOUPDATE'} = 'off';
46 $pakfiresettings{'HEALTHCHECK'} = 'on';
47 $pakfiresettings{'UUID'} = 'on';
49 sub refreshpage
{&Header
::openbox
( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header
::closebox
();}
51 &Header
::getcgihash
(\
%pakfiresettings);
53 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
54 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
56 &Header
::openpage
($Lang::tr
{'pakfire configuration'}, 1);
57 &Header
::openbigbox
('100%', 'left', '', $errormessage);
59 if ($pakfiresettings{'ACTION'} eq 'install'){
60 $pakfiresettings{'INSPAKS'} =~ s/\|/\ /g;
61 if ("$pakfiresettings{'FORCE'}" eq "on") {
62 my $command = "/usr/local/bin/pakfire install --non-interactive --no-colors $pakfiresettings{'INSPAKS'} &>/dev/null &";
64 system("/bin/sleep 1");
66 &Header
::openbox
("100%", "center", $Lang::tr
{'request'});
67 my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'INSPAKS'}`;
69 <table><tr><td colspan='2'>$Lang::tr{'pakfire install package'}.$pakfiresettings{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'}
73 $_ =~ s/\\e\[[0-1]\;[0-9]+m//g;
78 <tr><td colspan='2'>$Lang::tr{'pakfire accept all'}
79 <tr><td colspan='2'>
80 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
81 <input type='hidden' name='INSPAKS' value='$pakfiresettings{'INSPAKS'}' />
82 <input type='hidden' name='FORCE' value='on' />
83 <input type='hidden' name='ACTION' value='install' />
84 <input type='image' alt='$Lang::tr{'install'}' title='$Lang::tr{'install'}' src='/images/go-next.png' />
87 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
88 <input type='hidden' name='ACTION' value='' />
89 <input type='image' alt='$Lang::tr{'abort'}' title='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
94 &Header
::closebigbox
();
98 } elsif ($pakfiresettings{'ACTION'} eq 'remove') {
100 $pakfiresettings{'DELPAKS'} =~ s/\|/\ /g;
101 if ("$pakfiresettings{'FORCE'}" eq "on") {
102 my $command = "/usr/local/bin/pakfire remove --non-interactive --no-colors $pakfiresettings{'DELPAKS'} &>/dev/null &";
104 system("/bin/sleep 1");
106 &Header
::openbox
("100%", "center", $Lang::tr
{'request'});
107 my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'DELPAKS'}`;
109 <table><tr><td colspan='2'>$Lang::tr{'pakfire uninstall package'}.$pakfiresettings{'DELPAKS'}.$Lang::tr{'pakfire possible dependency'}
113 $_ =~ s/\\e\[[0-1]\;[0-9]+m//g;
118 <tr><td colspan='2'>$Lang::tr{'pakfire accept all'}
119 <tr><td colspan='2'>
120 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
121 <input type='hidden' name='DELPAKS' value='$pakfiresettings{'DELPAKS'}' />
122 <input type='hidden' name='FORCE' value='on' />
123 <input type='hidden' name='ACTION' value='remove' />
124 <input type='image' alt='$Lang::tr{'uninstall'}' title='$Lang::tr{'uninstall'}' src='/images/go-next.png' />
127 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
128 <input type='hidden' name='ACTION' value='' />
129 <input type='image' alt='$Lang::tr{'abort'}' title='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
134 &Header
::closebigbox
();
135 &Header
::closepage
();
139 } elsif ($pakfiresettings{'ACTION'} eq 'update') {
141 system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null &");
142 system("/bin/sleep 1");
143 } elsif ($pakfiresettings{'ACTION'} eq 'upgrade') {
144 my $command = "/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null &";
146 system("/bin/sleep 1");
147 } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") {
149 if ($pakfiresettings{'AUTOUPDATE'} eq 'on') {
150 system("/usr/local/bin/pakfire enable updates >/dev/null 2>&1");
152 system("/usr/local/bin/pakfire disable updates >/dev/null 2>&1");
155 &General
::writehash
("${General::swroot}/pakfire/settings", \
%pakfiresettings);
158 &General
::readhash
("${General::swroot}/pakfire/settings", \
%pakfiresettings);
163 $checked{'AUTOUPDATE'}{'off'} = '';
164 $checked{'AUTOUPDATE'}{'on'} = '';
165 $checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
166 $checked{'HEALTHCHECK'}{'off'} = '';
167 $checked{'HEALTHCHECK'}{'on'} = '';
168 $checked{'HEALTHCHECK'}{$pakfiresettings{'HEALTHCHECK'}} = "checked='checked'";
169 $checked{'UUID'}{'off'} = '';
170 $checked{'UUID'}{'on'} = '';
171 $checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'";
173 # DPC move error message to top so it is seen!
175 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
176 print "<font class='base'>$errormessage </font>\n";
180 my $return = `pidof pakfire`;
183 &Header
::openbox
( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" );
187 <img src='/images/indicator.gif' alt='$Lang::tr{'aktiv'}' title='$Lang::tr{'aktiv'}' />
189 $Lang::tr{'pakfire working'}
190 <tr><td colspan='2' align='center'>
191 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
192 <input type='image' alt='$Lang::tr{'reload'}' title='$Lang::tr{'reload'}' src='/images/view-refresh.png' />
194 <tr><td colspan='2' align='left'><pre>
196 my @output = `grep pakfire /var/log/messages | tail -20`;
205 &Header
::closebigbox
();
206 &Header
::closepage
();
211 my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`;
212 chomp($core_release);
213 my $core_update_age = &General
::age
("/opt/pakfire/db/core/mine");
214 my $corelist_update_age = &General
::age
("/opt/pakfire/db/lists/core-list.db");
215 my $server_update_age = &General
::age
("/opt/pakfire/db/lists/server-list.db");
216 my $packages_update_age = &General
::age
("/opt/pakfire/db/lists/packages_list.db");
218 &Header
::openbox
("100%", "center", "Pakfire");
221 <table width='95%' cellpadding='5' >
223 if ( -e
"/var/run/need_reboot") {
224 print "<tr><td align='center' colspan='2'><font color='red'>$Lang::tr{'needreboot'}!</font></td></tr>";
225 print "<tr><td colspan='2'> </font></td></tr>"
228 <tr><td width="50%" bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire system state'}:</b>
230 <tr><td align="center">$Lang::tr{'pakfire core update level'}: $core_release<hr />
231 $Lang::tr{'pakfire last update'} $core_update_age $Lang::tr{'pakfire ago'}<br />
232 $Lang::tr{'pakfire last serverlist update'} $server_update_age $Lang::tr{'pakfire ago'}<br />
233 $Lang::tr{'pakfire last core list update'} $corelist_update_age $Lang::tr{'pakfire ago'}<br />
234 $Lang::tr{'pakfire last package update'} $packages_update_age $Lang::tr{'pakfire ago'}
235 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
236 <input type='hidden' name='ACTION' value='update' />
237 <input type='submit' value='$Lang::tr{'calamaris refresh list'}' /><br />
240 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
241 <select name="UPDPAKS" size="5" disabled>
243 &Pakfire
::dblist
("upgrade", "forweb");
247 <input type='hidden' name='ACTION' value='upgrade' />
248 <input type='image' alt='$Lang::tr{'upgrade'}' title='$Lang::tr{'upgrade'}' src='/images/document-save.png' />
251 <tr><td colspan="2"><!-- Just an empty line -->
252 <tr><td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire available addons'}</b>
253 <td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire installed addons'}</b>
254 <tr><td align="center">
255 <p>$Lang::tr{'pakfire install description'}</p>
256 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
257 <select name="INSPAKS" size="10" multiple>
259 &Pakfire
::dblist
("notinstalled", "forweb");
264 <input type='hidden' name='ACTION' value='install' />
265 <input type='image' alt='$Lang::tr{'install'}' title='$Lang::tr{'install'}' src='/images/list-add.png' />
269 <p>$Lang::tr{'pakfire uninstall description'}</p>
270 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
271 <select name="DELPAKS" size="10" multiple>
274 &Pakfire
::dblist
("installed", "forweb");
279 <input type='hidden' name='ACTION' value='remove' />
280 <input type='image' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' src='/images/list-remove.png' />
286 &Header
::openbox
("100%", "center", "$Lang::tr{'settings'}");
289 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
291 <tr><td colspan='2' bgcolor='$color{'color20'}'><b>$Lang::tr{'basic options'}</b></td></tr>
292 <tr><td align='left' width='45%'>$Lang::tr{'pakfire update daily'}</td><td width="55%" align="left">
293 on <input type='radio' name='AUTOUPDATE' value='on' $checked{'AUTOUPDATE'}{'on'} /> |
294 <input type='radio' name='AUTOUPDATE' value='off' $checked{'AUTOUPDATE'}{'off'} /> off </td></tr>
295 <tr><td align='left' width='45%'>$Lang::tr{'pakfire health check'}</td><td align="left">
296 on <input type='radio' name='HEALTHCHECK' value='on' $checked{'HEALTHCHECK'}{'on'} /> |
297 <input type='radio' name='HEALTHCHECK' value='off' $checked{'HEALTHCHECK'}{'off'} /> off </td></tr>
298 <tr><td align='left' width='45%'>$Lang::tr{'pakfire register'}</td><td align="left">
299 on <input type='radio' name='UUID' value='on' $checked{'UUID'}{'on'} /> |
300 <input type='radio' name='UUID' value='off' $checked{'UUID'}{'off'} /> off </td></tr>
301 <tr><td colspan="2" align="center"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" /></td></tr>
307 &Header
::closebigbox
();
308 &Header
::closepage
();