MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/proc/self/root/scripts.20110531.215904.25158/mount_cleanup
#!/usr/bin/perl
# cpanel12 - mount_cleanup                        Copyright(c) 2006 cPanel, Inc.
#                                                           All Rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

my $proc_mounts = '/proc/mounts';

exit if !-e $proc_mounts;

my $clean_all_virtfs = @ARGV && $ARGV[0] =~ m/force/i ? 1 : 0;

my %mounts;
if ( open my $mount_fh, '<', $proc_mounts ) {
    while ( my $line = readline $mount_fh ) {
        if ( $line =~ m/^\S+\s+(\S+)/ ) {
            my $target = $1;
            if ( exists $mounts{$target} ) {
                $mounts{$target}++;
                next;
            }
            next if !-d $target;
            $mounts{$target} = 1;
        }
    }
    close $mount_fh;
}

foreach my $mount ( keys %mounts ) {
    next if $mount !~ m/^\S+\/virtfs\//;
    my $start = 2;
    if ($clean_all_virtfs) {
        $start = 1;
    }
    else {
        next if $mounts{$mount} < 2;
    }
    foreach my $count ( $start .. $mounts{$mount} ) {
        system 'umount', $mount;
    }
}