#!/usr/bin/perl
#
# smount/unmount v1.1 - 08/26/91 - by Brendan Kehoe (brendan@cs.widener.edu)
# Based on a program by Emmet Hogan.
#
($program = $ARGV[0]) =~ s%.*/%%;

$ENV{'PATH'} = '/bin:/usr/etc';
$ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne '';
$ENV{'IFS'} = '' if $ENV{'IFS'} ne '';

#
# List of directories that anybody can mount and unmount:
#
%legal = ("/src",      "Source archive",
	  "/pcfs",     "MS-DOS Diskette [same as `$program floppy']",
	  "/cdrom",    "CD-Rom          [same as `$program cdrom']",
	  "/home/xy",  "The Xy Project",
	  "/home/foo", "FooBar Group" );
#
# If these are different on your system, change them:
#
$prog'mount = "/etc/mount";
$prog'umount = "/etc/umount";
$mnt'cdrom = "/cdrom";			# where your CD Rom mounts
$mnt'floppy = "/pcfs";			# Where your pcfs is set up to mount on
#
# -- You shouldn't have to change anything else --
sub smount'listem {
    print " Legal directories are:\n";
    foreach $dir (sort (keys legal)) { print "\t$dir\t\t($legal{$dir})\n"; }
}

$option = $ARGV[1];

if ($program eq "unmount") { $MOUNT = $prog'umount; }
else { $MOUNT = $prog'mount; }

if ( $option eq "-l" ) { &smount'listem; exit 0; }

exec($MOUNT, $mnt'cdrom) if $option eq "cdrom";
exec($MOUNT, $mnt'floppy) if $option eq "floppy";
if (! $legal{$option}) { print "Illegal directory!"; &smount'listem; exit 0; }
exec($MOUNT, $option) if $legal{$option};
