home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-osu / Install / Install next >
Encoding:
Text File  |  1993-07-14  |  2.6 KB  |  123 lines

  1. #!/pub/local/bin/perl
  2. # Generic Install Script in Perl
  3. # Written by Mark C. Carroll
  4. # version 1: completed Oct 15, 1989
  5. %Install=();
  6. ="no";
  7.  
  8. # Beginning of Parameter Setting Code.
  9. @stuff=("graph3d1.sh","graph3d2.sh","bs");
  10. =&PackNames(@stuff);
  11. do SetGroupParams("3d","3d","mccarrol","studsys",0644,0755,@stuff);
  12.  
  13. # Beginning of standard code. Do not change after this line.
  14. # First, make sure the person installing is root:
  15. die "Install: you must be root to Install\n" unless ("$>" eq "0");
  16. local ();
  17.  
  18. # Then, install each filegroup
  19. foreach  ( @InstallNames ) {
  20.    print "Install : installing \n";
  21.    &InstallGroup();
  22. }
  23.  
  24. sub PackNames {
  25. # pack names into a string of the form "name:name:name"
  26.    local (@namearray)=@_;
  27.    local ();
  28.  
  29.    =join(':',@namearray);
  30.    return ;
  31. }
  32.  
  33.  
  34. sub SetGroupParams {
  35.    local (,,,,,,@files)=@_;
  36.    local (,,);
  37.    =&GetUid();
  38.    =&GetGid();
  39.    {,"owner"} = ;
  40.    {,"group"} = ;
  41.    {,"location"} = ;
  42.    {,"filemode"} = ;
  43.    {,"dirmode"} = ;
  44.    =&PackNames(@files);
  45.    {,"files"} = ;   
  46.    push(@InstallNames,);
  47. }
  48.  
  49. sub GetUid {
  50.   local ()=@_;
  51.   local (,,);
  52.   open(pass,'/etc/passwd') || die "Install: Can't get uids\n";
  53.   while (<pass>) {
  54.     (,,)=split(/:/);
  55.     if ( eq ) {
  56.       close pass;
  57.       return ;
  58.     }
  59.   }
  60.   close pass;
  61.   die "Install; can't find uid of \n";
  62. }
  63.  
  64. sub GetGid {
  65.    local ()=@_;
  66.    local (,,);
  67.  
  68.    open(groups,"/etc/group") || die "Install; can't open group files\n";
  69.    while (<groups>) {
  70.       (,,)=split(/:/);
  71.       if ( eq ) {
  72.          close groups;
  73.          return ;
  74.       }
  75.    }
  76.    close groups;
  77.    die "Install; can't find group id of \n";
  78. }
  79.  
  80.  
  81. sub InstallGroup {
  82.    local ()=@_;
  83.  
  84.    local (@files)=split(/:/,{,"files"});
  85.    local ()=({,"owner"});
  86.    local ()=({,"group"});
  87.    local ()=({,"location"});
  88.    local ()=({,"filemode"});
  89.    local ()=({,"dirmode"});
  90.    if ("" eq "yes") {
  91.       print "Installation Information on :\n";
  92.       print "   Owner: \n";
  93.       print "   Group: \n";
  94.       print "   Destination: \n";
  95.       print "   File mode: \n";
  96.       print "   Dir mode: \n";
  97.       print "   Files:\n";
  98.       foreach  ( @files ) { print "      \n"; }
  99.    }
  100.    unless  ( -e  ) {
  101.       print "Directory  does not exist. Should I create it? ";
  102.       =<STDIN>;
  103.       die "Install: installation directory  does not exist\n" 
  104.          unless ( =~ /[Yy]/) ;
  105.       mkdir(,);
  106.       chown ,,;
  107.    }
  108.    @fullfiles=();
  109.    foreach  ( @files ) {
  110.        =  . "/" . ;
  111.       if ( -e  ) {
  112.          system("cp  ");
  113.          push(@fullfiles,);
  114.       } 
  115.       else {
  116.          print "Install: file  in group  not found\n";
  117.       }
  118.    }
  119.    chown ,,@fullfiles;
  120.    chmod ,@fullfiles;
  121. }
  122.  
  123.