Linux server.jmdstrack.com 3.10.0-1160.119.1.el7.tuxcare.els10.x86_64 #1 SMP Fri Oct 11 21:40:41 UTC 2024 x86_64
/ scripts/ |
|
#!/usr/bin/perl use strict; my $v = 1 if ($ARGV[0] =~ /^-(|-)(v|verbose)$/i); my $location = "/backup/cpbackup/sbr"; if ( !-d $location ) { print "SBnR folder not found.\n" if ( $v );; exit 0; } my %mounts = (); foreach my $mount ( `cat /proc/mounts` ) { next if ($mount !~ m/^archivemount\s+(\S+)\s/); $mounts{$1} = 1; } exit 0 and print "No SBnR mounts found.\n" if ( %mounts == () && $v ); my $user = ''; opendir(SBR, $location); foreach my $dir ( readdir SBR ) { next if ( $dir =~ m/^\./ ); $user = $1 if ($dir =~ m/^(\w+)\./); print "Checking $user in $location/$dir/$user\n" if ( $v ); if ( $mounts{"$location/$dir/$user/homedir"} ) { print "$dir/$user/homedir found, unmounting..." if ( $v ); system("umount -l $location/$dir/$user/homedir\n") == 0 or die "Can't unmount $location/$dir/$user/homedir\n"; print "done.\n" if ( $v ); } if ( $mounts{"$location/$dir"} ) { print "$dir found, unmounting..." if ( $v ); system("umount -l $location/$dir\n") == 0 or die "Can't unmount $location/$dir/$user/homedir\n"; print "done.\n" if ( $v ); } } closedir SBR;