Willy Tu | 24b8b4b | 2023-08-07 17:49:37 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | action=$1 |
| 4 | devpath=$2 |
| 5 | of_fullname=$3 |
| 6 | |
| 7 | #Use of_fullname if it's there, otherwise use devpath. |
| 8 | function use_devpath(){ |
| 9 | path=$devpath |
| 10 | |
| 11 | if [[ "$path" =~ (.*)/hwmon/hwmon[0-9]+$ ]]; |
| 12 | then |
| 13 | path=${BASH_REMATCH[1]} |
| 14 | fi |
| 15 | echo "${path}" |
| 16 | } |
| 17 | |
| 18 | path=$of_fullname |
Matt Spinler | 670d92a | 2024-07-22 15:52:02 -0500 | [diff] [blame^] | 19 | if [ -z "${path}" ]@FORCE_DEVPATH@ |
Willy Tu | 24b8b4b | 2023-08-07 17:49:37 -0700 | [diff] [blame] | 20 | then |
| 21 | path="$(use_devpath)" |
| 22 | else |
| 23 | override_with_devpath=(@OVERRIDE_WITH_DEVPATH@) |
| 24 | if [[ "$path" =~ .*/(.*)$ ]]; |
| 25 | then |
| 26 | of_name="${BASH_REMATCH[1]}" |
| 27 | for i in ${!override_with_devpath[@]}; do |
| 28 | if [[ "${override_with_devpath[$i]}" == "${of_name}" ]]; |
| 29 | then |
| 30 | path="$(use_devpath)" |
| 31 | break |
| 32 | fi |
| 33 | done |
| 34 | fi |
| 35 | fi |
| 36 | |
| 37 | # Needed to re-do escaping used to avoid bitbake separator conflicts |
| 38 | path="${path//:/--}" |
| 39 | # Needed to escape prior to being used as a unit argument |
| 40 | path="$(systemd-escape "$path")" |
| 41 | systemctl --no-block "$action" "xyz.openbmc_project.Hwmon@$path.service" |