home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume22 / smount1.1 / part01 / smount.pl < prev    next >
Perl Script  |  1991-08-28  |  1KB  |  45 lines

  1. #!/usr/bin/perl
  2. #
  3. # smount/unmount v1.1 - 08/26/91 - by Brendan Kehoe (brendan@cs.widener.edu)
  4. # Based on a program by Emmet Hogan.
  5. #
  6. ($program = $ARGV[0]) =~ s%.*/%%;
  7.  
  8. $ENV{'PATH'} = '/bin:/usr/etc';
  9. $ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne '';
  10. $ENV{'IFS'} = '' if $ENV{'IFS'} ne '';
  11.  
  12. #
  13. # List of directories that anybody can mount and unmount:
  14. #
  15. %legal = ("/src",      "Source archive",
  16.       "/pcfs",     "MS-DOS Diskette [same as `$program floppy']",
  17.       "/cdrom",    "CD-Rom          [same as `$program cdrom']",
  18.       "/home/xy",  "The Xy Project",
  19.       "/home/foo", "FooBar Group" );
  20. #
  21. # If these are different on your system, change them:
  22. #
  23. $prog'mount = "/etc/mount";
  24. $prog'umount = "/etc/umount";
  25. $mnt'cdrom = "/cdrom";            # where your CD Rom mounts
  26. $mnt'floppy = "/pcfs";            # Where your pcfs is set up to mount on
  27. #
  28. # -- You shouldn't have to change anything else --
  29. sub smount'listem {
  30.     print " Legal directories are:\n";
  31.     foreach $dir (sort (keys legal)) { print "\t$dir\t\t($legal{$dir})\n"; }
  32. }
  33.  
  34. $option = $ARGV[1];
  35.  
  36. if ($program eq "unmount") { $MOUNT = $prog'umount; }
  37. else { $MOUNT = $prog'mount; }
  38.  
  39. if ( $option eq "-l" ) { &smount'listem; exit 0; }
  40.  
  41. exec($MOUNT, $mnt'cdrom) if $option eq "cdrom";
  42. exec($MOUNT, $mnt'floppy) if $option eq "floppy";
  43. if (! $legal{$option}) { print "Illegal directory!"; &smount'listem; exit 0; }
  44. exec($MOUNT, $option) if $legal{$option};
  45.