1#!/bin/bash 2# 3# Copyright © 2017 IBM Corporation 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17 18# Check a max31785 firmware revision and set the MSL property 19# on the specified inventory items. 20 21set -e 22 23function main() 24{ 25 usage="Usage: $(basename "$0") -p PATH... -b BUS_NUMBER -r REVISION" 26 while getopts p:b:r:h key; do 27 case $key in 28 p) 29 paths=$OPTARG 30 ;; 31 b) 32 bus=$OPTARG 33 ;; 34 r) 35 revision=$OPTARG 36 ;; 37 h) 38 echo "$usage" >&2 39 exit 40 ;; 41 \?) 42 printf "\nUnrecognized option\n" 43 echo "$usage" >&2 44 exit 1 45 ;; 46 esac 47 done 48 49 if [ -z "$paths" ] || [ -z "$bus" ] || [ -z "$revision" ]; then 50 echo "Missing option" >&2 51 echo "$usage" >&2 52 exit 1 53 fi 54 55 local state="false" 56 local actual 57 local dbus 58 59 dbus=$(mapper get-service /xyz/openbmc_project/inventory) 60 actual=$(i2cget -f -y "$bus" 0x52 0x9b w) 61 62 if (( actual >= revision )); then 63 state="true" 64 fi 65 66 for path in $paths; do 67 busctl call "$dbus" /xyz/openbmc_project/inventory \ 68 xyz.openbmc_project.Inventory.Manager Notify 'a{oa{sa{sv}}}' 1 \ 69 "$path" 1 \ 70 xyz.openbmc_project.Inventory.Decorator.MeetsMinimumShipLevel \ 71 1 MeetsMinimumShipLevel b "$state" 72 done 73} 74 75main "$@" 76