#!/bin/bash
FILE_VERSION=97
FPGA_VERSION=`/usr/bin/head -2 /proc/system/fpga |
 /usr/bin/tail -1 |
 /usr/bin/cut -d' ' -f2`
echo "The current FPGA version is ${FPGA_VERSION}."
if [ "$FPGA_VERSION" = "$FILE_VERSION" ]
then
 echo "FPGA is up to date. No further action is required."
else
 echo "FPGA version $FILE_VERSION is available."
 echo "You should update the FPGA to the new version."
 echo "Warning: FPGA update will disrupt traffic flowing through this switch."
 echo "It will also cause the switch to restart."
 PROMPT="Do you want to update the FPGA to version ${FILE_VERSION}? [N] "
 while true
 do
  read -ep "$PROMPT" REPLY
  case `echo $REPLY | /usr/bin/tr [:lower:] [:upper:]` in
   N|NO|"") exit 0 ;;
   Y|YES) break ;;
  esac
 done
 echo "Please avoid powering off the switch during programming."
 echo "When programming completes, the switch will reset itself."
 echo ""
 /fabos/share/jtagpgm -f /fabos/share/63-1000427.xsvf
fi
