From 9d5b2024c69cc5a71be4ba2f304938c5dae0d1e8 Mon Sep 17 00:00:00 2001 From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl> Date: Fri, 1 May 2020 03:28:39 +0200 Subject: [PATCH] Generalise the DS starting script and add it to the itango tools --- Femto-DS/Femto-DS.sh | 16 ------------- RandomData-DS/RandomData-DS.sh | 16 ------------- tools/itango/start-DS.sh | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 32 deletions(-) delete mode 100755 Femto-DS/Femto-DS.sh delete mode 100755 RandomData-DS/RandomData-DS.sh create mode 100755 tools/itango/start-DS.sh diff --git a/Femto-DS/Femto-DS.sh b/Femto-DS/Femto-DS.sh deleted file mode 100755 index 785f87970..000000000 --- a/Femto-DS/Femto-DS.sh +++ /dev/null @@ -1,16 +0,0 @@ -runThis=$(basename ${0}) -runThis=${runThis//.sh/.py} -if [ -f ${runThis} ]; then - myDir=${PWD} -else - myDir=${PWD}/$(dirname ${0}) -fi - -if [ ${#} -eq 1 ]; then - instance="${1}" -else - echo "The instance of this device server must be provided!" - exit -1 -fi -containerPath=${myDir//${HOME}\//\/hosthome\/} -docker exec -it itango python3 ${containerPath}/${runThis} ${instance} diff --git a/RandomData-DS/RandomData-DS.sh b/RandomData-DS/RandomData-DS.sh deleted file mode 100755 index 785f87970..000000000 --- a/RandomData-DS/RandomData-DS.sh +++ /dev/null @@ -1,16 +0,0 @@ -runThis=$(basename ${0}) -runThis=${runThis//.sh/.py} -if [ -f ${runThis} ]; then - myDir=${PWD} -else - myDir=${PWD}/$(dirname ${0}) -fi - -if [ ${#} -eq 1 ]; then - instance="${1}" -else - echo "The instance of this device server must be provided!" - exit -1 -fi -containerPath=${myDir//${HOME}\//\/hosthome\/} -docker exec -it itango python3 ${containerPath}/${runThis} ${instance} diff --git a/tools/itango/start-DS.sh b/tools/itango/start-DS.sh new file mode 100755 index 000000000..eabca56f7 --- /dev/null +++ b/tools/itango/start-DS.sh @@ -0,0 +1,41 @@ +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 +deviceServerPath=${myDir//${HOME}\//\/hosthome\/} + +docker exec -it itango python3 ${deviceServerPath}/${runThis} ${instance} ${@} -- GitLab