home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / hacking / internet / ftpm02.sh / inst.pl < prev    next >
Encoding:
Perl Script  |  1993-05-16  |  2.6 KB  |  107 lines

  1. #!/usr/bin/perl -s
  2. # Create the directories needed for ftpmail to work
  3. # By Lee McLoughlin <lmjm@doc.ic.ac.uk>
  4. #  You can do what you like with this except claim that you wrote it or
  5. #  give copies with changes not approved by Lee.  Neither Lee nor any other
  6. #  organisation can be held liable for any problems caused by the use or
  7. #  storage of this package.
  8. #
  9. # $Header: /a/swan/home/swan/staff/csg/lmjm/src/perl/mirror/ftpmail/RCS/inst.pl,v 1.7 1993/04/25 14:15:10 lmjm Exp lmjm $
  10. # $Log: inst.pl,v $
  11. # Revision 1.7  1993/04/25  14:15:10  lmjm
  12. # Allow for multiple help files (one per language).
  13. #
  14. # Revision 1.6  1993/04/23  23:27:05  lmjm
  15. # Massive renaming for sys5.
  16. #
  17. # Revision 1.5  1993/04/23  20:03:17  lmjm
  18. # Use own version of library routines before others.
  19. #
  20. # Revision 1.4  1993/04/23  17:23:39  lmjm
  21. # Renamed ftpmail-local-config.pl to ftpmail-config.pl
  22. # Made pathnames relative to $ftpmail_dir.
  23. #
  24. # Revision 1.3  1993/03/30  20:32:20  lmjm
  25. # Now requires an ftpmail account whose home directory everything is in
  26. # changed the -test option to use /tmp/ftpmail-test
  27. #
  28. # Revision 1.2  1993/03/23  21:40:12  lmjm
  29. # Cleaned up to use ftpmail's home and droped the .sh from the install.
  30. #
  31.  
  32. $ftpmail = 'ftpmail';
  33.  
  34. if( $test ){
  35.     $ftpmail_dir = '/tmp/ftpmail-test';
  36. }
  37. else {
  38.     # The ftpmail_dir is the home directory of ftpmail.
  39.     $ftpmail_dir = (getpwnam( $ftpmail ))[ 7 ];
  40.     $do_chown = 1;
  41. }
  42.  
  43.  
  44. mkdir( $ftpmail_dir, 0755 );
  45. print "mkdir $ftpmail_dir\n";
  46.  
  47. if( ! $ftpmail_dir ){
  48.     die "No home directory for ftpmail\n";
  49. }
  50.  
  51. if( ! -d $ftpmail_dir ){
  52.     die "no such directory as $ftpmail_dir\n";
  53. }
  54.  
  55. chop( $here = `pwd` );
  56.  
  57. chdir( $ftpmail_dir ) || die "cannot chdir to $ftpmail_dir\n";
  58.  
  59. unshift( @INC, $here );
  60.  
  61. require 'config.pl';
  62.  
  63. @dirs = ( $tmpdir, $quedir, $helpdir );
  64. @files = (
  65.     'q.pl',
  66.     'dq.pl',
  67.     'support.pl',
  68.     'config.pl',
  69.     'ftp.pl',
  70.     'chat2.pl',
  71.     'socket.ph',
  72.     $authfile );
  73. # All the help files are help_language
  74. @helpfiles = (
  75.     'help_english' );
  76.  
  77. foreach $dir ( @dirs ){
  78.     if( ! -d $dir ){
  79.         print "mkdir $dir\n";
  80.         if( ! mkdir( $dir, 0755 ) ){
  81.             die "Failed to create $dir";
  82.         }
  83.     }
  84. }
  85.  
  86. # Copy in the rest of the files
  87. print "Installing files\n";
  88. foreach $file ( @files ){
  89.     print "copying $file\n";
  90.     system( "cp $here/$file ." );
  91. }
  92. foreach $file ( @helpfiles ){
  93.     print "copying $file\n";
  94.     $f = $file;
  95.     # change help_english -> english
  96.     $f =~ s,help_,,;
  97.     system( "cp $here/$file $helpdir/$f" );
  98. }
  99. link( "$helpdir/english", "$helpdir/help" );
  100. system( "chmod 755 q.pl dq.pl" );
  101. if( $do_chown ){
  102.     $uid = (getpwnam( $ftpmail ))[ 2 ];
  103.     chown $uid, 0, @files;
  104.     chown $uid, 0, @dirs;
  105.     chown $uid, 0, $ftpmail_dir;
  106. }
  107.