MOON
Server: Apache
System: Linux host.communityeducationproject.org 3.10.0-1160.105.1.vz7.214.3 #1 SMP Tue Jan 9 19:45:01 MSK 2024 i686
User: ohiobwc (508)
PHP: 5.6.23
Disabled: show_source, system, passthru, popen, proc_open, allow_url_fopen
Upload Files
File: //scripts/mount_cleanup
#!/usr/local/cpanel/3rdparty/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;
    }
}