#!/bin/sh # # This is the primary install script. It is called directly by the # install kernel. # # Alastair Scobie (May 1997, March 1999, Oct 99, Feb/Jun 00) # # Modified for LCFG installation tests at CERN. # Julian.Blake@cern.ch, July 2001. # # $Id: dcsrc,v 1.17 2002/03/25 08:35:15 blake Exp $ # # $Log: dcsrc,v $ # Revision 1.17 2002/03/25 08:35:15 blake # installroot-1.1-21.edg: dcsrc: Add Enrico Ferro's nointeract option. # # Revision 1.16 2002/03/05 16:10:43 blake # installroot-1.1-20.edg: dcsrc: Call bootpc with --dhcp option. # # Revision 1.15 2001/10/17 14:16:38 iven # error message in case Option-151 is missing. # # Revision 1.14 2001/10/02 07:27:35 blake # Create mount points /var/mnt/export/ and /var/mnt/usr/remote/. # # Revision 1.13 2001/09/27 14:36:03 blake # Julian.Blake@cern.ch, 2001/9/27: installroot-1.1-8.edg. # dcsrc: Mount repository file system ("/etc/obj/nfsmount install"). # nointeract=yes rcs_revision='$Revision: 1.17 $' rcs_author='$Author: blake $' rcs_date='$Date: 2002/03/25 08:35:15 $' echo echo "---------- Division of Informatics Redhat 6.2 install ---------- " echo " Version: $rcs_revision" echo " Date: $rcs_date" echo export PATH=$PATH:/sbin:/usr/sbin export TZ=UTC [ "$CONSOLE" ] || CONSOLE="/dev/console" if [ "`/sbin/consoletype`" = "vt" ] ; then DBGTERM=/dev/tty2 else DBGTERM=$CONSOLE fi /bin/mount -n /proc /proc -t proc 2> $DBGTERM #loadkeys uk > $DBGTERM 2>&1 echo "Making ramdisk for /var" > $DBGTERM 2>&1 /sbin/mke2fs /dev/ram1 > $DBGTERM 2>&1 /bin/mount -n /dev/ram1 /mnt > $DBGTERM 2>&1 rsync -a /var/. /mnt/. > $DBGTERM 2>&1 umount -n /mnt > $DBGTERM 2>&1 /bin/mount -n /dev/ram1 /var > $DBGTERM 2>&1 for a in obj/conf obj/log obj/status obj/tmp run \ tmp tmp/a mnt/export mnt/usr/remote do [ -d /var/$a ] || mkdir -p /var/$a > $DBGTERM 2>&1 done # do we need this ? Maybe for PCMCIA #mkdir /tmp/netreport echo "Initializing loopback" > $DBGTERM 2>&1 /sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 \ broadcast 127.255.255.255 > $DBGTERM 2>&1 /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo > $DBGTERM 2>&1 hostname=`hostname` > $DBGTERM 2>&1 echo "Our boot address is $hostname" > $DBGTERM 2>&1 # will need to upgrade to bash 2 for this - do we really need it ? #shopt -s execfail if [ "$hostname" = "(none)" ] ; then echo "We must be a laptop - starting pcmcia services" # Note: we *must* read from CONSOLE this way for some reason. PCICOPTS=`(read -p "Enter any pcmcia options [none] : " INPUT < $CONSOLE \ ; echo $INPUT)` kernelver=`uname -r` PC=/lib/modules/$kernelver/pcmcia insmod $PC/pcmcia_core.o > $DBGTERM 2>&1 insmod $PC/i82365.o $PCICOPTS > $DBGTERM 2>&1 insmod $PC/ds.o > $DBGTERM 2>&1 /sbin/cardmgr -o > $DBGTERM 2>&1 ifconfig eth0 > $DBGTERM 2>&1 if [ "$?" != 0 ] ; then echo "" echo "*** Install failed - no ethernet card found ***" /bin/sh fi echo "" echo "Configuring network interface (eth0)" /sbin/pump else # we're not a laptop ifconfig eth0 > $DBGTERM 2>&1 if [ "$?" != 0 ]; then echo "" echo "*** Install failed - no ethernet card could be found ***" /bin/sh fi fi IFACE=`route |grep eth | awk '{print $NF;}'|sort -u` echo "interface is $IFACE" > $DBGTERM 2>&1 # For some inexplicable reason "route" complains that the network # is down if we attempt to add a route straight away, so we loop # on this until successful... echo "checking for default route and network route" > $DBGTERM 2>&1 DEFAULT=`route|grep default| awk '{print $NF;}' ` > $DBGTERM 2>&1 echo "Default is $DEFAULT" > $DBGTERM 2>&1 if ! [ "$DEFAULT" ]; then res=1 cnt=1 while [ "$res" != 0 ]; do echo "Adding default route (attempt $cnt)" > $DBGTERM route add default $IFACE > $DBGTERM 2>&1 res=$? cnt=`expr $cnt + 1` usleep 500000 done fi echo "Making bootpc request......." bootpc --dhcp --returniffail --timeoutwait 30 \ --dev $IFACE 2> $DBGTERM > /var/tmp/bootp-response if [ "$?" != "0" ]; then echo "" echo "*** Install failure : No valid response for bootp request ***" /bin/sh fi . /var/tmp/bootp-response echo "Bootp response from $SERVER :-" > $DBGTERM echo "Domain = $DOMAIN" > $DBGTERM echo "Ipaddr = $IPADDR" > $DBGTERM echo "Netmask = $NETMASK" > $DBGTERM echo "Network = $NETWORK" > $DBGTERM echo "Broadcast = $BROADCAST" > $DBGTERM if [ "$GATEWAYS_1" ]; then GATEWAY=$GATEWAYS_1 else GATEWAY=$SERVER fi if [ "$DNSSRVS_1" ]; then DNSSRV=$DNSSRVS_1 else DNSSRV=$SERVER fi #if [ "$YPSRVR" ]; then # YPSRV=$YPSRVR_1 #else # YPSRV=$SERVER #fi NETROUTE=`route|grep $NETWORK| awk '{print $1;}' ` > $DBGTERM 2>&1 echo "Net is $NETROUTE" > $DBGTERM 2>&1 if ! [ "$NETROUTE" ]; then ifconfig $IFACE ${IPADDR} netmask ${NETMASK} \ broadcast ${BROADCAST} > $DBGTERM 2>&1 route add -net ${NETWORK} netmask ${NETMASK} $IFACE \ > $DBGTERM 2>&1 fi if ! [ "$DEFAULT" ]; then route add default gw ${GATEWAY} $IFACE > $DBGTERM 2>&1 fi domainname $DOMAIN > $DBGTERM 2>&1 echo "Building /etc/resolv.conf" > $DBGTERM echo "domain $DOMAIN" > /etc/resolv.conf echo "nameserver $DNSSRV" >> /etc/resolv.conf if [ "$DNSSRVS_2" ]; then echo "nameserver $DNSSRVS_2" >> /etc/resolv.conf fi #echo "sortlist $NETWORK/255.255.255.0" >> /etc/resolv.conf #echo "ypserver $YPSRV" > /etc/yp.conf #echo "rhs=.$DOMAIN" > /etc/hesiod.conf echo "Looking up our hostname" > $DBGTERM eval `/bin/ipcalc --hostname ${IPADDR}` echo "Hostname is $HOSTNAME" hostname $HOSTNAME if [ "`hostname`" != "$HOSTNAME" ] ; then echo "** Failure - failed to set hostname to $HOSTNAME" /bin/sh fi if [ "$TIMESRVS" ] ; then echo "Setting time from $TIMESRVS" rdate -s $TIMESRVS fi date echo -n "portmap" > $DBGTERM /sbin/portmap > $DBGTERM 2>&1 echo " ok" > $DBGTERM 2>&1 #echo -n "ypbind" #/sbin/ypbind & 2>/dev/null #status=1 #while [ $status -gt 0 ] ; do # ypwhich 2>/dev/null >/dev/null # status=$? #done #echo -n " bound to " #ypwhich if [ "$T151" ] ; then echo "Fetching initial profile from $T151" echo "Fetching initial profile from $T151" > $DBGTERM 2>&1 /etc/obj/profile install $T151 / [ "$?" = "0" ] || /bin/sh else echo "*** Install failure : did not receive Option-151 from BOOTP server" echo " -> can't fetch initial profile" /bin/sh fi #mkdir -p /var/amd.root/export #mkdir -p /var/amd.root/usr/remote #echo "Starting amd object" #/etc/obj/amd install #echo if [ -x /sbin/hdparm ] then idedisks=`ls -1 /proc/ide | grep '^hd'` for d in $idedisks do opts=`/sbin/hdparm -i /dev/$d 2>/dev/null | /etc/getdma` echo "hdparm options $opts for /dev/$d" /sbin/hdparm $opts /dev/$d done fi /usr/bin/GET http://$SERVER:8087/cgi/reset?IP=${IPADDR} if [ "$nointeract" != "yes" ] ; then echo "Please remove the floppy....if you used one" echo valid='no' while [ "$valid" = 'no' ] ; do /bin/echo -n "Type I for install, S for shell : "; read uip < $CONSOLE case $uip in I|i) valid='yes' ;; S|s) /bin/sh;; esac done valid='no' while [ "$valid" = 'no' ] ; do /bin/echo -n "Type Y to confirm, S for shell : "; read uip < $CONSOLE case $uip in Y|y) valid='yes' ;; S|s) /bin/sh;; esac done fi # Mount repository file system if [ -x /etc/obj/nfsmount ] ; then /etc/obj/nfsmount install fi # Install Linux /etc/obj/update install [ "$?" = "0" ] || /bin/sh if [ "$T151" ] ; then echo "Fetching profile from $T151" echo "Fetching profile from $T151" > $DBGTERM 2>&1 /etc/obj/profile install $T151 /root [ "$?" = "0" ] || /bin/sh fi /etc/obj/update installclean [ "$?" = "0" ] || /bin/sh sleep 1 sync sync sleep 1 /sbin/reboot -d -f