#!/usr/bin/perl ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2007-2011 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # # # ############################################################################### use strict; # enable only the following on debugging purpose #use warnings; #use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; require "/opt/pakfire/lib/functions.pl"; my %cgiparams=(); my $errormessage = ''; my %color = (); my %pakfiresettings = (); my %mainsettings = (); &Header::showhttpheaders(); $cgiparams{'ACTION'} = ''; $cgiparams{'VALID'} = ''; $cgiparams{'INSPAKS'} = ''; $cgiparams{'DELPAKS'} = ''; sub refreshpage{&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'pagerefresh'}
";&Header::closebox();} &Header::getcgihash(\%cgiparams); &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color); &Header::openpage($Lang::tr{'pakfire configuration'}, 1); &Header::openbigbox('100%', 'left', '', $errormessage); if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) { $cgiparams{'INSPAKS'} =~ s/\|/\ /g; if ("$cgiparams{'FORCE'}" eq "on") { &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", $cgiparams{'INSPAKS'}); } else { &Header::openbox("100%", "center", $Lang::tr{'request'}); my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", $cgiparams{'INSPAKS'}); print <$Lang::tr{'pakfire install package'}.$cgiparams{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'}
END
		foreach (@output) {
		  $_ =~ s/\\[[0-1]\;[0-9]+m//g;
			print "$_\n";
		}
		print <
		$Lang::tr{'pakfire accept all'}
		 
		
END &Header::closebox(); &Header::closebigbox(); &Header::closepage(); exit; } } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) { $cgiparams{'DELPAKS'} =~ s/\|/\ /g; if ("$cgiparams{'FORCE'}" eq "on") { &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", $cgiparams{'DELPAKS'}); } else { &Header::openbox("100%", "center", $Lang::tr{'request'}); my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", $cgiparams{'DELPAKS'}); print <$Lang::tr{'pakfire uninstall package'}.$cgiparams{'DELPAKS'}.$Lang::tr{'pakfire possible dependency'}
END
		foreach (@output) {
		  $_ =~ s/\\[[0-1]\;[0-9]+m//g;
			print "$_\n";
		}
		print <
		$Lang::tr{'pakfire uninstall all'}
		 
		
END &Header::closebox(); &Header::closebigbox(); &Header::closepage(); exit; } } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) { &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) { &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors"); } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") { $pakfiresettings{"TREE"} = $cgiparams{"TREE"}; # Check for valid input if ($pakfiresettings{"TREE"} !~ m/^(stable|testing|unstable)$/) { $errormessage .= $Lang::tr{'pakfire invalid tree'}; } unless ($errormessage) { &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings); # Update lists &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors"); } } &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings); my %selected=(); my %checked=(); $selected{"TREE"} = (); $selected{"TREE"}{"stable"} = ""; $selected{"TREE"}{"testing"} = ""; $selected{"TREE"}{"unstable"} = ""; $selected{"TREE"}{$pakfiresettings{"TREE"}} = "selected"; # DPC move error message to top so it is seen! if ($errormessage) { &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); print "$errormessage \n"; &Header::closebox(); } if (-e $Pakfire::lockfile) { &Header::openbox( 'Waiting', 1, "" ); print < $Lang::tr{  $Lang::tr{'pakfire working'}
END my @output = `grep pakfire /var/log/messages | tail -20`; foreach (@output) { print "$_
"; } print < END &Header::closebox(); &Header::closebigbox(); &Header::closepage(); exit; refreshpage(); } my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`; chomp($core_release); my $core_update_age = &General::age("/opt/pakfire/db/core/mine"); my $corelist_update_age = &General::age("/opt/pakfire/db/lists/core-list.db"); my $server_update_age = &General::age("/opt/pakfire/db/lists/server-list.db"); my $packages_update_age = &General::age("/opt/pakfire/db/lists/packages_list.db"); &Header::openbox("100%", "center", "Pakfire"); print < END if ( -e "/var/run/need_reboot") { print "$Lang::tr{'needreboot'}!"; print " " } print <$Lang::tr{'pakfire system state'}: $Lang::tr{'available updates'}: $Lang::tr{'pakfire core update level'}: $core_release
$Lang::tr{'pakfire last update'} $core_update_age $Lang::tr{'pakfire ago'}
$Lang::tr{'pakfire last serverlist update'} $server_update_age $Lang::tr{'pakfire ago'}
$Lang::tr{'pakfire last core list update'} $corelist_update_age $Lang::tr{'pakfire ago'}
$Lang::tr{'pakfire last package update'} $packages_update_age $Lang::tr{'pakfire ago'}



  $Lang::tr{'pakfire available addons'} $Lang::tr{'pakfire installed addons'}

$Lang::tr{'pakfire install description'}

$Lang::tr{'pakfire uninstall description'}

END &Header::closebox(); &Header::openbox("100%", "center", "$Lang::tr{'settings'}"); print <
$Lang::tr{'pakfire tree'}
 
END &Header::closebox(); &Header::closebigbox(); &Header::closepage();