Newer
Older
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
37
38
39
40
function help()
{
why="${1}"
echo -e "*** Cannot start the Python device server.\n${why}\n\n* The Python file for the device server must be the 1st parameter that is provided.\n* The instance of this device server must be the 2nd parameter that is provided."
exit -1
}
# Check if the mandatory parameters are present:
# ${1}: device server's Python file
# ${2}: instance of the device server's executable in the configDB
case ${#} in
0)
help "The device server's Python file and the instance are missing."
;;
1)
help "The device server's instance is missing."
;;
*)
deviceServer="${1}"
shift
instance="${1}"
shift
;;
esac
# Find the path to the device server's Python file that is
# relative to the /hosthome directory (in Docker the user's
# mounted ${HOME}).
# ATTENTION
# This is assuming that the device server's Python file exists
# on the Docker's host in the user's ${HOME} directory.
runThis=$(basename ${deviceServer})
runThis=${runThis//.sh/.py}
if [ -f ${runThis} ]; then
myDir=${PWD}
else
myDir=${PWD}/$(dirname ${deviceServer})
fi
docker exec -it itango python3 ${deviceServerPath}/${runThis} ${instance} ${@}