home *** CD-ROM | disk | FTP | other *** search
- #!/pub/local/bin/perl
- # Generic Install Script in Perl
- # Written by Mark C. Carroll
- # version 1: completed Oct 15, 1989
- %Install=();
- ="no";
-
- # Beginning of Parameter Setting Code.
- @stuff=("graph3d1.sh","graph3d2.sh","bs");
- =&PackNames(@stuff);
- do SetGroupParams("3d","3d","mccarrol","studsys",0644,0755,@stuff);
-
- # Beginning of standard code. Do not change after this line.
- # First, make sure the person installing is root:
- die "Install: you must be root to Install\n" unless ("$>" eq "0");
- local ();
-
- # Then, install each filegroup
- foreach ( @InstallNames ) {
- print "Install : installing \n";
- &InstallGroup();
- }
-
- sub PackNames {
- # pack names into a string of the form "name:name:name"
- local (@namearray)=@_;
- local ();
-
- =join(':',@namearray);
- return ;
- }
-
-
- sub SetGroupParams {
- local (,,,,,,@files)=@_;
- local (,,);
- =&GetUid();
- =&GetGid();
- {,"owner"} = ;
- {,"group"} = ;
- {,"location"} = ;
- {,"filemode"} = ;
- {,"dirmode"} = ;
- =&PackNames(@files);
- {,"files"} = ;
- push(@InstallNames,);
- }
-
- sub GetUid {
- local ()=@_;
- local (,,);
- open(pass,'/etc/passwd') || die "Install: Can't get uids\n";
- while (<pass>) {
- (,,)=split(/:/);
- if ( eq ) {
- close pass;
- return ;
- }
- }
- close pass;
- die "Install; can't find uid of \n";
- }
-
- sub GetGid {
- local ()=@_;
- local (,,);
-
- open(groups,"/etc/group") || die "Install; can't open group files\n";
- while (<groups>) {
- (,,)=split(/:/);
- if ( eq ) {
- close groups;
- return ;
- }
- }
- close groups;
- die "Install; can't find group id of \n";
- }
-
-
- sub InstallGroup {
- local ()=@_;
-
- local (@files)=split(/:/,{,"files"});
- local ()=({,"owner"});
- local ()=({,"group"});
- local ()=({,"location"});
- local ()=({,"filemode"});
- local ()=({,"dirmode"});
- if ("" eq "yes") {
- print "Installation Information on :\n";
- print " Owner: \n";
- print " Group: \n";
- print " Destination: \n";
- print " File mode: \n";
- print " Dir mode: \n";
- print " Files:\n";
- foreach ( @files ) { print " \n"; }
- }
- unless ( -e ) {
- print "Directory does not exist. Should I create it? ";
- =<STDIN>;
- die "Install: installation directory does not exist\n"
- unless ( =~ /[Yy]/) ;
- mkdir(,);
- chown ,,;
- }
- @fullfiles=();
- foreach ( @files ) {
- = . "/" . ;
- if ( -e ) {
- system("cp ");
- push(@fullfiles,);
- }
- else {
- print "Install: file in group not found\n";
- }
- }
- chown ,,@fullfiles;
- chmod ,@fullfiles;
- }
-
-