]>
Commit | Line | Data |
---|---|---|
8dcebe53 SS |
1 | #!/usr/bin/perl -w |
2 | ############################################################################ | |
3 | # # | |
4 | # This file is part of the IPFire Firewall. # | |
5 | # # | |
6 | # IPFire is free software; you can redistribute it and/or modify # | |
7 | # it under the terms of the GNU General Public License as published by # | |
8 | # the Free Software Foundation; either version 2 of the License, or # | |
9 | # (at your option) any later version. # | |
10 | # # | |
11 | # IPFire is distributed in the hope that it will be useful, # | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
14 | # GNU General Public License for more details. # | |
15 | # # | |
16 | # You should have received a copy of the GNU General Public License # | |
17 | # along with IPFire; if not, write to the Free Software # | |
18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # | |
19 | # # | |
20 | # Copyright (C) 2018 IPFire Team <info@ipfire.org>. # | |
21 | # # | |
22 | ############################################################################ | |
23 | ||
24 | package IDS; | |
25 | ||
26 | require '/var/ipfire/general-functions.pl'; | |
27 | require "${General::swroot}/lang.pl"; | |
28 | ||
29 | # | |
30 | ## Function for checking if at least 300MB of free disk space are available | |
31 | ## on the "/var" partition. | |
32 | # | |
33 | sub checkdiskspace () { | |
34 | # Call diskfree to gather the free disk space of /var. | |
35 | my @df = `/bin/df -B M /var`; | |
36 | ||
37 | # Loop through the output. | |
38 | foreach my $line (@df) { | |
39 | # Ignore header line. | |
40 | next if $line =~ m/^Filesystem/; | |
41 | ||
42 | # Search for a line with the device information. | |
43 | if ($line =~ m/dev/ ) { | |
44 | # Split the line into single pieces. | |
45 | my @values = split(' ', $line); | |
46 | my ($filesystem, $blocks, $used, $available, $used_perenctage, $mounted_on) = @values; | |
47 | ||
48 | # Check if the available disk space is more than 300MB. | |
49 | if ($available < 300) { | |
50 | # If there is not enough space, print out an error message. | |
51 | my $errormessage = "$Lang::tr{'not enough disk space'} < 300MB, /var $available MB"; | |
52 | ||
53 | # Exit function and return the error message. | |
54 | return $errormessage; | |
55 | } | |
56 | } | |
57 | } | |
58 | ||
59 | # Everything okay, return nothing. | |
60 | return; | |
61 | } | |
62 | ||
63 | ||
64 | 1; |