Annotation of loncom/build/postinstall.pl, revision 1.4

1.1       harris41    1: #!/usr/bin/perl
                      2: 
                      3: # A post-installation script
                      4: # to finalize a LON-CAPA
                      5: # installation.
                      6: 
1.2       harris41    7: # set /etc/hosts.deny to be ALL: ALL
                      8: open OUT, ">/etc/hosts.deny";
                      9: print OUT "ALL: ALL\n";
                     10: close OUT;
                     11: 
                     12: # get wget and install
                     13: system('lynx -source http://install.lon-capa.org/3.1/SupplementalRPMS/wget-1.5.3-6.i386.rpm > wget-1.5.3-6.i386.rpm');
                     14: system('rpm','-Uvh','--force','wget-1.5.3-6.i386.rpm');
                     15: 
                     16: # download SupplementalRPMS and install
                     17: system('wget','-r','http://install.lon-capa.org/3.1/SupplementalRPMS');
                     18: system('rpm','-Uvh','--force','install.lon-capa.org/3.1/SupplementalRPMS');
                     19: 
                     20: # download remove_extra.sh and run
                     21: system('wget','http://install.lon-capa.org/3.1/scripts/remove_extra.sh');
                     22: system('sh','./remove_extra.sh');
                     23: 
                     24: # download FinalRPMS and install
                     25: system('wget','-r','http://install.lon-capa.org/3.1/FinalRPMS');
                     26: system('rpm','-Uvh','--force','install.lon-capa.org/3.1/FinalRPMS');
                     27: 
1.1       harris41   28: # allow entry of new access.conf parameters
1.2       harris41   29: my @perlsetvars=("lonHostID","lonRole","lonAdmEMail","lonDefDomain","lonLoadLim","lonExpire");
                     30: my %psvinfo=(
                     31: 	     "lonHostID" => <<END
                     32: LON Host ID is an internal ID within the LON-CAPA
                     33: network used to specify the uniqueness of a particular
                     34: LON-CAPA server.  Current examples include "msul1", "msua3",
                     35: "103l1", "fsul1", and "107a1".
                     36: END
                     37: ,	     "lonRole" => <<END
                     38: LON Role specifies the role this machine plays within
                     39: the LON-CAPA network.  There are two valid values for
                     40: this:
                     41:  * library
                     42:  * access
                     43: END
                     44: ,	     "lonAdmEMail" => <<END
                     45: LON System Administrator E-Mail specifies the e-mail
                     46: address of an institutional member responsible for
                     47: direct upkeep of this server.
                     48: END
                     49: ,	     "lonDefDomain" => <<END
                     50: LON Domain is a unique internal identifier within the LON-CAPA network
                     51: specific to the home institution.  Current examples include
                     52: "msu", "fsu", "103", and "107".
                     53: END
                     54: ,	     "lonLoadLim" => <<END
                     55: LON Load Limit specifies a threshold of activity within The Learning
                     56: Online Network that this machine should provide.  We strongly recommend
                     57: a value of 2.00.  Depending on processor architecture (dual processor),
                     58: this value may be increased, but there is no readily available measure
                     59: in this regard.
                     60: END
                     61: ,	     "lonExpire" => <<END
                     62: LON Expiration Time indicates, in seconds, how long distributed resources
                     63: should be held in the server's cache when not being accessed by students,
                     64: instructors, or any other class of user.  We recommend a value of 86400.
                     65: END
                     66: 	     );
                     67: my $template=`/bin/cat /etc/httpd/conf/access.conf`;
                     68: my $okay=0;
                     69: while ($okay==0) {
                     70:     foreach my $psv (@perlsetvars) {
                     71:         print "\n";
                     72:         print $psvinfo{$psv};
                     73:         print "\nEnter in value for $psv: "; my $input=<>; chop $input;
                     74:         my $pval=$input;
                     75:         $template=~s/(\nPerlSetVar\s+$psv\s+)\S+/$1$pval/;
                     76:         $pvar{$psv}=$pval;
                     77:     }
                     78:     print "\n\nThese are the current values:\n";
                     79:     foreach my $psv (@perlsetvars) {
                     80:         print "$psv\t\t$pvar{$psv}\n";
                     81:     }
                     82:     print "Are these correct? (y/n)";
                     83:     my $input=<>;
                     84:     if ($input=~/^y/i) {
                     85:         $okay=1;
                     86:     }
                     87: }
                     88: open OUT,">/etc/httpd/conf/access.conf";
                     89: print OUT $template;
                     90: close OUT;
                     91: 
                     92: $template=`/bin/cat /etc/smb.conf`;
                     93: foreach my $psv (@perlsetvars) {
                     94:     $template=~s/\{\{\{\{\[(.*?)\]\}\}\}\}/$pvar{$1}/ge;
                     95: }
                     96: open OUT,">/etc/smb.conf";
                     97: print OUT $template;
                     98: close OUT;
