# UberJS Version 4.0.1a-Standard echo "" echo "UberJS Standard v4.0.1a with NetInit v4.0.1a Booting" echo "" #################################################################################################################################### # UberJS Mechanism ( http://clue.eng.iastate.edu/uberjs - uberjs@iastate.edu ) #################################################################################################################################### # Method: # 1. Check /tmp/uberjs/ipethers # If mac address is not there or is listed with DHCP the system will try DHCP first. # If mac address is listed with an IP, the system will skip DHCP attempts. # 2. Bring up interfaces # If /tmp/uberjs/nodhcp exists, DHCP will not be attempted # If DHCP was specified, IP, netmask, and default routes will be configured by DHCP and brought up # If DHCP fails, the user will be prompted for an IP and the interface will be brought up # If DHCP gives an invalid address, or undesirable address, the user is given the option to be prompted instead # If /tmp/uberjs/useonly or /tmp/uberjs/ignore files exist, only certain interfaces will be included or excluded # If no IP was given in ipethers, the builder will be prompted for IP then the interface will be brought up # If an IP was given in ipethers, the ip address specified will be user and the interface will be brought up # 3. Netmask # If /tmp/uberjs/netmask exists, that netmask (dotted decimal) will be used # If that file does not exist, the builder will be prompted # 4. Automatic route detection # If /tmp/uberjs/noautoroute exists, automatic route detection will not be attempted. # If DHCP was specified, default route is already established # If DHCP was not used, in.routed is used to determine a route # If in.routed cannot find a router after 120 seconds, the user is prompted to enter one # 5. Hostname determination # nslookup is used to determine hostname, then set with hostname -s # If no hostname is found, hostname defaults to localhost # 6. WGET # Wget is run and downloads a directory structure from ftp or www as specified in /tmp/uberjs/wget_servers # Wget will try each server down the line, but will stop trying when a server succeeds (expects mirrors) # Wget copies any downloaded files to /tmp (straight into/over the ramdisk filesystem, allows for some last minute tweaks) # 7. NFS Mounting # If bootparams was downloaded by wget or already on the CD, it is parsed and the filesystem locations are determined # If bootparams does not have our hostname in it, /tmp/uberjs/nfs_servers will be checked and a menu will be presented # the user can then select any of the servers specified # If no nfs_servers file exists, or any of the filesystem locations are blank, the user will be prompted for the blank entries. # Finally, filesystems are mounted and things are put in place so that the jumpstart can proceed # Note that all the scripts think we're doing a cd install because of the prom command boot cdrom - install # so the media is mounted on /cdrom, and the $SI_CONFIG_DIR becomes a mountpoint instead of a hardcoded file # 8. Sysidcfg Copy/Tweak # If the mounts were successful, sysidcfg is copied from the nfs mount that contains the sysidcfg file to /tmp/root/etc # If the sysidcfg file exists and contains the line 'network_interface=', no tweaks are made at this point # If the file doesnt contain that line, UberJS adds it with some intelligence about whether the system was booted with # DHCP or was configured manually to an IP. # If the sysidcfg file exists and contains the line 'name_service=', no tweaks are made at this point # If the file doesnt contain that line, and resolv.conf exists, UberJS adds it with the information in /tmp/root/etc/resolv.conf # 9. Sun Install # At this point, the standard jumpstart mechanism takes over # #################################################################################################################################### # # NOTE: Reading this document requires a basic knowledge of SH scripting, but the comments should help you see what is going on. # To be successful in modifications, a more in-depth knowledge may be necessary. # Also, some awk scripting is used (note awk, not gnu awk), and admittedly, some may be able to be replaced with other code. # # A couple coding hints follow # The most common errors occur when: # String variables in if statements when quotation marks are not around the $variable and the variable is empty # ie # if [ $MYVAR = "" ]; then should be if [ "$MYVAR" = "" ]; then # # sun also often does if [ "x$MYVAR" = "x" ]; then # # # The brackets [] in an if statement are not separated from the if conditions by a space on either side # ie # if ["$MYVAR" = "" ]; then or if [ $MYVAR -eq 2]; then or if [ "$MYVAR" = "TEST"]; then # #################################################################################################################################### # NOTE: Don't redirect outputs to /dev/null! In rcS script, it says to redirect all output to /tmp/somefile because of # an nfs bug of some kind #################################################################################################################################### echo "" echo "UberJS v4.0.1a Network Initialization Code Beginning" echo "" #################################################################################################################################### # NETWORK INITIALIZATION SECTION # Find and mount the image from nfs #################################################################################################################################### ############################ # MAC ADDRESS DETECTION ############################ echo "Detecting mac address" CURRENT_ETHER=`ifconfig -a | grep "ether" | awk '{ if (NR==1) { print $2 } }'` # use first interface only echo "My mac address is ${CURRENT_ETHER}" ############################ # IP ETHERS MATCHING # Check /tmp/uberjs/ipethers ############################ echo "Checking /tmp/uberjs/ipethers for matching mac address" if [ -f /tmp/uberjs/ipethers ]; then IP_FROM_ETHERS=`cat /tmp/uberjs/ipethers | grep "${CURRENT_ETHER}" | awk '{ print $2 }'` # get the IP address for that mac address in ipethers if [ "${IP_FROM_ETHERS}" != "" ]; then echo "Matched entry for ${CURRENT_ETHER} in ipethers is ${IP_FROM_ETHERS}" else echo "No match found, will try DHCP for this host" fi else echo "No /tmp/uberjs/ipethers file, will try DHCP for this host" fi ############################ # INTERFACE CONFIGURATION ############################ # the below is a new feature, create /tmp/uberjs/useonly-primary or /tmp/uberjs/useonly-fcip0 or /tmp/uberjs/useonly-hme0 # to use only that interface. # works by only placing the desired devices in net_device_list echo "Iterating interfaces on this machine" net_device_list="" USEONLY_TEST=`ls /tmp/uberjs/useonly-*` # note whether we have useonly specifiers so we only use those interfaces if [ "${USEONLY_TEST}" = "" ]; then USEONLY_EXISTS="no" else echo "Useonly specifiers exist in /tmp/uberjs, will only use those interfaces" USEONLY_EXISTS="yes" fi # check if a useonly-primary directive exists if [ -f /tmp/uberjs/useonly-primary ]; then PRI_IF="`ifconfig -a | grep '^[a-z]*[0-9]:' | sed 's/^\([a-z]*[0-9]\):.*/\1/' | grep -v '^lo[0-9]' | head -1`" echo "Found useonly specifier for the primary interface." echo "Primary interface on this system is ${PRI_IF}." if [ "${PRI_IF}" = "" ]; then echo "No primary interface discovered!" /sbin/sh -i exit 1 fi net_device_list="${PRI_IF}:${net_device_list}" fi # The following little section is a Sun devised way to enumerate the interfaces and loop through them # # Get the complete list of network devices # so that we can ifconfig them individually # for i in `ifconfig -a |grep "^[a-z0-9]*:" | awk -F':' '{print $1}'`; do if [ "${USEONLY_EXISTS}" = "yes" ]; then if [ -f /tmp/uberjs/useonly-primary -a "${i}" = "${PRI_IF}" ]; then echo "Found useonly specifier for interface ${i}, already added with useonly-primary" # don't relist primary continue fi if [ -f /tmp/uberjs/useonly-${i} ]; then echo "Found useonly specifier for interface ${i}." net_device_list="${i}:${net_device_list}" fi else net_device_list="${i}:${net_device_list}" fi done # # net_device_list contains a ":" delimited list # of network devices # old_ifs=$IFS IFS=":" set -- $net_device_list for i do if [ "$i" = "lo0" ]; then continue fi if [ -f /tmp/uberjs/ignore-${i} ]; then echo "Found ignore specifier for interface ${i}. Skipping." continue #skip this interface if ignore designated fi ############################ # DHCP METHOD ############################ if [ "${IP_FROM_ETHERS}" = "" -a -f /tmp/uberjs/nodhcp ]; then echo "/tmp/uberjs/nodhcp file present, Not attempting DHCP configuration." else IP_FROM_ETHERS="DHCP" fi if [ "${IP_FROM_ETHERS}" = "DHCP" ]; then # if we dont have an ipethers specified address or it says to do DHCP, do DHCP! echo "Trying DHCP on $i (timeout is 60 seconds)" /sbin/ifconfig $i dhcp primary start wait 60 # attempt dhcp configuration if [ $? -eq 0 ] ; then echo "Network initialized via DHCP" IP_FROM_ETHERS=`/sbin/ifconfig $i | grep inet | awk '{ print $2 }'` #set ip so we dont try and override it DEFROUTER=`netstat -rn | grep default | awk '{print $2}'` #needed below echo "Getting hostname from DNS" NS_OF_IP=`nslookup ${IP_FROM_ETHERS} | grep "Name:" | awk '{print $2}' 2> /tmp/uberjs.out` #look up hostname # the following awk mess translates hex formatted netmask to dotted decimal MY_NETMASK=`ifconfig $i | grep netmask | awk '{ for(i=0;i<4;i++) { bytes1[i]=substr($4,((i*2)+1),1); bytes2[i]=substr($4,((i*2)+2),1); if (bytes1[i]=="a") { bytes1[i]=10 } else if (bytes1[i]=="b") { bytes1[i]=11 } else if (bytes1[i]=="c") { bytes1[i]=12 } else if (bytes1[i]=="d") { bytes1[i]=13 } else if (bytes1[i]=="e") { bytes1[i]=14 } else if (bytes1[i]=="f") { bytes1[i]=15 }; if (bytes2[i]=="a") { bytes2[i]=10 } else if (bytes2[i]=="b") { bytes2[i]=11 } else if (bytes2[i]=="c") { bytes2[i]=12 } else if (bytes2[i]=="d") { bytes2[i]=13 } else if (bytes2[i]=="e") { bytes2[i]=14 } else if (bytes2[i]=="f") { bytes2[i]=15 }; bytes[i]=((bytes1[i]*16)+bytes2[i]) } print bytes[0]"."bytes[1]"."bytes[2]"."bytes[3] }'` CORRECT=0 while [ $CORRECT != 1 ]; # allow user to refuse the DHCP'd address do echo "" echo "IP: ${IP_FROM_ETHERS}" echo "Hostname: ${NS_OF_IP}" echo "Gateway: ${DEFROUTER}" echo "Netmask: ${MY_NETMASK}" echo "" echo "Is this acceptable? [y/n]" read DHCPOK if [ "${DHCPOK}" = "n" -o "${DHCPOK}" = "no" ]; then # wipe out variables IP_FROM_ETHERS="" DEFROUTER="" MY_NETMASK="" /usr/sbin/route -f >/tmp/uberjs.out 2>&1 # flush routes /sbin/ifconfig $i down unplumb # unplumb it /sbin/ifconfig $i plumb # then replumb it to get back to 0.0.0.0 on the interface CORRECT=1 elif [ "${DHCPOK}" = "y" -o "${DHCPOK}" = "yes" ]; then DHCP_IFACE=$i uname -S ${NS_OF_IP} # set DHCP hostname from DNS CORRECT=1 fi done else # No luck, give up on this interface /sbin/ifconfig $i dhcp drop # wipe out variables IP_FROM_ETHERS="" DEFROUTER="" MY_NETMASK="" /usr/sbin/route -f >/tmp/uberjs.out 2>&1 # flush routes /sbin/ifconfig $i down unplumb # unplumb it /sbin/ifconfig $i plumb # then replumb it to get back to 0.0.0.0 on the interface fi fi ############################ # MANUAL METHOD, prompting ############################ ipaddr=`/sbin/ifconfig $i | grep inet | awk '{ print $2 }'` # check to see if we didnt configure above, or didnt like the dhcp'd info if [ "X$ipaddr" = "X0.0.0.0" -a "${IP_FROM_ETHERS}" = "" ]; then # ip address is unset and none was found by the files CORRECT=0 while [ $CORRECT != 1 ]; # loop until they enter an ip address they're happy with do echo "Please enter IP address for $i:" echo "If you wish to skip this interface, simply leave blank" read IP_FROM_ETHERS if [ "${IP_FROM_ETHERS}" = "" ]; then echo "Skip this interface? [y/n]" IP_FROM_ETHERS="SKIP" else echo "You entered: ${IP_FROM_ETHERS}" echo "Is this correct? [y/n]" fi read YESNO if [ "${YESNO}" = "y" -o "${YESNO}" = "yes" ]; then CORRECT=1 fi if [ "${YESNO}" = "n" -o "${YESNO}" = "no" ]; then if [ "${IP_FROM_ETHERS}" = "SKIP" ]; then CORRECT=1 fi fi done # so now $IP_FROM_ETHERS has a new, user entered and verified IP address and the code below will be happy. fi if [ "${IP_FROM_ETHERS}" = "SKIP" ]; then echo "Skipping this interface" IP_FROM_ETHERS="" continue fi ############################ # MANUAL METHOD, activation ############################ if [ "X$ipaddr" = "X0.0.0.0" ]; then # we have a plumbed, but unconfigured interface /sbin/ifconfig $i $IP_FROM_ETHERS 2>&1 ipaddr=`/sbin/ifconfig $i | grep inet | awk '{ print $2 }'` if [ "X$ipaddr" != "X0.0.0.0" ]; then # The interface configured itself correctly echo "Configured interface $i" /sbin/ifconfig $i up ############################ # NETMASK SETUP ############################ if [ -f /tmp/uberjs/netmask ]; then # check to see if the file exists MY_NETMASK=`cat /tmp/uberjs/netmask 2>/tmp/uberjs.out` if [ "${MY_NETMASK}" != "" ]; then echo "Found netmask ${MY_NETMASK} in /tmp/uberjs/netmask" else echo "No netmask found in /tmp/uberjs/netmask" MY_NETMASK="" # set to empty fi else echo "No /tmp/uberjs/netmask file present" MY_NETMASK="" # set to empty fi if [ "${MY_NETMASK}" = "" ]; then # if no netmask from /tmp/uberjs/netmask, default then confirm CORRECT=0 while [ $CORRECT != 1 ]; do echo "Assuming netmask of 255.255.0.0, is this acceptable? [y/n]" read YESNO if [ "${YESNO}" = "y" -o "${YESNO}" = "yes" ]; then MY_NETMASK="255.255.0.0" # set the netmask CORRECT=1 fi if [ "${YESNO}" = "n" -o "${YESNO}" = "no" ]; then MY_NETMASK="" # allow a prompt CORRECT=1 fi done fi if [ "${MY_NETMASK}" = "" ]; then # if default not acceptable (mask still blank), prompt CORRECT=0 while [ $CORRECT != 1 ]; do echo "Please input netmask for $i (dotted decimal):" read MY_NETMASK echo "You entered: ${MY_NETMASK}" echo "Is this correct? [y/n]" read YESNO if [ "${YESNO}" = "y" -o "${YESNO}" = "yes" ]; then CORRECT=1 fi done fi echo "Configuring interface $i to use the new netmask" /sbin/ifconfig $i netmask ${MY_NETMASK} >/tmp/uberjs.out 2>&1 ############################ # ROUTE DISCOVERY ############################ if [ -f /tmp/uberjs/noautoroute ]; then echo "/tmp/uberjs/noautoroute present: Not attempting automatic route discovery" else /usr/sbin/route -f >/tmp/uberjs.out 2>&1 # flush routes echo "Starting in.routed to find default routers" echo "Routed will run for a max of 60 seconds" # The start time current time, and elapsed time variables are time converted to seconds from midnight and it takes # the difference from the start time to the current time to determine how long the process has been running. # the process loops until a default route pops into the routing table or the allotted time has expired STARTTIME=`date '+%H:%M:%S' | awk -F":" 'BEGIN {totseconds=0} { totseconds+=($3+($2*60)+($1*60*60)) } END { print totseconds }'` CURTIME=${STARTTIME} ELAPSEDTIME=0 DEFROUTER="" /usr/sbin/in.routed # start the discovery daemon ROUTEDPID=`ps -ef | grep routed | grep -v grep | awk '{ print $2 }'` # get its pid so we can kill it later while [ "$DEFROUTER" = "" -a $ELAPSEDTIME -lt 60 ]; do # run for 30 seconds or until we get a route DEFROUTER=`/usr/bin/netstat -rn | grep default | awk '{print $2}'` # check for default routes CURTIME=`date '+%H:%M:%S' | awk -F":" 'BEGIN {totseconds=0} { totseconds+=($3+($2*60)+($1*60*60)) } END { print totseconds }'` ELAPSEDTIME=`echo "$STARTTIME $CURTIME" | awk '{ print abs($2-$1) }'` done if [ "$DEFROUTER" = "" ]; then echo "No default router found after 60 seconds." fi echo "Killing in.routed on PID ${ROUTEDPID}" kill -9 $ROUTEDPID fi if [ "$DEFROUTER" = "" ]; then CORRECT=0 while [ $CORRECT != 1 ]; do echo "Please enter gateway address:" read DEFROUTER echo "You entered: ${DEFROUTER}" echo "Is this correct? [y/n]" read RESPONSE if [ "${RESPONSE}" = "y" -o "${RESPONSE}" = "yes" ]; then CORRECT=1 fi done /usr/sbin/route add default $DEFROUTER # add the default route fi echo "Using default router ${DEFROUTER}" echo "Putting default route in /tmp/root/etc/defaultrouter" echo "${DEFROUTER}" > /tmp/root/etc/defaultrouter else echo "Skipping manual configuration of interface $i" fi fi ############################ # HOSTNAME SETUP ############################ echo "Determining my hostname from nslookup" NS_OF_IP=`nslookup ${IP_FROM_ETHERS} | grep Name | awk '{ print $2}'` if [ "${NS_OF_IP}" != "" ]; then echo "Nslookup returns my hostname is ${NS_OF_IP}" echo "Setting hostname with uname -S" uname -S ${NS_OF_IP} else echo "Nslookup failed, or ip has no dns name." echo "setting hostname to localhost with uname -S" uname -S localhost fi done IFS=$old_ifs #echo "${Rootfs} - / ${Roottype} - no ro" >> /etc/vfstab #################################################################################################################################### # WGET Routine, downloads from a location and puts files in the /tmp/uberjs directory # tries one server at a time until one succeeds (assumes mirroed configuration) # Good files to wget: bootparams, nfs_servers, possibly resolv.conf #################################################################################################################################### if [ -f /tmp/uberjs/wget_servers ]; then NUMWGETSERVERS=`/usr/bin/wc -l /tmp/uberjs/wget_servers | awk '{ print $1 }'` echo "List contains ${NUMWGETSERVERS} servers for wget configuration" if [ ! -d /tmp/wget ]; then mkdir /tmp/wget else rm -rf /tmp/wget mkdir /tmp/wget fi SERVERNO=1 DONEWGET=0 # loop through the file until we are successful while [ $DONEWGET = 0 ] do export SERVERNO CURSERVER=`cat /tmp/uberjs/wget_servers | tail +${SERVERNO} | awk '{ if ( NR==1) { print $0 }}'` # print the record we want echo "Trying Server #${SERVERNO} : ${CURSERVER}" /tmp/uberjs/wget -qr -nH -P /tmp/wget ${CURSERVER} if [ $? = 0 ]; then DONEWGET=1 SUCCESS=1 echo "Success" else if [ $SERVERNO = $NUMWGETSERVERS ]; then DONEWGET=1 SUCCESS=0 else SERVERNO=`echo $SERVERNO | awk '{ tmp = $1; print ($1+1) }'` fi fi done if [ $SUCCESS = 1 ]; then #NOTE: Because of how wget works, if your files are in ftp://foobar.org/uberftpget #/tmp/uberftpget will be created. Using the -nd argument creates a flat filesystem unfortunately #and we cannot use it. Instead, the below method will work for ANY TOP-LEVEL DIRECTORY on your ftp server #so whatever toplevel directory you create should have the uberjs directory and perhaps root/etc directory #as well echo "Copying the wget'd configs from $CURSERVER into /tmp" cp -r /tmp/wget/*/* /tmp rm -rf /tmp/wget else echo "Wget failed, proceeding normally." fi fi echo "" echo "Network Initialization Section Completed." #################################################################################################################################### # UberJS Standard Portion #################################################################################################################################### echo "" echo "UberJS Standard Portion Beginning" echo "" #################################################################################################################################### # NFS SECTION (Network should be up and running by now) #################################################################################################################################### Installfs="" # location of media gets mounted on /cdrom Profilefs="" # location of profile/rules gets mounted at $SI_CONFIG_DIR Sysidfs="" # location of sysidcfg file gets mounted on /tmp/sysidfs ############################ # Bootparams parsing ############################ if [ -f /tmp/uberjs/bootparams ]; then MYBOOTP=`cat /tmp/uberjs/bootparams | grep "^${IP_FROM_ETHERS}"` # try ip first if [ "${MYBOOTP}" = "" -a "${NS_OF_IP}" != "" ]; then MYBOOTP=`cat /tmp/uberjs/bootparams | grep "^${NS_OF_IP}"` # then try hostname fi Installfs=`echo "${MYBOOTP}" | awk '{for (i=1;i<=NF;i++) { split($i,a,"=") ; if(a[1]=="install") { print a[2] } } }'` Profilefs=`echo "${MYBOOTP}" | awk '{for (i=1;i<=NF;i++) { split($i,a,"=") ; if(a[1]=="install_config") { print a[2] } } }'` Sysidfs=`echo "${MYBOOTP}" | awk '{for (i=1;i<=NF;i++) { split($i,a,"=") ; if(a[1]=="sysid_config") { print a[2] } } }'` fi ############################ # nfs_servers section # list of servers that can be used (this is only used if Installfs, Profilefs, and Sysidfs havent been filled in yet) ############################ if [ -f /tmp/uberjs/nfs_servers -a "${Installfs}" = "" -a "${Profilefs}" = "" -a "${Sysidfs}" = "" ]; then SELECTIONDONE=0 while [ $SELECTIONDONE -ne 1 ]; do NUMNFSSERVERS=`wc -l /tmp/uberjs/nfs_servers | awk '{ print $1 }'` # get a count of how many servers there are in the file MENUNUM=`echo ${NUMNFSSERVERS} | awk '{ print ($1+1) }'` # we need one more than the number of choices so we can include an input option echo "Found ${NUMNFSSERVERS} NFS server possibilites in nfs_servers file" echo "Please select from the following" echo "" CSRVR=1 while [ $CSRVR -ne $MENUNUM ] # loop through the file, and display the desired line with its menu number in front (in $CSRVR) do INSTSRVR=`cat /tmp/uberjs/nfs_servers | tail +${CSRVR} | awk '{ if (NR==1) { print $1 } }'` # parse the selected line PROFSRVR=`cat /tmp/uberjs/nfs_servers | tail +${CSRVR} | awk '{ if (NR==1) { print $2 } }'` SYSIDSRVR=`cat /tmp/uberjs/nfs_servers | tail +${CSRVR} | awk '{ if (NR==1) { print $3 } }'` echo "Choice #${CSRVR}" echo " Install: ${INSTSRVR}" echo " Install Config: ${PROFSRVR}" echo " Sysid Config: ${SYSIDSRVR}" echo "" CSRVR=`echo ${CSRVR} | awk '{ tmp = $1 ; print ($1+1) }'` # increment number via awk since shell doesnt know how properly (gets string"+1") done echo "Choice #${CSRVR}" echo " Do not use nfs_servers file (Input other server location)" # include an extra option to input our own echo "" echo "Input your choice: " read CSCHOICE if [ "${CSCHOICE}" = "" ]; then CSCHOICE=0 # if no input, invalidate fi if [ ${CSCHOICE} -lt 1 -o $CSCHOICE -gt $MENUNUM ]; then # if out of range, invalidate CSCHOICE=0 fi if [ $CSCHOICE = $MENUNUM ]; then Installfs="" # blank these so we catch for input below Profilefs="" Sysidfs="" echo "" echo "Input your own server?" echo "[y/n]" read CSOK elif [ $CSCHOICE -ne 0 ]; then Installfs=`cat /tmp/uberjs/nfs_servers | tail +${CSCHOICE} | awk '{ if (NR==1) { print $1 } }'` # parse the selected line Profilefs=`cat /tmp/uberjs/nfs_servers | tail +${CSCHOICE} | awk '{ if (NR==1) { print $2 } }'` Sysidfs=`cat /tmp/uberjs/nfs_servers | tail +${CSCHOICE} | awk '{ if (NR==1) { print $3 } }'` echo "" echo "Using Choice #${CSCHOICE}" echo " Install: ${Installfs}" echo " Install Config: ${Profilefs}" echo " Sysid Config: ${Sysidfs}" echo "" echo "ok? [y/n]" read CSOK else CSOK="n" fi if [ "${CSOK}" = "y" -o "${CSOK}" = "yes" ]; then SELECTIONDONE=1 fi echo "" done fi ################################ # Manual input of NFS Servers ################################ # if Installfs isn't filled in by one of the above sections, ask for an explicit entry. if [ "${Installfs}" = "" ]; then CORRECT=0 while [ $CORRECT != 1 ] do echo "Please type the NFS server:path to the Media directory: " read Installfs echo "You entered: ${Installfs}" echo "Is this correct? [y/n]" read RESPONSE if [ "${RESPONSE}" = "y" -o "${RESPONSE}" = "yes" ]; then CORRECT=1 fi done fi # if Profilefs isn't filled in by one of the above sections, ask for an explicit entry. if [ "${Profilefs}" = "" ]; then CORRECT=0 while [ $CORRECT != 1 ] do echo "Please type the NFS server:path to the Profile directory: " read Profilefs echo "You entered: ${Profilefs}" echo "Is this correct? [y/n]" read RESPONSE if [ "${RESPONSE}" = "y" -o "${RESPONSE}" = "yes" ]; then CORRECT=1 fi done fi # if Sysidfs isn't filled in by one of the above sections, ask for an explicit entry. if [ "${Sysidfs}" = "" ]; then CORRECT=0 while [ $CORRECT != 1 ] do echo "Please type the NFS server:path to the Sysid Config directory: " read Sysidfs echo "You entered: ${Sysidfs}" echo "Is this correct? [y/n]" read RESPONSE if [ "${RESPONSE}" = "y" -o "${RESPONSE}" = "yes" ]; then CORRECT=1 fi done fi ######################## # NFS MOUNTING ######################## # cdrom needs to be unmounted and replaced with nfs mount to media # this is to fool JumpStart into thinking we're doing a cdrom install still # all of the scripts know from 'boot cdrom - install' that we're doing cd, and will look # for everything in /cdrom echo "Unmounting /cdrom" cd / umount /cdrom 2> /tmp/uberjs.out echo "Proceeding to mount NFS paths." #----------------------------------------------------------------------- echo "Mounting Install Media from ${Installfs} on /cdrom" /sbin/mount -F nfs -o ro ${Installfs} /cdrom >/tmp/uberjs.out 2>&1 if [ $? != 0 ]; then echo "Mount failed, bringing up a shell" exec /bin/sh fi #----------------------------------------------------------------------- echo "Unmounting any previous install_config mounts" for CURMOUNT in `mount | grep install_config | awk '{ print $1 }'`; do echo "Unmounting ${CURMOUNT}" umount $CURMOUNT done # did it this way in case sun changes where SI_CONFIG_DIR is. SI_CONFIG_DIR=`cat /usr/sbin/install.d/profind | grep "SI_CONFIG_DIR=" | awk -F"=" '{ print $2 }'` echo "Creating mountpoint for profind (SI_CONFIG_DIR)" if [ -d ${SI_CONFIG_DIR} ]; then rm -rf ${SI_CONFIG_DIR} fi mkdir ${SI_CONFIG_DIR} echo "Mounting Profile Info from ${Profilefs} on ${SI_CONFIG_DIR}" /sbin/mount -F nfs -o ro ${Profilefs} ${SI_CONFIG_DIR} >/tmp/uberjs.out 2>&1 if [ $? != 0 ]; then echo "Mount failed, bringing up a shell" exec /bin/sh fi #----------------------------------------------------------------------- echo "Creating mountpoint for sysid info" mkdir /tmp/sysidfs echo "Mounting Sysid Info from ${Sysidfs} on /tmp/sysidfs" /sbin/mount -F nfs -o ro ${Sysidfs} /tmp/sysidfs >/tmp/uberjs.out 2>&1 if [ $? != 0 ]; then echo "Mount failed, bringing up a shell" exec /bin/sh else if [ -f /tmp/sysidfs/sysidcfg ]; then echo "Copying sysidcfg file into /tmp/root/etc" cp /tmp/sysidfs/sysidcfg /tmp/root/etc else echo "No sysidcfg file was found on this mount" fi echo "Un-mounting /tmp/sysidfs" umount /tmp/sysidfs fi #----------------------------------------------------------------------- echo "Mounting completed" ############################################################## # SYSIDCFG Modification ############################################################## if [ -f /tmp/root/etc/sysidcfg ]; then # Default Router Tweak (avoids having to enter the already discovered/entered default router in the sun install phase) # Also is DHCP Tweak NETIFACELINE=`cat /tmp/root/etc/sysidcfg | grep "^network_interface="` if [ "${NETIFACELINE}" = "" ]; then # only write out if line doesnt already exist if [ "${DHCP_IFACE}" = "" ]; then # add netmask and default router since not DHCP echo "Adding network_interface line to sysidcfg with ipv6=no, netmask=${MY_NETMASK}, and default_route=${DEFROUTER}" echo "network_interface=PRIMARY { protocol_ipv6=no netmask=$MY_NETMASK default_route=$DEFROUTER }" >> /tmp/root/etc/sysidcfg else # dont add netmask or default router, just add DHCP since we booted with DHCP echo "Adding network_interface line to sysidcfg with ipv6=no and DHCP tag" echo "network_interface=PRIMARY { protocol_ipv6=no dhcp }" >> /tmp/root/etc/sysidcfg fi else # make no changes because the network_interface line exists. This may not be optimal. echo "network_interface already specified in sysidcfg, this may not be optimal. No changes will be made at this point." fi # Name Service Tweak (avoids having to enter the information from resolv.conf) NAMESERVICELINE=`cat /tmp/root/etc/sysidcfg | grep "^name_service="` if [ -f /tmp/root/etc/resolv.conf -a "${NAMESERVICELINE}" = "" ]; then # only write if resolv.conf exists and the line doesnt already exist RESOLVDOMAIN=`cat /tmp/root/etc/resolv.conf | grep domain | awk '{ if (NR==1) { print $2 }}'` # return only first record in case of bad file RESOLVNS=`cat /tmp/root/etc/resolv.conf | grep nameserver | awk 'BEGIN { nslist="" } { if (NR==1) { nslist=$2 } else if (NR<=3) { nslist=nslist","$2 }} END { print nslist }'` # get comma separated list of nameservers, up to max of 3 RESOLVSEARCH=`cat /tmp/root/etc/resolv.conf | grep search | awk '{ srchlist=$2 ; for (i=3;i<=NF;i++) { srchlist=srchlist","$i } ; print srchlist }'` if [ "$RESOLVDOMAIN" != "" -a "$RESOLVNS" != "" -a "$RESOLVSEARCH" != "" ]; then echo "Adding name_service line to sysidcfg from resolv.conf information" echo "name_service=DNS { domain_name=$RESOLVDOMAIN name_server=$RESOLVNS search=$RESOLVSEARCH }" >> /tmp/root/etc/sysidcfg else echo "Resolv.conf is not complete. No changes will be made to sysidcfg" fi else echo "Resolv.conf does not exist or name_service line already specified in sysidcfg. No changes will be made to sysidcfg." fi fi # Loopback mount the full version of /usr on the server # if [ -d /cdrom/Solaris_*/Tools/Boot/usr ]; then /sbin/mount -F lofs /cdrom/Solaris_*/Tools/Boot/usr /usr mount_return_code=$? if [ $mount_return_code -ne 0 ]; then echo "Unable to mount /cdrom/Solaris_*/Tools/Boot/usr" exec /sbin/sh fi fi # Append the vfstab file echo "${Installfs} - /cdrom nfs - no ro" >> /etc/vfstab echo "${Profilefs} - ${SI_CONFIG_DIR} - no ro" >> /etc/vfstab echo "${Sysidfs} - /tmp/sysidfs - no ro" >> /etc/vfstab