1#!/bin/bash 2 3# This shell script sets all the group D-Bus objects 4# in /xyz/openbmc_project/led/groups/ to true or false. 5# If the group is in excluded list, then, they are not 6# altered 7 8function usage() 9{ 10 echo "led-set-all-groups-asserted.sh [true/false] [optional groups to be excluded]" 11 echo "Example: led-set-all-groups-asserted.sh true" 12 echo "Example: led-set-all-groups-asserted.sh false bmc_booted power_on" 13 return 0; 14} 15 16# We need at least 1 argument 17if [ $# -lt 1 ]; then 18 echo "At least ONE argument needed"; 19 usage; 20 exit -1; 21fi 22 23# User passed in argument [true/false] 24action=$1 25 26# If it is not "true" or "false", exit 27if [ $action != "true" ] && [ $action != "false" ]; then 28 echo "Bad argument $action passed"; 29 usage; 30 exit -1; 31fi 32 33# Get the excluded groups, where $@ is all the agruments passed 34index=2; 35excluded_groups="" 36 37for arg in "$@" 38do 39 if [ $arg == $action ] 40 then 41 # Must be true/false 42 continue 43 elif [ $index -eq $# ] 44 then 45 excluded_groups="${excluded_groups}$arg" 46 else 47 excluded_groups="${excluded_groups}$arg|" 48 fi 49 let "index+=1" 50done 51 52# Now, set the LED group to what has been requested 53if [ ${#excluded_groups} -eq 0 ] 54then 55 for line in $(busctl tree xyz.openbmc_project.LED.GroupManager | grep -e groups/ | awk -F 'xyz' '{print "/xyz" $2}'); 56 do 57 busctl set-property xyz.openbmc_project.LED.GroupManager $line xyz.openbmc_project.Led.Group Asserted b $action; 58 done 59else 60 for line in $(busctl tree xyz.openbmc_project.LED.GroupManager | grep -e groups/ | grep -Ev $excluded_groups | awk -F 'xyz' '{print "/xyz" $2}'); 61 do 62 busctl set-property xyz.openbmc_project.LED.GroupManager $line xyz.openbmc_project.Led.Group Asserted b $action; 63 done 64fi 65 66# Return Success 67exit 0 68