1.4     ! harris41   99: 
1.1       harris41  100: # unshadow passwords
1.2       harris41  101: # change this line in /etc/pam.d/login
                    102: # password   required     /lib/security/pam_pwdb.so nullok use_authtok md5 shadow
                    103: $template=`/bin/cat /etc/pam.d/login`;
                    104: $template=~s|password   required     /lib/security/pam_pwdb\.so nullok use_authtok md5 shadow|password   required     /lib/security/pam_pwdb.so nullok use_authtok|;
                    105: open OUT, ">/etc/pam.d/login";
                    106: print OUT $template;
                    107: close OUT;
                    108: # change this line in /etc/pam.d/passwd
                    109: # password   required     /lib/security/pam_pwdb.so use_authtok nullok md5 shadow 
                    110: $template=`/bin/cat /etc/pam.d/passwd`;
                    111: $template=~s|password   required     /lib/security/pam_pwdb\.so nullok use_authtok md5 shadow|password   required     /lib/security/pam_pwdb.so nullok use_authtok|;
                    112: open OUT, ">/etc/pam.d/passwd";
                    113: print OUT $template;
                    114: close OUT;
                    115: `/usr/sbin/pwunconv`;
                    116: `/usr/sbin/grpunconv`;
                    117: # set new passwords
                    118: print "Now we need to have passwords entered in order to unshadow this machine.\n";
                    119: system('stty -echo');
                    120: $okay=0;
                    121: my $input1;
                    122: my $input2;
                    123: while ($okay==0) {
                    124:     print "Enter in password for root: ";
                    125:     $input1=<>; chop $input1;
                    126:     print "\nEnter in password again for root: ";
                    127:     $input2=<>; chop $input2;
                    128:     if ($input1 ne $input2) {
                    129:         print "\nPasswords do not match, try again.\n";
                    130:     }
                    131:     else {
                    132:         $okay=1;
                    133:     }
                    134: }
                    135: open OUT, "|/usr/sbin/chpasswd";
                    136: print OUT "root:$input1\n";
                    137: close OUT;
                    138: 
                    139: $okay=0;
                    140: while ($okay==0) {
                    141:     print "\nEnter in password for www: ";
                    142:     $input1=<>; chop $input1;
                    143:     print "\nEnter in password again for www: ";
                    144:     $input2=<>; chop $input2;
                    145:     if ($input1 ne $input2) {
                    146:         print "\nPasswords do not match, try again.\n";
                    147:     }
                    148:     else {
                    149:         $okay=1;
                    150:     }
                    151: }
                    152: open OUT, "|/usr/sbin/chpasswd";
                    153: print OUT "www:$input1\n";
                    154: close OUT;
                    155: system('stty echo');
                    156: 
1.1       harris41  157: # create mime.types link
1.2       harris41  158: `ln -s /etc/mime.types /etc/httpd/conf/mime.types`;
                    159: 
1.1       harris41  160: # restart network and inet services
1.2       harris41  161: system('/etc/rc.d/init.d/network','reload');
                    162: system('/etc/rc.d/init.d/inet','restart');
