home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3565 / smount.pl < prev    next >
Encoding:
Perl Script  |  1991-07-03  |  1.3 KB  |  40 lines

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