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 / SWBD63 / fabos-6.3.2b-10.ppc.rpm / fabos-6.3.2b.10.cpio.gz / fabos-6.3.2b.10.cpio / fabos / cliexec / reboot < prev    next >
Text File  |  2010-11-10  |  4KB  |  165 lines

  1. #!/bin/sh
  2. #
  3. #    Copyright (c) 2001 Brocade Communications Systems, Inc.
  4. #    All rights reserved.
  5. #
  6. #    File name:   reboot
  7. #    Module name: fabos/src/utils/sys
  8. #
  9. #    This script is wrapper to the traditional /sbin/reboot command 
  10. #    so that /fabos/sbin/ will contain this wrapper to 
  11. #    1, Allow admin account to use it. admin account should not have 
  12. #    /sbin/reboot (linux reboot) access in its PATH. If this reboot was
  13. #       invoked from dual CP actiove CP side, A prompt will show up for user
  14. #       confirmation.
  15. #    2, FOS can call this function with -s option to skip the prompt. 
  16. #    3,    FOS should call this function with -r option for reboot reason.
  17. #    The reboot reason will be displayed in raslog meassge HAM-1004
  18. #    after switch boot up.
  19. #    The reboot reason for -r option has to be one word without spcae.
  20. #    example: reboot -r ChassisConfig
  21. #
  22. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/fabos/bin:/fabos/sbin
  23.  
  24. chassis_info=`getchassisconfig`
  25.  
  26. ischassis=`echo $chassis_info | \
  27.         sed -n -e 's/.*Chassis based system: //gp' | \
  28.         sed -n -e 's/ .*//gp'`
  29.  
  30. #get reboot reason
  31. REASON="Reboot"
  32. FAST=""
  33. SKIP_PROMPT="No"
  34. CREBOOT="No"
  35. while getopts r:sfc c > /dev/null
  36. do
  37.     case $c in
  38.     r) REASON=$OPTARG
  39.        ;;
  40.     s) SKIP_PROMPT="Yes"
  41.         ;;
  42.     f) FAST="-f"   
  43.        ;;
  44.     c) CREBOOT="Yes"
  45.        ;;
  46.        *)
  47.        echo "usage: reboot"
  48.        exit 1
  49.        ;;
  50.     esac
  51. done
  52.  
  53. #OPTION=$*
  54. #remove -s and -r option
  55. #echo $REASON
  56. #OPTION=`echo $OPTION | /bin/sed "s/-r[ \t]\{1,\}[^ ]\{1,\}//;s/[ \t]*-s[ \t]\{1,\}//;s/[ \t]-s$//"`
  57. OPTION=$FAST
  58. #echo $OPTION
  59.  
  60. # #############################
  61. # This is added to support the forced reset of the Zues FPGA, note that
  62. # cpu reset (as done by this reboot) is not sufficient.
  63. # The details of how and when are hidden in the driver which has exported
  64. # this /proc/node
  65. #
  66.  
  67. # swbd
  68. #
  69. # Retrieve the current system platform name, of the form "SWBDn", where n
  70. # is cardinal number, assuming a sin/hinv input stream.
  71. #
  72. swbd() {
  73.     /bin/sed -n -e 's/^.*\(SWBD[[:digit:]]\{1,\}\).\+$/\1/gp'
  74. }
  75.  
  76. # Determine the system platform identifier.
  77. SWBD=$(sin | swbd 2> /dev/null)
  78.  
  79. case ${SWBD##SWBD} in
  80.  
  81.     '76' )
  82.     zeus_fault=`cat /proc/fabos/blade/0/info | grep "blade fault reason" | grep 53`
  83.     if [ "$zeus_fault" ]
  84.     then
  85.         /sbin/fpga_update.sh
  86.     fi
  87.  
  88.     if [ -e /etc/init.d/zeus_reconfig ]
  89.     then
  90.         /etc/init.d/zeus_reconfig start
  91.         /etc/init.d/zeus_reconfig stop
  92.     fi
  93.  
  94.     ;;
  95.  
  96.     '72' )
  97.         #
  98.         # The devices that are connected to the embedded switches take more time to
  99.         # detect that the switch has been rebooted. This is because, the OLS is sent
  100.         # only when the chip is initialized during the next reboot session. So, issue
  101.         # a switchdisable to bring down the ports explicitly before the reboot to
  102.         # allow the hosts to detect the reboot scenario much earlier.
  103.         #
  104.         /fabos/cliexec/switchdisable
  105.  
  106.     ;;
  107.     
  108. esac
  109.  
  110. #
  111. # Only prompt user on active cp on a chassis based system
  112. # this reboot request was not called from "chassisReboot"
  113. #
  114. if [ "$ischassis" = "Yes" -a "$CREBOOT" = "No" ]; then
  115.     hashow_cmd="hashow -l"
  116.  
  117.     case "$(hashow -l)" in
  118.     *ACTIVE*HA_ENABLED*)
  119.         is_active="Yes"
  120.         is_hadisabled="No"
  121.         ;;
  122.     *STANDBY*HA_ENABLED*)
  123.         is_active="No"
  124.         is_hadisabled="No"
  125.         ;;
  126.     *STANDBY*HA_DISABLED*)
  127.         is_active="No"
  128.         is_hadisabled="Yes"
  129.         ;;
  130.     *ACTIVE*HA_DISABLED*)
  131.         is_active="Yes"
  132.         is_hadisabled="Yes"
  133.         ;;
  134.     esac
  135.  
  136.     if [ "$is_active" = "Yes" -a "$SKIP_PROMPT" = "No" ]; then
  137.         if [ "$is_hadisabled" = "No" ]; then
  138.             # text here revised per defect 78391
  139.             echo "Warning: This command is being run on a control processor (CP)"
  140.             echo "based system and will cause the active CP to reboot."
  141.         else
  142.             echo "Warning: This command is being run on a control processor (CP)"
  143.             echo "based system. Because HA is disabled, it will cause both active"
  144.             echo "and the standby CP to reboot."
  145.             echo "HA will be enabled after boot up."
  146.         fi
  147.  
  148.         read -p "Are you sure you want to reboot the active CP [y/n]?" in
  149.         if [ "$in" != "y" -a "$in" != "Y" ]; then
  150.             exit
  151.         fi
  152.     fi
  153.  
  154.     # If this is this is active CP and HA is currently then reboot
  155.     # the chassis and retain mastership.
  156.     if [ "$is_active" = "Yes" -a "$is_hadisabled" = "Yes" ]; then
  157.         /fabos/sbin/chassisReboot -m
  158.     fi
  159. fi
  160.  
  161. #record boot reason
  162. /sbin/hainfo RebootReason $REASON
  163. /sbin/reboot $OPTION
  164.  
  165.