#!/usr/bin/perl
$version = 2 ;

# nfsModMount - Modify a mounted filesystem.
#               Unmount the old filesystem if possible, and mount the
#               new one.  The data passed is the old, and new filesystems.

# --- Initialization ---
# Deal with possible spaces in the input 
foreach $i (0 .. $#ARGV) {
   $data .= "@ARGV[$i] " ;
}
chop($data) ;

if($data eq "-v") {
    print "$version\n" ;
    exit(0) ;
}
 
($OLDMNT, $NEWMNT) = split(/\s+/, $data, 7) ;
print "Running site specific mount modify script\n" ;
print "Old mount point = '$OLDMNT'\n" ;
print "New mount point = '$NEWMNT'\n" ;

# Make the directory
if ( ! -d $NEWMNT ) {
    `mkdir -p $NEWMNT` ;
}

# Discover OS type and run the appropriate command
chop($os = `uname -s`) ;

if($os eq "Linux") {
    $OS="linux" ;
    `umount $OLDMNT` ;
    `mount $NEWMNT` ;

} elsif($os eq "SunOS") {
    chop($ver = `uname -r`) ;
    ($major, $minor) = split(/\./, $ver) ;
    if($major == 5) {
        $OS = "solaris" ;
	`umount $OLDMNT` ;
	`mount $NEWMNT` ;
    } else {
        $OS = "sunos" ;
	`umount $OLDMNT` ;
	`mount $NEWMNT` ;
    }

} elsif(($os eq "IRIX") | ($os eq "IRIX64"))  {
    $OS="irix" ;
    `umount $OLDMNT` ;
    `mount $NEWMNT` ;
} elsif($os eq "HP-UX") {
    $OS="hpux" ;
    `umount $OLDMNT` ;
    `mount $NEWMNT` ;
}
print "Done\n" ;
exit 0 ;


