-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitach_replace.sh
executable file
·36 lines (34 loc) · 1.4 KB
/
itach_replace.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Shell Script for HomeAssistant that will replace
# the native itachip2ir dynamic linked library with a custom one.
# When pyitach runs, it looks for a file with a name containing
# the string *itachip2ir* + ext, where ext is 'so','dylib','dll','pyd'.
# This script assumes its it ".so"
# It will look for the native version based on a key search word and if found will
# rename its filename extension from ".so" to ".sow"
# and then will copy the custom version (named itachip2ir.so) in its place.
# For HA Docker on HAOS, it should be located
# at /usr/local/lib/python3.XX/site-packages.
SourceFile=/config/shell_commands/itachip2ir.so
SitePath=/usr/local/lib/python3.10/site-packages
SearchString="cpython"
echo "Looking for original itach binary file"
FullFileName=$(ls $SitePath/itachip2ir.* | grep -E $SearchString )
#echo FullFileName $FullFileName
if [ -z $FullFileName ]; then
#echo "FullFileName is null"
echo "Could not find native itach binary file"
else
if [ -e $FullFileName ]; then
echo "Found file" $FullFileName
if [ "${FullFileName: -4}" == ".sow" ]; then
echo "File ending in .sow already exists, so nothing to do"
else
echo "File does not end in .sow, so rename it and copy over custom version"
mv $FullFileName "${FullFileName}w"
cp $SourceFile "${SitePath}/itachip2ir.so"
fi
else
echo "File Not Found"
fi
fi