File: //proc/self/root/scripts.20110531.215904.25158/getfreemount.pl
#!/usr/bin/perl
# cpanel - getfreemount.pl Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use Cpanel::Config ();
## case 34397 deprecation: delete this file completely
sub getmntpoint {
my $wwwacct_ref = Cpanel::Config::loadwwwacctconf();
my $homedir = $wwwacct_ref->{'HOMEDIR'};
my $homematch = $wwwacct_ref->{'HOMEMATCH'};
$disk = `df`;
my $max = 0;
my $mnt = "/";
my (@DISK) = split( /\n/, $disk );
my $addline = '';
foreach $line (@DISK) {
if ( $line !~ /[\s|\t]+/ ) {
$addline = $line;
$addline =~ s/\n//g;
next;
}
if ( $line =~ m/^\/dev/ || $addline ne "" ) {
$line =~ s/\n//g;
$line =~ m/ (\d*)\s*\d*\%\s*(\S+)$/;
my $free = $1;
my $mount = $2;
my $assess = 1;
if ( ( $mount eq "/" ) && ( $homedir eq 0 ) ) {
$assess = 0;
}
$free = int($free);
$max = int($max);
if ( ( $max < $free ) && ( $assess eq 1 ) && ( $mount =~ /$homematch/ || $mount eq "/" ) ) {
$max = $free;
if ( $mount eq "/" ) {
$mount = $homedir;
}
$mnt = $mount;
}
}
}
if ( $mnt eq "" || $mnt eq "/" ) { $mnt = '/home'; }
return $mnt;
}
1;