home *** CD-ROM | disk | FTP | other *** search
/ ftp.jcu.edu.au / 2014.06.ftp.jcu.edu.au.tar / ftp.jcu.edu.au / v6.3.2b / install < prev    next >
Text File  |  2009-10-13  |  27KB  |  980 lines

  1. #!/bin/sh
  2. #    Copyright (c) 1996-2008 Brocade Communications Systems, Inc.
  3. #    All rights reserved.
  4. #
  5. #
  6. #    Description:
  7. #      Install script that initializes a platform
  8. #
  9. #      6/15/2006  updated for Linux 2.6 installation  
  10. #
  11. #      7/11/2006  updated for development and nfdiag plist installs
  12. #
  13. #      8/02/2006  updated to fix create_release_file
  14. #
  15. #      8/24/2006  updated to fix xfs doesnt work on terminator, use ext3
  16. #                 fix access to create_release_file
  17. #                 picked up a BD=55 tweak for bootenv
  18. #
  19. #      8/28/2006  updated to make xfs to be used for BD=12 & 21 only
  20. #      8/31/2006  reordered the disk setup to do partition then mkfs 
  21. #                 do both before entering install loop
  22. #      9/27/2006  added swbd22 to xfs to be used
  23.  
  24.  
  25. # Set the LD_LIBRARY_PATH for the interdependency 
  26. export PATH=$PATH:/bin:/sbin:/mnt/bin:/mnt/sbin
  27. export LD_LIBRARY_PATH="/lib:/usr/lib:/mnt/lib"
  28.  
  29. # This function is here because of sporadic new hardware failures with
  30. # parted.  Parted erroneously find the label "in use" and fail writing
  31. # the label.  Since we know that the CF cannot be in use by anything else
  32. # when install is running, we clobber the label block with zeros to assure
  33. # that parted will work.
  34. clobber_label()
  35. {
  36.     if [ -e /tmp/foo ] ; then           # prevent unexpected messages
  37.         rm /tmp/foo 
  38.     fi
  39.     i=0
  40.     while (( $i < 256 )) ; do
  41. #                1 2 3 4 5 6 7 8 9 a b c d e f  (16*256 = 4096)
  42.         printf "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" >> /tmp/foo
  43.         i=$(( $i + 1 ))
  44.     done
  45.     cat /tmp/foo > /dev/hda
  46.     rc=$?
  47.     if [ -e /tmp/foo ] ; then           # prevent unexpected messages
  48.         rm /tmp/foo 
  49.     fi
  50.     if (( ${rc} )) ; then
  51.         echo INSTALL26: Cannot write to /dev/hda.   Install ABORTED
  52.         exit 0
  53.     fi
  54. }
  55.  
  56. usage() {
  57.     program=`basename $0`
  58.  
  59.     echo "Usage: $program <platform> <TEST | EXTENDED> package"
  60.     echo "  platform      <Optional> hardware must be this platform."
  61.     echo "  TEST          Perform read/write testing of compact flash memory."
  62.     echo "  EXTENDED      Perform extended testing of compact flash memory."
  63.     echo "  package       Package to install."
  64.  
  65.     echo ""
  66.     echo "Platforms for this product are:"
  67.     cat platform_names | grep $PLATFORM | cut -d":" -f2- | xargs
  68.     echo ""
  69.     echo "Platform \"$PLATFORM\" packages are:"
  70.     if [ "`ls ./$PLATFORM/*.plist 2>/dev/null`" = "" ]
  71.     then
  72.       echo "INTERNAL ERROR: No packages found for platform $PLATFORM"
  73.     else
  74.       ls ./$PLATFORM/*.plist 2>/dev/null | cut -d"/" -f3 | cut -d "." -f1
  75.     fi
  76.     echo ""
  77.     exit 1
  78. }
  79.  
  80. exit_out()
  81. {
  82.     if [ $error = TRUE ]
  83.     then
  84.     echo "INSTALL26: install FAILED with $warn_count warnings."
  85.     exit 1
  86.     else
  87.     if [ $warn_count ]
  88.     then
  89.         echo "INSTALL26: install PASSED with $warn_count warnings."
  90.     else
  91.         echo "INSTALL26: install PASSED."
  92.     fi
  93.     exit 0
  94.     fi
  95. }
  96.  
  97. #
  98. # do_command <warn/error> <command...>
  99. #
  100. do_command()
  101. {
  102.     warn=$1
  103.     shift
  104.     $*
  105.     if [ $? -ne 0 ]
  106.     then
  107.     if [ $warn = TRUE ]
  108.     then
  109.         echo "INSTALL26: Warning - failed $*"
  110.         warn_count=`expr $warn_count + 1`
  111.         return 1
  112.     else
  113.         echo "INSTALL26: ERROR - failed $*"
  114.         continue=FALSE
  115.         error=TRUE
  116.         exit_out
  117.     fi
  118.     fi
  119.     return 0
  120. }
  121. #
  122. # install-rpms <plist> <root>
  123. #
  124. installrpms()
  125. {
  126.     LIST=$PLATFORM/$1
  127.  
  128.     if [ ! -f $LIST ] || [ ! -r $LIST ]; then
  129.     echo "INSTALL26: Cannot open/read package list to install."
  130.     exit 1
  131.     fi
  132.  
  133.     if [ ! -z $2 ]; then
  134.     ROOT=$2
  135.     else
  136.         ROOT=/
  137.     fi
  138.  
  139.     RPM="rpm --root $ROOT"
  140.  
  141.     echo "INSTALL26: Installing RPMs from $LIST rooted at $ROOT..."
  142.     echo "INSTALL26: Installing RPMs using $RPM ..."
  143.  
  144.     if [ ! -d ${ROOT}/var/lib/rpm ]; then
  145.         echo "INSTALL26: Initializing RPM database..."
  146.     do_command TRUE mkdir -p ${ROOT}/var/lib/rpm
  147.     do_command TRUE rpm --root $ROOT --initdb
  148.     fi
  149.  
  150.     #
  151.     # When we install the first package, we will not run any pre- or
  152.     # post-install of that package. The script will fail because the
  153.     # filesystem has just been initialized.
  154.     #
  155.     first_package=1
  156.  
  157.     # echo "INSTALL26: install from list $LIST"
  158.     for package in `grep "\.rpm" $LIST `;
  159.     do
  160.         #echo "INSTALL26: installing  $package"
  161.     #
  162.     # Only install the package if it hasn't already been installed
  163.     # 
  164.     if [ $first_package -eq 1 ]; then
  165.        do_command TRUE $RPM --force --nodeps -ivUh --noscripts $package
  166.        first_package=0
  167.     else
  168.        do_command TRUE $RPM --force --nodeps -ivUh $package
  169.     fi
  170.  
  171.         # stop on problem to diagnose
  172.     if [ $? -ne 0 ]
  173.     then
  174.            echo "INSTALL26: install died  for $package"
  175.            echo "INSTALL26: cmd= $RPM --force --nodeps -ivUh $package"
  176.            exit 1
  177.     fi
  178.     done
  179. }
  180.  
  181. copy_image_lists()
  182. {
  183.     LIST=$PLATFORM/$1
  184.     VCONF=$PLATFORM/$2
  185.  
  186.     if [ ! -z $3 ]; then
  187.     ROOT=$3
  188.     else
  189.         ROOT=/
  190.     fi
  191.  
  192.     do_command TRUE mkdir -p  ${ROOT}/var/images/$PLATFORM
  193.  
  194.     if [ ! -f $LIST ] || [ ! -r $LIST ]; then
  195.     echo "INSTALL26: Cannot open/read package list to install. Skipping..."
  196.     else
  197.     do_command TRUE cp $LIST  ${ROOT}/var/images/$PLATFORM/plist
  198.     fi
  199.  
  200.     if [ ! -f $VCONF ] || [ ! -r $VCONF ]; then
  201.     echo "INSTALL26: Cannot open/read version configuration. Skipping..."
  202.     else
  203.     do_command TRUE cp $VCONF ${ROOT}/var/images/$PLATFORM/version.conf
  204.     fi
  205. }
  206.  
  207. #
  208. # Removes the linuxthreads based glibc files.
  209. # These are required only during RPM installation
  210. #
  211. reset_glibc()
  212. {
  213.     if [ ! -z $1 ]; then
  214.     ROOT=$1
  215.     else
  216.         ROOT=/
  217.     fi
  218.  
  219.     >$ROOT/etc/ld.so.preload
  220.     cp $ROOT/var/glibc-linuxthreads/copyback/ld-2.3.6.so $ROOT/lib/ld-2.3.6.so
  221.     >$ROOT/var/glibc-linuxthreads/copyback/ld-2.3.6.so
  222.     cp $ROOT/var/glibc-linuxthreads/copyback/ldconfig $ROOT/sbin/ldconfig
  223.     >$ROOT/var/glibc-linuxthreads/copyback/ldconfig
  224.  
  225.     # Store the checksums for ldconfig and ld.so
  226.     chroot $ROOT /usr/bin/md5sum /lib/ld-2.3.6.so >> $ROOT/etc/ldchksum
  227.     chroot $ROOT /usr/bin/md5sum /sbin/ldconfig >> $ROOT/etc/ldchksum
  228.  
  229.     # Remove the linuxthreads package
  230.     ltpackage=`$RPM -qa | grep "glibc-linuxthreads"`
  231.     do_command TRUE $RPM -e $ltpackage
  232.  
  233.     # Use grep from the distribution. grep utility bundled in
  234.     # busybox is messing up reading a binary file
  235.     do_command TRUE ${ROOT}/bin/grep -a -v "$ltpackage" ${ROOT}/var/images/$PLATFORM/plist > /tmp/.tmpplist
  236.     do_command TRUE mv /tmp/.tmpplist ${ROOT}/var/images/$PLATFORM/plist
  237. }
  238.  
  239. #
  240. # test_for_product <candidate>
  241. #
  242. test_for_product()
  243. {
  244.     # Normalize the argument
  245.     candidate=`echo $1 | tr "A-Z" "a-z"`
  246.  
  247.     #
  248.     # Look up the name in the list of known names for the platform ID
  249.     #
  250.     target=`grep $PLATFORM platform_names`
  251.     if [ "$target" = "" ]
  252.     then
  253.     echo "INSTALL26: Unknown Platform found $PLATFORM"
  254.     usage
  255.     fi
  256.     if [ "`echo $target | grep $candidate`" = "" ]
  257.     then
  258.     # It is not the one we are, is it a different product?
  259.     if [ "`grep $candidate platform_names`" != "" ]
  260.     then
  261.         # output error message if valid product, otherwise it is not a 
  262.         # product argument, and we use PLATFORM
  263.         echo "INSTALL26: Actual platform ($PLATFORM) does not match specified platform $1."
  264.         echo "INSTALL26: ERROR - failed $0 $*"
  265.         continue=FALSE
  266.         error=TRUE
  267.         exit_out
  268.     fi
  269.     echo FALSE
  270.     else
  271.     echo $PLATFORM
  272.     fi
  273. }
  274.  
  275. #
  276. # test_for_test <candidate>
  277. #
  278. test_for_test()
  279. {
  280.     if [ "$1" = "TEST" ]
  281.     then
  282.     echo 1
  283.     else
  284.     if [ "$1" = "EXTENDED" ]
  285.     then
  286.         echo 2
  287.     else
  288.         echo FALSE
  289.     fi
  290.     fi
  291. }
  292.  
  293. #
  294. # test_for_package <candidate>
  295. #
  296. test_for_package()
  297. {
  298.     #abc=`echo $1 | tr -s '[:upper:]' '[:lower:]'`
  299.     abc=$(echo $1 | tr '[A-Z]' '[a-z]')
  300.  
  301.     #
  302.     # See if first parameter was a PACKAGE
  303.     #
  304.     if [ -f ./$PLATFORM/$abc.plist ]
  305.     then
  306.     echo $abc
  307.     else
  308.     echo FALSE
  309.     fi
  310. }
  311.  
  312. #
  313. # parse the command line arguments
  314. #
  315. parse_arguments()
  316. {
  317.     # check explicitly for package and test parameters, and assume 
  318.     # anything else is the plaftorm validation
  319.     #
  320.     while [ $# -gt 0 ]
  321.     do
  322.     result=`test_for_product $1`
  323.     if [ "$result" = "FALSE" ]
  324.     then
  325.         result=`test_for_test $1`
  326.         if [ "$result" = "FALSE" ]
  327.         then
  328.         result=`test_for_package $1`
  329.         if [ "$result" = "FALSE" ]
  330.         then
  331.             printf "INSTALL26: Unknown parameter %s\n" $1
  332.             usage
  333.         else
  334.             PACKAGE=$result
  335.         fi
  336.         else
  337.         do_test=$result
  338.         fi
  339.     else
  340.         PLATFORM=$result
  341.     fi
  342.     shift
  343.     done
  344.  
  345.     #######################
  346.     # Check the parameters
  347.     #
  348.     if [ ! -f ./$PLATFORM/$PACKAGE.plist ]
  349.     then
  350.     printf "INSTALL26: Incorrect package %s\n" $PACKAGE
  351.     usage
  352.     fi
  353.     case $PLATFORM in
  354.     "SWBD12" ) REVISION=3;;
  355.             *) REVISION=2;;
  356.     esac
  357. }
  358.  
  359. #------------------------------
  360. # BEGIN MAIN PART OF THE INSTALL26
  361. # BEGIN MAIN PART OF THE INSTALL26
  362. #------------------------------
  363.  
  364. if [ -z `pwd | grep load` ]
  365. then
  366.     echo "INSTALL26: ERROR install directory is not mounted on /load."
  367.     exit 1
  368. fi
  369.  
  370. for mnt in `mount | cut -d" " -f3 | grep "/mnt"`
  371. do
  372.     umount $mnt
  373. done
  374.  
  375. FS='ext3'
  376. FSOPTS='-f'
  377. DEVICE='hda'
  378. TMPMNT='/mnt'
  379. do_test=NOTEST
  380. warn_count=0
  381. continue=TRUE
  382. OSLDR0=0
  383. OSLDR1=0
  384. ATABOOT=0
  385. error=FALSE
  386.  
  387. echo "INSTALL26: Installing Linux 2.6 ..."
  388.  
  389. PACKAGE="no_package_defined"
  390. node="platform"
  391. major=`grep $node\$ /proc/devices | cut -d ' ' -f 1`
  392. if [  $major ]; then
  393.     rm -f /dev/$node
  394.     mknod  /dev/$node c $major 0
  395. fi
  396.  
  397. PLATFORM=`sin | \
  398.           /bin/grep Platform | \
  399.           /usr/bin/cut -d" " -f2 | \
  400.           /usr/bin/cut -d"," -f1`
  401.  
  402. REVISION=`sin | \
  403.           /bin/grep Platform | \
  404.           /usr/bin/cut -d" " -f4`
  405.  
  406. ######################
  407. # parse the arguments
  408. parse_arguments $*
  409.  
  410. case "$PLATFORM" in
  411.         "SWBD12" ) FS=xfs ;;
  412.         "SWBD21" ) FS=xfs ;;
  413.         "SWBD22" ) FS=xfs ;;
  414.                 *) ;;
  415. esac
  416.  
  417. # for debug use only
  418. #echo "platform=$PLATFORM"
  419. #echo "revision=$REVISION"
  420. #echo "package=$PACKAGE"
  421. #echo "FS=$FS"
  422.  
  423. #######################################
  424. # Determine whether it supports ATA boot
  425. #
  426. case $PLATFORM in
  427.     "SWBD10" ) ATABOOT=0;;
  428.     "SWBD12" ) ATABOOT=0;;
  429.     "SWBD21" ) ATABOOT=0;;
  430.     "SWBD22" ) ATABOOT=0;;
  431.     "SWBD23" ) ATABOOT=0;;
  432.     "SWBD26" ) ATABOOT=0;;
  433.     "SWBD27" ) ATABOOT=0;;
  434.     "SWBD32" ) ATABOOT=0;;
  435.     "SWBD42" ) ATABOOT=0;;
  436.     *) ATABOOT=1;;
  437. esac
  438.  
  439. ##############################################
  440. # Let's get down to it and install this thing
  441. #
  442. echo "INSTALL26: INSTALL26ING for platform: $PLATFORM revision: $REVISION package $PACKAGE"
  443.  
  444. #echo "INSTALL26: Finding module dependencies..."
  445. #if [ ! -h /lib/modules/`uname -r` ]; then
  446. #    ln -sf default /lib/modules/`uname -r`
  447. #fi
  448. #
  449. #do_command FALSE depmod -Aqe
  450.  
  451. if [ ! -d /proc/ide/ide0 ]
  452. then
  453.     echo "INSTALL26: Starting services..."
  454.  
  455.     do_command TRUE chkconfig pcmcia on
  456.     do_command TRUE /etc/rc.d/init.d/pcmcia start
  457. fi
  458.  
  459. max_count=30
  460. echo -n "INSTALL26: Determining drive capacity (MAX $max_count sec)"
  461.  
  462. count=0
  463. while [ ! -f /proc/ide/${DEVICE}/capacity -a $count -lt $max_count ]; do
  464.     echo -n "."
  465.     sleep 1
  466.     count=`expr $count + 1`
  467. done
  468. echo ""
  469. if [ $count -ge $max_count ]
  470. then
  471.     echo "INSTALL26: Failed to determine drive capacity. Perhaps pcmcia driver did not start correctly."
  472.     error=TRUE
  473.     exit_out
  474. fi
  475.  
  476. echo "INSTALL26: Partitioning drive..."
  477.  
  478. BLOCKS=`cat /proc/ide/${DEVICE}/capacity`
  479. ((HALFMB = ($BLOCKS >> 12)))
  480. ((ENDMB = 2 * $HALFMB))
  481.  
  482. echo "INSTALL26: Drive Size: BLOCKS=${BLOCKS} HALFMB=${HALFMB} ENDMB=${ENDMB}"
  483.  
  484. # Workaround until the page_alloc.c bug is fixed... -bk
  485. if [ "$PLATFORM" = "SWBD24" ]; then
  486.     ((HALFMB = 128))
  487.     ((ENDMB = 256))
  488. fi
  489.  
  490. # first hammer any existent filesystem into oblivion
  491. printf "%1024s" fabos > /dev/hda
  492.  
  493. # do partitioning setup
  494. echo "INSTALL26: Partition setup for /dev/${DEVICE} ..."
  495. echo "INSTALL26: Partition 1:  0  -  $HALFMB"
  496. echo "INSTALL26: Partition 2:  $HALFMB  -  $ENDMB"
  497. clobber_label               # Assure parted mklabel will work...
  498. do_command TRUE parted -s /dev/${DEVICE} mklabel msdos
  499. do_command TRUE parted -s /dev/${DEVICE} mklabel msdos
  500. do_command TRUE parted -s /dev/${DEVICE} mkpart primary $FS 0.000 $HALFMB.000
  501. do_command TRUE parted -s /dev/${DEVICE} mkpart primary $FS $HALFMB.000 $ENDMB.000
  502. do_command TRUE parted -s /dev/${DEVICE} print
  503.  
  504. # create filesystems ext3 or xfs
  505. echo "INSTALL26: Creating $FS file system on /dev/${DEVICE}${partition}..."
  506.  
  507. case "$FS" in
  508.    "ext3")
  509.       do_command TRUE mke2fs -g32768 -b4096 -j /dev/hda1
  510.       do_command TRUE tune2fs -c 0 -i 0 /dev/hda1
  511.       do_command TRUE mke2fs -g32768 -b4096 -j /dev/hda2
  512.       do_command TRUE tune2fs -c 0 -i 0 /dev/hda2
  513.    ;;
  514.    * )
  515.       do_command TRUE mkfs -t $FS $FSOPTS /dev/hda1
  516.       do_command TRUE mkfs -t $FS $FSOPTS /dev/hda2
  517.    ;;
  518. esac
  519.  
  520. for partition in 1 2; do
  521.   if [ $continue = TRUE ]
  522.   then
  523.     #
  524.     # if this is a Ulysses box, then program the backplane mac address
  525.     #
  526.     if [ ${partition} -eq 1 ]
  527.     then
  528.     if [ -f ./$PLATFORM/bpmac -a "$PLATFORM" != "SWBD21" ]
  529.     then
  530.         echo "INSTALL26: Setting up Private Ethernet mac address"
  531.         do_command TRUE ./$PLATFORM/bpmac
  532.     fi
  533.     fi
  534.  
  535.     if [ "$do_test" = NOTEST ]
  536.     then
  537.     echo "INSTALL26: Skipping the memory tests"
  538.     else
  539.     if [ "$do_test" = 1 ]
  540.     then
  541.         echo "INSTALL26: Running the Read/Write memory tests"
  542.     else
  543.         echo "INSTALL26: Running the EXTENDED memory tests"
  544.     fi
  545.  
  546.     # use the platform specific sbin, default to 405 
  547.     if [ -f ./$PLATFORM/sbin/blockcheck ]
  548.     then
  549.         echo "INSTALL26: Running ./$PLATFORM/sbin/blockcheck"
  550.         ./$PLATFORM/sbin/blockcheck -t $do_test -v /dev/${DEVICE}${partition}
  551.     else
  552.         echo "INSTALL26: Running ./sbin/blockcheck"
  553.         ./sbin/blockcheck -t $do_test -v /dev/${DEVICE}${partition}
  554.     fi
  555.     fi
  556.  
  557.     echo "INSTALL26: Mounting Primary FileSystem(/dev/${DEVICE}${partition}) on ${TMPMNT}..."
  558.     #echo "INSTALL26: fs=${FS}"
  559.     #echo "INSTALL26: device=${DEVICE}"
  560.     #echo "INSTALL26: partition=${partition}"
  561.     #echo "INSTALL26: tmpmnt=${TMPMNT}"
  562.  
  563.     do_command TRUE mount -t $FS /dev/${DEVICE}${partition} ${TMPMNT}
  564.  
  565.     #
  566.     # Install soft-link for modules
  567.     #
  568.     if [ ! -d /mnt/lib ]; then
  569.        do_command TRUE mkdir /mnt/lib
  570.     fi
  571.     if [ ! -d /mnt/lib/modules ]; then
  572.        do_command TRUE mkdir /mnt/lib/modules
  573.     fi
  574.     do_command TRUE ln -sf default /mnt/lib/modules/`uname -r`
  575.  
  576.     #
  577.     # Make sure groups are installed.
  578.     #
  579.     if [ ! -d /mnt/etc ]; then
  580.        do_command TRUE mkdir /mnt/etc
  581.     fi
  582.     do_command TRUE cat ./$PLATFORM/group > /mnt/etc/group
  583. #    do_command FALSE cat > /mnt/etc/group << EOF
  584. #root::0:root
  585. #bin::1:root,bin,daemon
  586. #daemon::2:root,bin,daemon
  587. #sys::3:root,bin,adm
  588. #EOF
  589.     #
  590.     # Create fabos/lib
  591.     #
  592.     if [ ! -d /mnt/fabos ]; then
  593.        do_command TRUE mkdir -p /mnt/fabos/share
  594.     fi
  595.     if [ ! -d /mnt/fabos/lib ]; then
  596.        do_command TRUE mkdir /mnt/fabos/lib
  597.     fi
  598.  
  599.     #
  600.     # Fix termcap / readline chicken and egg problem
  601.     #
  602.     do_command TRUE cp /lib/libtermcap.so.1.3 /mnt/lib
  603.  
  604.     #
  605.     # Create device nodes and symlinks that can only be created
  606.     # at runtime.
  607.     # First the mtd symlinks
  608.     #
  609.     if [ ! -d /mnt/dev ]; then
  610.        do_command TRUE mkdir /mnt/dev
  611.     fi
  612.  
  613.     while read var1 var2 var3 var4 var5
  614.     do
  615.         # We do this check to get rid of initial comment string
  616.         if [ "$var1" = "dev:" ];
  617.         then
  618.             continue;
  619.         fi
  620.  
  621.         # What if its an empty line
  622.         if [ "x$var1" = "x" ];
  623.         then
  624.             continue;
  625.         fi
  626.         # Strip devname off the ":"
  627.         devname=${var1%:}
  628.  
  629.         # If var4 contains a ":" tmpvar will be NULL
  630.         tmpvar=${var4##*:*}
  631.  
  632.         # Check if tmpvar is NULL
  633.         if [ "x$tmpvar" = "x" ]; then
  634.             # Build dev_alias with removing initial '"'
  635.             dev_alias=${var4#\"};
  636.             # dev_alias does not need the ending:
  637.             dev_alias=${dev_alias%:};
  638.  
  639.             # Do the actual linking for the dev_alias->devname
  640.             ln -s -f /dev/$devname /mnt/dev/$dev_alias
  641.                     #echo "INSTALL26:creating link: /dev/$devname /mnt/dev/$dev_alias"
  642.         fi
  643.     done </proc/mtd
  644.  
  645.     # Next the platform device
  646.     node="platform"
  647.     major=`grep $node\$ /proc/devices | cut -d ' ' -f 1`
  648.     if [  $major ]; then
  649.     rm -f /mnt/dev/$node
  650.     mknod  /mnt/dev/$node c $major 0
  651.     fi
  652.  
  653.     installrpms $PACKAGE.plist ${TMPMNT}
  654.  
  655.     copy_image_lists $PACKAGE.plist version.conf ${TMPMNT}
  656.  
  657.     reset_glibc ${TMPMNT}
  658.  
  659.     ####################################
  660.     # Run platform specific install if required
  661.     #if [ -f $PLATFORM/install ]
  662.     #then
  663.     #echo "INSTALL26: Running $PLATFORM/install"
  664.     #$PLATFORM/install $PLATFORM $PACKAGE
  665.     #fi
  666.  
  667.     ####################################
  668.     # load the manufacturing additions
  669.     # After the normal rpm's and PLATFORM specific process has been completed,
  670.     # then install the manufacturing overlays it they exist. We must be 
  671.     # specific, and only take this action if the PACKAGE is factory or 
  672.     # development. DO NOT do this for the release SW.
  673.  
  674.     if [ "$PACKAGE" = factory -o "$PACKAGE" = development -o "$PACKAGE" = foslight ]
  675.     then
  676.     for fil in `ls ./$PLATFORM/Mfgtests/*/* 2>/dev/null`
  677.     do
  678.         script=`echo $fil | cut -d"/" -f4-`
  679.         echo "INSTALL26: Loading $script"
  680.         do_command TRUE cp $fil /mnt/fabos/$script
  681.         do_command TRUE chmod 0755 /mnt/fabos/$script
  682.         do_command TRUE chgrp factory /mnt/fabos/$script
  683.         # if there are additions for manufacturing, then the rpm -V that 
  684.         # happens during boot (controlled by the NoSysTest boot 
  685.         # environment variable) will most likely fail, so turn of the
  686.           # the rpm -V (only once though).
  687.     done
  688.     fi
  689.  
  690.     echo "INSTALL26: Updating the file system table..."
  691.  
  692.     cat > ${TMPMNT}/etc/fstab << EOF
  693. /dev/root    /        $FS    rw,noatime    0 0
  694. none        /proc        proc    defaults    0 0
  695. none        /dev/pts    devpts    mode=620    0 0
  696. EOF
  697.  
  698.     echo "INSTALL26: Fixing up pdm wrong directory for rcp"
  699.     do_command TRUE ln -sf ../usr/bin/rcp /mnt/bin/rcp
  700.  
  701.     echo "INSTALL26: Fixing up /etc/modules.conf..."
  702.  
  703.     do_command TRUE cat > /mnt/etc/modules.conf << EOF
  704. keep
  705. path=/fabos/modules
  706. alias eth1 eepro100
  707. EOF
  708.  
  709.     echo "INSTALL26: Fixing fabos/sbin/sname"
  710.     if [ ! -x /mnt/fabos/sbin/sname ] ; then
  711.           ln -sf ../bin/sname /mnt/fabos/sbin/sname
  712.     fi
  713.  
  714.     echo "INSTALL26: Setting up release file"
  715.     # use the platform specific sbin, default to 405 
  716.     if [ -f ./sbin/create_release_file ]
  717.     then
  718.        echo "INSTALL26: Running ./sbin/create_release_file"
  719.        ./sbin/create_release_file -p $PLATFORM -l $PACKAGE
  720.     else
  721.        if [ -f ./$PLATFORM/sbin/create_release_file ]
  722.        then
  723.           echo "INSTALL26: Running ./$PLATFORM/sbin/create_release_file"
  724.           ./$PLATFORM/sbin/create_release_file -p $PLATFORM -l $PACKAGE
  725.        else
  726.           echo "INSTALL26: Unable to Setup create_release_file"
  727.       error=TRUE
  728.       exit_out
  729.        fi
  730.     fi
  731.  
  732.     #
  733.     # Remove circular link.
  734.     #
  735.     echo "INSTALL26: Remove circular link in /lib/modules"
  736.  
  737.     rm /mnt/lib/modules/`uname -r`/default 2>/dev/null 1>&2
  738.  
  739.     if [ "$PACKAGE" = foslight ]
  740.     then
  741.     echo "INSTALL26: DISABLE POST ..."
  742.  
  743.     # only disable POST on the first partition
  744.     if [ ${partition} -eq 1 ]
  745.     then
  746.         do_command TRUE touch /mnt/var/diagd.skippost 2>/dev/null
  747.         do_command TRUE rm -f /mnt/etc/config/fabos  2>/dev/null
  748.         do_command TRUE echo "off" > /mnt/etc/config/fabos
  749.     fi
  750.     fi
  751.  
  752.     if [ "$PACKAGE" = factory -o "$PACKAGE" = dvt -o "$PACKAGE" = nfdiag ]
  753.     then
  754.     echo "INSTALL26: Fixing up /etc/config entries..."
  755.  
  756.     # only turn off fabos on the first partition
  757.     # This allows manufacturing process to use fruinit on clean install
  758.     # and having the second partition on allows for badrootdev support
  759.     # during power cycle tests.
  760.     if [ ${partition} -eq 1 ]
  761.     then
  762.         do_command TRUE rm -f /mnt/etc/config/fabos  2>/dev/null
  763.         do_command TRUE echo "off" > /mnt/etc/config/fabos
  764.         do_command TRUE rm -f /mnt/etc/config/foslight  2>/dev/null
  765.         do_command TRUE echo "on" > /mnt/etc/config/foslight
  766.         do_command TRUE rm -f /mnt/etc/config/chubby  2>/dev/null
  767.         do_command TRUE echo "off" > /mnt/etc/config/chubby
  768.     fi
  769.     # turn off the login timeout
  770.     do_command TRUE cat > /mnt/etc/idle.conf << EOF
  771. 0
  772. EOF
  773.     do_command TRUE rm -f /mnt/etc/config/webtools 2>/dev/null
  774.     do_command TRUE rm -f /mnt/etc/config/fwd 2>/dev/null
  775.     do_command TRUE rm -f /mnt/etc/config/evmd 2>/dev/null
  776.     do_command TRUE rm -f /mnt/etc/config/snmpd 2>/dev/null
  777.     do_command TRUE rm -f /mnt/etc/config/swdd 2>/dev/null
  778.     do_command TRUE rm -f /mnt/etc/config/wdtd 2>/dev/null
  779.  
  780.     do_command TRUE echo "off" > /mnt/etc/config/webtools
  781.     do_command TRUE echo "off" > /mnt/etc/config/fwd
  782.     do_command TRUE echo "off" > /mnt/etc/config/evmd
  783.     do_command TRUE echo "off" > /mnt/etc/config/snmpd
  784.     do_command TRUE echo "off" > /mnt/etc/config/swdd
  785.     do_command TRUE echo "off" > /mnt/etc/config/wdtd
  786.  
  787.     do_command TRUE rm -f /mnt/etc/rc.d/rc.pwdinit 2>/dev/null
  788.  
  789.     fi
  790.  
  791.    # nfdiag support
  792.    if [ "$PACKAGE" = "nfdiag" ]
  793.    then
  794.       if [ ${partition} -eq 1 ]
  795.       then
  796.          # Disable fabos
  797.          do_command TRUE echo "off" > /mnt/etc/config/fabos
  798.  
  799.          # run nfdiag in init level 2
  800.          do_command TRUE ln -s ../init.d/network /mnt/etc/rc.d/rc2.d/S01network
  801.          do_command TRUE cp /mnt/nfabos/bin/diagrun.sh /mnt/etc/rc.d/rc2.d/S30diags
  802.       fi
  803.    fi
  804.  
  805.     if [  $major ]; then
  806.         rm -f /mnt/dev/$node
  807.         mknod  /mnt/dev/$node c $major 0
  808.     fi
  809.    
  810.     ####################################
  811.     # Copy kernel image to user flash only once
  812.     #
  813.     if [ ${ATABOOT} -eq 0 -a ${partition} -eq 1 ]
  814.     then
  815.     mtds=`cat /proc/mtd | grep kernel | cut -f1 -d: | xargs echo`
  816.     for mtd_dev in ${mtds} ; do
  817.         echo "INSTALL26: Writing Kernel to partition ${mtd_dev} of Kernel Flash"
  818.             do_command TRUE /mnt/sbin/flash_write \
  819.             -i /mnt/boot/zImage.tree.initrd -o /dev/${mtd_dev}
  820.     done
  821.     fi
  822.  
  823.     ####################################
  824.     # Clear the panic dump partition
  825.     #
  826.     if [ ${partition} -eq 1 ]
  827.     then
  828.     mtds=`cat /proc/mtd | grep log | cut -f1 -d: | xargs echo`
  829.     for mtd_dev in ${mtds} ; do
  830.         echo "INSTALL26: Clearing the partition ${mtd_dev} of Kernel Flash"
  831.         cat /dev/zero > /dev/${mtd_dev} 2> /dev/null
  832.     done
  833.  
  834.     fi
  835.  
  836.     ####################################
  837.     # touch /mnt/etc/fabos/upgrade_status1 and /mnt/etc/fabos/upgrade_state
  838.     # so that FSS will not overwrite these files after firmwaredownload -s on
  839.     # standby CP
  840.     touch /mnt/etc/fabos/upgrade_status1
  841.  
  842.     ####################################
  843.     # touch /mnt/etc/fabos/lisenses to create blank
  844.     # license file for 24 bit licenses
  845.     touch /mnt/etc/fabos/licenses
  846.  
  847.     #########################################################
  848.     # Generate kernel image map file and find its starting LBA
  849.     ##########################################################
  850.     # first a kludge to fix mapinst bug, remove /dev/fd*
  851.     do_command TRUE rm -rf /dev/fd* >/dev/null 2>&1
  852.     tmp=`/mnt/sbin/mapinst /mnt/boot/zImage.tree.initrd | cut -d ':' -f 2` 2>/dev/null
  853.     if [ ${partition} -eq 1 ]
  854.     then
  855.        OSLDR0=`printf "ATA()0x%x\n" $tmp`
  856.        echo "INSTALL26: mapinst generated $OSLDR0"
  857.     else
  858.        OSLDR1=`printf "ATA()0x%x\n" $tmp`
  859.        echo "INSTALL26: mapinst generated $OSLDR1"
  860.     fi
  861.    
  862.     # save bootenv & friends for use after fs is unmounted
  863.     if [ ${partition} -eq 1 ] ; then
  864.        echo "INSTALL26: save copy of bootenv for later use ..."
  865.        if [ ! -f /bin/bootenv  ]; then
  866.           do_command TRUE cp /mnt/sbin/bootenv /bin/.
  867.        fi
  868.        if [ ! -f /lib/libbootenv.so.1.0  ]; then
  869.           do_command TRUE cp /mnt/lib/libbootenv.so.1.0 /lib/.
  870.        fi
  871.     fi
  872.  
  873.     # Store the checksums for ldconfig and ld.so
  874.     chroot $ROOT /sbin/getvf
  875.     vf_val=$?
  876.     if [ ${vf_val} -eq 1 ];  then
  877.         do_command TRUE cp $ROOT/etc/fabos/user_vf.db.default $ROOT/etc/fabos/user.db
  878.         echo "getvf returned $vf_val. VF Database is copied." >> $TMPMNT/var/log/user.log
  879.     else
  880.         echo "getvf returned $vf_val. Non-VF Database is copied." >> $TMPMNT/var/log/user.log
  881.     fi
  882.  
  883.  
  884.     echo "INSTALL26: Unmounting file system..."
  885.     do_command TRUE umount ${TMPMNT}
  886.  
  887.   fi
  888. done
  889.  
  890. ####################################
  891. # Update boot environment
  892. #
  893.  
  894. #
  895. # The new version of bootenv command checks the checksum 
  896. # of bootenv partition. This doesn't work on platforms
  897. # that don't support dual bootenv partitions and thus don't
  898. # have partition checksum. So we run bootenv with -i 
  899. # option to invalidate partition checksum first. This tell
  900. # bootenv command to ignore checksum. 
  901. #
  902. echo "INSTALL26: Setup of Boot Environment"
  903. bootenv  > /dev/null 2>&1
  904. if [ $? -ne 0 ]
  905. then
  906.   bootenv -i
  907.   do_command TRUE bootenv > /dev/null 2>&1
  908. fi
  909.  
  910. echo "INSTALL26: Setting boot environment parameters..."
  911. # remove the system test override variable
  912. # NOTE do not use do_command on this because the variable may not exist,
  913. # and the command will return a fail status, but this is not an indication
  914. # of a failing install
  915. bootenv -u NoSysTest 2> /dev/null
  916.  
  917. # The special characters in this bootenv variable value prevent the use of 
  918. # do_command. So I have copied the content of do_command here.
  919. bootenv -u LoadIdentifier 2> /dev/null
  920. bootenv -v LoadIdentifiers "Fabric Operating System;Fabric Operating System"
  921.  
  922. #
  923. #Update OSLoader
  924. #
  925. if [ ${ATABOOT} -eq 1 ]
  926. then
  927.    do_command TRUE bootenv -v OSLoader "${OSLDR0};${OSLDR1}"
  928. else
  929.    do_command TRUE bootenv -v OSLoader 'MEM()0xF0000000;MEM()0xF0800000'
  930. fi
  931.  
  932. do_command TRUE bootenv -v OSRootPartition "${DEVICE}1;${DEVICE}2"
  933. do_command TRUE bootenv -v AutoLoad 'yes'
  934. do_command TRUE bootenv -v InitTest 'MEM()'
  935. do_command TRUE bootenv -v OSLoadOptions 'quiet'
  936. do_command TRUE bootenv -v SkipWatchdog 'yes'
  937. # NOTE do not use do_command on this because the variable may not exist,
  938. # and the command will return a fail status, but this is not an indication
  939. # of a failing install
  940. bootenv -u BadRootDev 2> /dev/null
  941. bootenv -u SoftUpgrade 2> /dev/null
  942. bootenv -u Upgrade 2> /dev/null
  943.  
  944. # Update some boot environment for nfdiag package
  945. # Overwrite OSLoadOption and run nfdiag in init level 2
  946. if [ "$PACKAGE" = "nfdiag" ]
  947. then
  948.    do_command TRUE bootenv -v OSLoadOptions '2'
  949.    if [ "$PLATFORM" = "SWBD55" -o "$PLATFORM" = "SWBD68" -o "$PLATFORM" = "SWBD81"]
  950.    then
  951.       bootenv -v bootcmd "setenv bootargs mem=\${mem} \${OSLoadOptions};ataboot;bootm 0x400000"
  952.       bootenv -v initrd_high "0x20000000"   
  953.    fi
  954. else
  955.    if [ "$PLATFORM" = "SWBD55" -o "$PLATFORM" = "SWBD68" -o "$PLATFORM" = "SWBD81"]
  956.    then
  957.       bootenv -v bootcmd "setenv bootargs mem=\${mem} \${OSLoadOptions};ataboot;bootm 0x400000"
  958.       bootenv -v initrd_high "0x20000000"   
  959.    fi
  960. fi
  961.     
  962. ####################################
  963. # Output ending instructions
  964. #
  965. if [ -f $PLATFORM/ending_instructions ]
  966. then
  967.     cat $PLATFORM/ending_instructions
  968. else
  969.     echo ""
  970.     echo "INSTALL26: No platform specific instructions found."
  971.     echo "INSTALL26: You may now reboot the system."
  972.     echo ""
  973.     echo "INSTALL26: Be sure you have a console connection to the system before rebooting."
  974.     echo ""
  975. fi
  976. ####################################
  977. # Output overall results
  978. #
  979. exit_out
  980.