Revision: 6205 http://ipcop.svn.sourceforge.net/ipcop/?rev=6205&view=rev Author: owes Date: 2012-01-02 16:25:19 +0000 (Mon, 02 Jan 2012) Log Message: ----------- Add diskspace test when autoloading update packages.
Modified Paths: -------------- ipcop/trunk/src/libs/general-functions.pl ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 Modified: ipcop/trunk/src/libs/general-functions.pl =================================================================== --- ipcop/trunk/src/libs/general-functions.pl 2012-01-01 09:10:14 UTC (rev 6204) +++ ipcop/trunk/src/libs/general-functions.pl 2012-01-02 16:25:19 UTC (rev 6205) @@ -22,7 +22,7 @@ # Copyright (c) 2002/04/13 Steve Bootes - add alias section, helper functions # Copyright (c) 2002/08/23 Mark Wormgoor <m...@wormgoor.com> validfqdn() # Copyright (c) 2003/09/11 Darren Critchley <darr...@telus.net> srtarray() -# Copyright (c) 2004-2011 The IPCop Team +# Copyright (c) 2004-2012 The IPCop Team # # $Id$ # @@ -961,6 +961,25 @@ } # +# Get available space on partition in MiB. +# Return space on /root if called without parameter. +# +sub getavailabledisk +{ + my $where = '/root'; + $where = shift if (defined($_[0])); + + open(XX, "/bin/df -B M $where | grep -v Filesystem |"); + my $df = <XX>; + close(XX); + my ($device, $size, $used, $free, $percent) = split(' ', $df); + $free =~ m/^(\d+)M$/; + $free = $1; + + return $free; +} + +# # Translate interface # sub translateinterface @@ -1112,6 +1131,8 @@ # 1 RED is down # 2 problem opening patches/available # 3 problem downloading +# 4 installpackage in downloadpatch() returned an error... Look in the log for details. +# 5 not enough diskspace sub downloadpatchlist { if (! -e '/var/ipcop/red/active') { @@ -1168,12 +1189,23 @@ if (($preload eq 'on') && (${General::version} ne $available->{"latest"})) { my $number = 0; my $done = 0; + my $ret = 0; $version = $available->{"update-${General::version}"}->{nextversion}; while (($number < 10) && ! $done) { - # TODO: add disk space test + # installpackage wants 2 * update size + 1,5 MiB. + # So we will need at least 3 * size + 1,5 MiB before update. + my $spacerequired = int($available->{"update-$version"}->{size} / 1024) * 3 + 2; + my $free = getavailabledisk('/var/patches'); + if ($spacerequired > $free) { + &General::log("Not enough diskspace to download update, required is $spacerequired MiB."); + return 5; + } - downloadpatch($version, 0); + $ret = downloadpatch($version, 0); + return 1 if ($ret == 32); + return 3 if ($ret == 33); + return 4 if ($ret != 0); if (defined($available->{"update-$version"}->{latest})) { $done = 1; Modified: ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 =================================================================== --- ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 2012-01-01 09:10:14 UTC (rev 6204) +++ ipcop/trunk/updates/2.0.3/ROOTFILES.i486-2.0.3 2012-01-02 16:25:19 UTC (rev 6205) @@ -9,6 +9,7 @@ /home/httpd/cgi-bin/updates.cgi /home/httpd/cgi-bin/urlfilter.cgi /home/httpd/vhost81/cgi-bin/redirect.cgi +/usr/lib/ipcop/general-functions.pl /usr/lib/ipcop/header.pl /usr/lib/ipcop/library.sh /usr/local/bin/makesquidconf This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ Ipcop-svn mailing list Ipcop-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipcop-svn