1.1       harris41  163: # restart httpd
1.2       harris41  164: system('/etc/rc.d/init.d/httpd','restart');
                    165: 
                    166: # fix the setup of init.d processes
                    167: # nfs
1.3       harris41  168: # bash$ diff nfs nfs~
                    169: # 6c6
                    170: # < # chkconfig: 345 60 20
                    171: # ---
                    172: # > # chkconfig: - 60 20
                    173: # then chkconfig
1.4     ! harris41  174: $template=`/bin/cat /etc/rc.d/init.d/nfs`;
        !           175: $template=~s/\# chkconfig: - 60 20/\# chkconfig: 345 60 20/;
        !           176: open OUT,">/etc/rc.d/init.d/nfs";
        !           177: print OUT $template;
        !           178: close OUT;
        !           179: $template=`/bin/cat /etc/rc.d/init.d/xntpd`;
        !           180: $template=~s/\# chkconfig: - 55 10/\# chkconfig: 345 55 10/;
        !           181: open OUT,">/etc/rc.d/init.d/xntpd";
        !           182: print OUT $template;
        !           183: close OUT;
1.3       harris41  184: 
                    185: # ntp
                    186: # chkconfig 345
                    187: # then chkconfig
                    188: 
1.2       harris41  189: # make atalk specific modifications
1.3       harris41  190: # /etc/atalk/config
                    191: open OUT, ">/etc/atalk/config";
                    192: print OUT <<END;
                    193: # Appletalk configuration
                    194: # Change this to increase the maximum number of clients that can connect:
                    195: AFPD_MAX_CLIENTS=5
                    196: # Change this to set the machine's atalk name:
                    197: # ATALK_NAME=`echo \${HOSTNAME}|cut -d. -f1`
                    198: ATALK_NAME=`grep '^PerlSetVar.*lonHostID' /etc/httpd/conf/access.conf | perl -e '\$_=<>; split(/\s+/); print "LONCAPA_\$_[2]";
                    199: '`
                    200: # Set which daemons to run:
                    201: PAPD_RUN=no
                    202: AFPD_RUN=yes
                    203: # Control whether the daemons are started in the background
                    204: ATALK_BGROUND=no
                    205: END
                    206: close OUT;
                    207: # /etc/conf.modules should have this line
                    208: #      alias net-pf-5 appletalk
                    209: # depmod -a
                    210: $template=`/bin/cat /etc/conf.modules`;
                    211: $template.="alias net-pf-5 appletalk\n";
                    212: open OUT, ">/etc/conf.modules";
                    213: print OUT $template;
                    214: close OUT;
                    215: system('depmod -a');
1.2       harris41  216: 
1.4     ! harris41  217: # restart nfs, smb, xntpd and atalk services
1.2       harris41  218: system('/etc/rc.d/init.d/smb','restart');
                    219: system('/etc/rc.d/init.d/atalk','restart');
1.3       harris41  220: system('/etc/rc.d/init.d portmap','stop');
                    221: system('/etc/rc.d/init.d nfs','stop');
                    222: system('/etc/rc.d/init.d portmap','start');
                    223: system('/etc/rc.d/init.d nfs','start');
                    224: system('/etc/rc.d/init.d/smb','restart');
                    225: system('/etc/rc.d/init.d/inet','restart');
1.4     ! harris41  226: system('/etc/rc.d/init.d/xntpd','restart');
1.2       harris41  227: 
1.1       harris41  228: # restart loncontrol
1.2       harris41  229: print "Please be patient while loncontrol services are restarted (approximately 10 minutes).\n";
                    230: system('/etc/rc.d/init.d/loncontrol','restart');
                    231: 
1.1       harris41  232: # warn about /etc/hosts.allow
1.2       harris41  233: print <<END;
                    234: Final note:  Currently your machine is set-up
                    235: to disable many different kinds of network
                    236: connectivity.  To enable network connectivity
                    237: different than that needed for LON-CAPA, you
                    238: must make appropriate adjustment to the
                    239: /etc/hosts.allow file.
                    240: END

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>