#!/usr/bin/perl

# MountAdd  (c) Copyright 1998 Mark Black 

$version = 0.16 ;

# MountAdd
# This script is called to add a new mounted filesystem.
# The input is the name of the filesytem to mount.

($inp) = @ARGV ;

# Output the version if requested
if($inp eq "-v") {
    print "$version\n" ;
    exit(0) ;
}

# Make the mount point if necessary
if( -d $inp ) {
    # Directory exists, now mount it

} else {
    # Directory does not exist
    if( -e $inp ) {
	print "ERROR:  Mountpoint is an already existing file!\n" ;
	exit -1 ;
    } else {
	# Make the directory
	`mkdir -p $inp 2>/dev/null` ;
	if( $? ) {
	    print "ERROR:  Cannot make the necessary mount point" ;
	    exit -1 ;
	}

	# Mount the filesystem
	`mount $inp` ;
	if( $? ) {
	    print "ERROR:  Unable to mount $inp.  Reason:  $! \n" ;
	    exit -1 ;
	}
    }
}
	    
exit 0 ;





