]>
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 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{'AUTOUPGRADE'} = 'off';
47 $pakfiresettings{'HEALTHCHECK'} = 'on';
48 $pakfiresettings{'UUID'} = 'on';
50 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
();}
52 &Header
::getcgihash
(\
%pakfiresettings);
54 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
55 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
57 &Header
::openpage
($Lang::tr
{'pakfire configuration'}, 1);
58 &Header
::openbigbox
('100%', 'left', '', $errormessage);
60 if ($pakfiresettings{'ACTION'} eq 'install'){
61 $pakfiresettings{'INSPAKS'} =~ s/\|/\ /g;
62 if ("$pakfiresettings{'FORCE'}" eq "on") {
63 my $command = "/usr/local/bin/pakfire install --non-interactive --no-colors $pakfiresettings{'INSPAKS'} &>/dev/null &";
65 system("/bin/sleep 1");
67 &Header
::openbox
("100%", "center", "Abfrage");
68 my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'INSPAKS'}`;
70 <table><tr><td colspan='2'>$Lang::tr{'pakfire install package'}.$pakfiresettings{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'}
74 $_ =~ s/\\e\[[0-1]\;[0-9]+m//g;
79 <tr><td colspan='2'>$Lang::tr{'pakfire accept all'}
80 <tr><td colspan='2'>
81 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
82 <input type='hidden' name='INSPAKS' value='$pakfiresettings{'INSPAKS'}' />
83 <input type='hidden' name='FORCE' value='on' />
84 <input type='hidden' name='ACTION' value='install' />
85 <input type='image' alt='$Lang::tr{'install'}' src='/images/go-next.png' />
88 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
89 <input type='hidden' name='ACTION' value='' />
90 <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
95 &Header
::closebigbox
();
99 } elsif ($pakfiresettings{'ACTION'} eq 'remove') {
101 $pakfiresettings{'DELPAKS'} =~ s/\|/\ /g;
102 if ("$pakfiresettings{'FORCE'}" eq "on") {
103 my $command = "/usr/local/bin/pakfire remove --non-interactive --no-colors $pakfiresettings{'DELPAKS'} &>/dev/null &";
105 system("/bin/sleep 1");
107 &Header
::openbox
("100%", "center", "Abfrage");
108 my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'DELPAKS'}`;
110 <table><tr><td colspan='2'>$Lang::tr{'pakfire uninstall package'}.$pakfiresettings{'DELPAKS'}.$Lang::tr{'pakfire possible dependency'}
114 $_ =~ s/\\e\[[0-1]\;[0-9]+m//g;
119 <tr><td colspan='2'>$Lang::tr{'pakfire accept all'}
120 <tr><td colspan='2'>
121 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
122 <input type='hidden' name='DELPAKS' value='$pakfiresettings{'DELPAKS'}' />
123 <input type='hidden' name='FORCE' value='on' />
124 <input type='hidden' name='ACTION' value='remove' />
125 <input type='image' alt='$Lang::tr{'uninstall'}' src='/images/go-next.png' />
128 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
129 <input type='hidden' name='ACTION' value='' />
130 <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
135 &Header
::closebigbox
();
136 &Header
::closepage
();
140 } elsif ($pakfiresettings{'ACTION'} eq 'update') {
142 system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null &");
143 system("/bin/sleep 1");
144 } elsif ($pakfiresettings{'ACTION'} eq 'upgrade') {
145 my $command = "/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null &";
147 system("/bin/sleep 1");
148 } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") {
150 if ($pakfiresettings{'AUTOUPDATE'} eq 'on') {
151 system("/usr/local/bin/pakfire enable updates >/dev/null 2>&1");
153 system("/usr/local/bin/pakfire disable updates >/dev/null 2>&1");
156 if ($pakfiresettings{'AUTOUPGRADE'} eq 'on') {
157 system("/usr/local/bin/pakfire enable upgrades >/dev/null 2>&1");
159 system("/usr/local/bin/pakfire disable upgrades >/dev/null 2>&1");
162 &General
::writehash
("${General::swroot}/pakfire/settings", \
%pakfiresettings);
165 &General
::readhash
("${General::swroot}/pakfire/settings", \
%pakfiresettings);
170 $checked{'AUTOUPDATE'}{'off'} = '';
171 $checked{'AUTOUPDATE'}{'on'} = '';
172 $checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
173 $checked{'AUTOUPGRADE'}{'off'} = '';
174 $checked{'AUTOUPGRADE'}{'on'} = '';
175 $checked{'AUTOUPGRADE'}{$pakfiresettings{'AUTOUPGRADE'}} = "checked='checked'";
176 $checked{'HEALTHCHECK'}{'off'} = '';
177 $checked{'HEALTHCHECK'}{'on'} = '';
178 $checked{'HEALTHCHECK'}{$pakfiresettings{'HEALTHCHECK'}} = "checked='checked'";
179 $checked{'UUID'}{'off'} = '';
180 $checked{'UUID'}{'on'} = '';
181 $checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'";
183 # DPC move error message to top so it is seen!
185 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
186 print "<font class='base'>$errormessage </font>\n";
190 my $return = `pidof pakfire`;
193 &Header
::openbox
( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" );
197 <img src='/images/indicator.gif' alt='$Lang::tr{'aktiv'}' />
199 $Lang::tr{'pakfire working'}
200 <tr><td colspan='2' align='center'>
201 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
202 <input type='image' alt='$Lang::tr{'reload'}' src='/images/view-refresh.png' />
204 <tr><td colspan='2' align='left'><pre>
206 my @output = `grep pakfire /var/log/messages | tail -20`;
215 &Header
::closebigbox
();
216 &Header
::closepage
();
221 my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`;
222 chomp($core_release);
223 my $core_update_age = &General
::age
("/opt/pakfire/db/core/mine");
224 my $corelist_update_age = &General
::age
("/opt/pakfire/db/lists/core-list.db");
225 my $server_update_age = &General
::age
("/opt/pakfire/db/lists/server-list.db");
226 my $packages_update_age = &General
::age
("/opt/pakfire/db/lists/packages_list.db");
228 &Header
::openbox
("100%", "center", "Pakfire");
231 <table width='95%' cellpadding='5' >
232 <tr><td width="50%" bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire system state'}:</b>
234 <tr><td align="center">$Lang::tr{'pakfire core update level'}: $core_release<hr />
235 $Lang::tr{'pakfire last update'} $core_update_age ago<br />
236 $Lang::tr{'pakfire last serverlist update'} $server_update_age ago<br />
237 $Lang::tr{'pakfire last core list update'} $corelist_update_age ago<br />
238 $Lang::tr{'pakfire last package update'} $packages_update_age ago
239 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
240 <input type='hidden' name='ACTION' value='update' />
241 <input type='submit' value='$Lang::tr{'calamaris refresh list'}' /><br />
244 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
245 <select name="UPDPAKS" size="5" disabled>
247 &Pakfire
::dblist
("upgrade", "forweb");
251 <input type='hidden' name='ACTION' value='upgrade' />
252 <input type='image' alt='$Lang::tr{'upgrade'}' src='/images/document-save.png' />
255 <tr><td colspan="2"><!-- Just an empty line -->
256 <tr><td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire available addons'}</b>
257 <td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire installed addons'}</b>
258 <tr><td align="center">
259 <p>$Lang::tr{'pakfire install description'}</p>
260 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
261 <select name="INSPAKS" size="10" multiple>
263 &Pakfire
::dblist
("notinstalled", "forweb");
268 <input type='hidden' name='ACTION' value='install' />
269 <input type='image' alt='$Lang::tr{'install'}' src='/images/list-add.png' />
273 <p>$Lang::tr{'pakfire uninstall description'}</p>
274 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
275 <select name="DELPAKS" size="10" multiple>
278 &Pakfire
::dblist
("installed", "forweb");
283 <input type='hidden' name='ACTION' value='remove' />
284 <input type='image' alt='$Lang::tr{'remove'}' src='/images/list-remove.png' />
290 &Header
::openbox
("100%", "center", "$Lang::tr{'settings'}");
293 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
295 <tr><td colspan='2' bgcolor='$color{'color20'}'><b>$Lang::tr{'basic options'}</b></td></tr>
296 <tr><td align='left' width='45%'>$Lang::tr{'pakfire update daily'}</td><td width="55%" align="left">
297 on <input type='radio' name='AUTOUPDATE' value='on' $checked{'AUTOUPDATE'}{'on'} /> |
298 <input type='radio' name='AUTOUPDATE' value='off' $checked{'AUTOUPDATE'}{'off'} /> off </td></tr>
299 <tr><td align='left' width='45%'>$Lang::tr{'pakfire core update auto'}</td><td align="left">
300 on <input type='radio' name='AUTOUPGRADE' value='on' $checked{'AUTOUPGRADE'}{'on'} /> |
301 <input type='radio' name='AUTOUPGRADE' value='off' $checked{'AUTOUPGRADE'}{'off'} /> off </td></tr>
302 <tr><td align='left' width='45%'>$Lang::tr{'pakfire health check'}</td><td align="left">
303 on <input type='radio' name='HEALTHCHECK' value='on' $checked{'HEALTHCHECK'}{'on'} /> |
304 <input type='radio' name='HEALTHCHECK' value='off' $checked{'HEALTHCHECK'}{'off'} /> off </td></tr>
305 <tr><td align='left' width='45%'>$Lang::tr{'pakfire register'}</td><td align="left">
306 on <input type='radio' name='UUID' value='on' $checked{'UUID'}{'on'} /> |
307 <input type='radio' name='UUID' value='off' $checked{'UUID'}{'off'} /> off </td></tr>
308 <tr><td colspan="2" align="center"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" /></td></tr>
314 &Header
::closebigbox
();
315 &Header
::closepage
();