sub check_mount {
my $x = shift;
my $mount_file = '/etc/mtab';
my $mount_point = 'fpfiles';
open FILE,"<$mount_file" or die "I cant open $mount_file\n$!\n";
my @lines = <FILE>;
close FILE;
foreach(@lines) {
print $_."\n";
if($_ =~ /$mount_point/gi) {
#if we find its mounted return, with good news if we were able to mount it
if($x > 1) {
print "The file system was not mounted, but the good news is I was able to mount it for you!! YAY me!!\n";
}
return 1;
}
#else its not
else {
if($x == 2) {
die("There is some kind of weird problem. fpfiles from MHI isnt mounted, and I cant seem to mount it.\nPlease come fix it now!!\n");
}
#try to mount it
my @args = ("mount", "-a");
system(@args) == 0 or die "system @args failed: $?";
$x++;
check_mount($x);
}
}
}
=> perl reboot_vmware.pl
/dev/mapper/VolGroup00-LogVol00 / ext3 rw 0 0
/dev/mapper/VolGroup00-LogVol00 / ext3 rw 0 0
There is some kind of weird problem. fpfiles from MHI isnt mounted, and I cant seem to mount it.
Please come fix it now!!