MOON
Server: Apache
System: Linux vps.thepromohut.com 2.6.18-398.el5 #1 SMP Tue Sep 16 20:51:48 EDT 2014 i686
User: caretrak (507)
PHP: 5.2.10
Disabled: NONE
Upload Files
File: //scripts.20110601.041516.15411/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);
    }
}