| #!/bin/sh |
| # |
| # Copyright (c) 2016 Nest, Inc. |
| # All rights reserved. |
| # |
| # This document is the property of Nest. It is considered |
| # confidential and proprietary information. |
| # |
| # This document may not be reproduced or transmitted in any form, |
| # in whole or in part, without the express written permission of |
| # Nest. |
| # |
| # Description: |
| # This script is for checking to see if the NCP firmware |
| # needs to be updated. |
| # |
| |
| usage() { |
| echo "Usage:" 1>&2 |
| echo " $0 [firmware-image-path] [installed-ncp-version-string]" 1>&2 |
| exit 1 |
| } |
| |
| if [ $# = 0 ] |
| then usage |
| fi |
| |
| FIRMWARE_IMAGE="$1" |
| shift |
| |
| if [ $# = 0 ] |
| then |
| strings "${FIRMWARE_IMAGE}" | grep -i '^[A-Z0-9]*/.*;.*$' |
| exit 1 |
| fi |
| |
| FIRMWARE_VERSION="$@" |
| |
| if grep "${FIRMWARE_VERSION}" "${FIRMWARE_IMAGE}" 1>/dev/null 2>/dev/null |
| then |
| echo "NCP firmware is up-to-date." 1>&2 |
| exit 1 # Firmware update not necessary |
| else |
| echo "NCP firmware IS OUT OF DATE." 1>&2 |
| exit 0 # Firmware update IS necessary |
| fi |
| |