File: //proc/self/root/proc/self/root/scripts.20110531.215904.25158/increase_filesystem_limits
#!/usr/bin/perl
# cpanel - increase_file_limits 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::LoadFile ();
use Cpanel::SafeRun::Simple ();
use Cpanel::FindBin ();
if ( $^O =~ m/freebsd/i ) {
my $sysctl_bin = Cpanel::FindBin::findbin('sysctl');
my $file_max = ( split( /\s+/, Cpanel::SafeRun::Simple::saferun( $sysctl_bin, 'kern.maxfiles' ) ) )[1];
if ( $file_max && $file_max < 131072 ) {
Cpanel::SafeRun::Simple::saferun( $sysctl_bin, 'kern.maxfiles=131072' );
exit;
}
}
my $file_max = Cpanel::LoadFile::loadfile('/proc/sys/fs/file-max');
if ( $file_max && $file_max < 131072 ) {
set_file_value( '/proc/sys/fs/file-max', 131072 );
}
my $file_max = Cpanel::LoadFile::loadfile('/proc/sys/fs/dquot-max');
if ( $file_max && $file_max < 16384 ) {
set_file_value( '/proc/sys/fs/dquot-max', 16384 );
}
exit;
sub set_file_value {
my $file = shift;
my $value = shift;
if ( open( my $fh, '>', $file ) ) {
print {$fh} $value;
close($fh);
}
}