blob: cdf9d11cab0ae4f9f3fc66675218df79778ed5f8 [file] [log] [blame]
Willy Tu24b8b4b2023-08-07 17:49:37 -07001#!/bin/bash
2
3action=$1
4devpath=$2
5of_fullname=$3
6
7#Use of_fullname if it's there, otherwise use devpath.
8function 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
18path=$of_fullname
Matt Spinler670d92a2024-07-22 15:52:02 -050019if [ -z "${path}" ]@FORCE_DEVPATH@
Willy Tu24b8b4b2023-08-07 17:49:37 -070020then
21 path="$(use_devpath)"
22else
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
35fi
36
37# Needed to re-do escaping used to avoid bitbake separator conflicts
38path="${path//:/--}"
39# Needed to escape prior to being used as a unit argument
40path="$(systemd-escape "$path")"
41systemctl --no-block "$action" "xyz.openbmc_project.Hwmon@$path.service"