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 / myid < prev    next >
Text File  |  2010-11-10  |  2KB  |  92 lines

  1. #!/bin/bash
  2. PATH=/bin:/usr/bin:$PATH
  3.  
  4. # getHaStat function
  5. # we return 100 for active
  6. #           101 for standby
  7. #           102 for unknown state
  8.  
  9.  
  10. getHaStat()
  11. {
  12.     hastat=102
  13.     this_active_standby="N/A"    
  14.     typeset -a lines
  15.     # Break the HASHOW into lines
  16.     IFS=$'\n' lines=($HASHOW)
  17.     for l in "${lines[@]}"
  18.       do
  19.       case $l in
  20.       (*Local*Active) hastat=100; this_active_standby="Active";;
  21.       (*Local*Standby) hastat=101; this_active_standby="Standby";;
  22.       esac
  23.     done
  24. }
  25.  
  26. getttystatus()
  27. {
  28. # let us obtain the tty session
  29.     local this_tty=$(/usr/bin/tty)
  30.  
  31. # let us obtain the Active/Standby status
  32.  
  33.     case $this_tty in
  34.     (/dev/pts/*)
  35.     local ip=$LOCAL_IP
  36.     case "$LOCAL_IP" in
  37.         (::[Ff][Ff][Ff][Ff]:*[^0-9.]*) ;; # Handle a very rare cornercase
  38.         (::[Ff][Ff][Ff][Ff]:**) ip=${LOCAL_IP#::[Ff][Ff][Ff][Ff]:};;
  39.     esac
  40.     local ss='s/#.*//;/^[\t ]*'"$ip"'[\t ]\+\([^\t ]\+\).*/{s//\1/ip;q;}'
  41.     this_cp_sw=$(/bin/sed -ne "$ss" /etc/hosts)
  42.     message1="${this_cp_sw} (${ip})"
  43.     ;;
  44.  
  45.     (/dev/ttyS1)
  46.     message1="Modem Line (/dev/ttyS1)"
  47.     ;;
  48.  
  49.     (/dev/ttyS0|/dev/console|/dev/con)
  50.     message1="Console Port (/dev/ttyS0)"
  51.     ;;
  52.  
  53.     (*)
  54.     message1="Unknown (tty returned '$this_tty')"
  55.     ;;
  56.  
  57.     esac
  58.     printf "%s " "$message1"
  59. }
  60.  
  61.  
  62.  
  63. getredundantstatus()
  64. {
  65. #next let us see if the system is redundant or non redundant
  66.     case "${HASHOW}" in
  67.     (*[Nn][Oo][Nn]-[Rr][Ee][Dd][Uu][Nn][Dd][Aa][Nn][Tt]*)
  68.     this_redundant_non_redundant="Non-Redundant"
  69.     ;;
  70.     (*[Ss][Tt][Aa][Nn][Dd][Bb][Yy]*)
  71.     this_redundant_non_redundant="Redundant"
  72.     ;;
  73.     (*)
  74.     this_redundant_non_redundant="HA-Status-N/A"
  75.     ;;
  76.     esac
  77. }
  78.  
  79. main()
  80. {
  81.     printf "\n\tCurrent Switch:  "
  82.     /fabos/cliexec/.sname
  83.     HASHOW=$(hashow)
  84.     printf "\tSession Detail:  "
  85.     getttystatus
  86.     getredundantstatus
  87.     getHaStat
  88.     printf "%s\n" "${this_active_standby} ${this_redundant} ${this_redundant_non_redundant}"
  89. }
  90.  
  91. main
  92.