From b63a071ad0b44479120bcbd81d69f0c7c80cae99 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Sun, 3 Oct 2021 15:48:26 +0200 Subject: [PATCH] L2SS-394: Remove path recasting magic by just copying the config into the container and using it from there --- sbin/load_ConfigDb.sh | 24 +++++------------------- sbin/update_ConfigDb.sh | 29 +++++------------------------ 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/sbin/load_ConfigDb.sh b/sbin/load_ConfigDb.sh index 96432f31c..f7c753689 100755 --- a/sbin/load_ConfigDb.sh +++ b/sbin/load_ConfigDb.sh @@ -10,23 +10,9 @@ else help "A file name must be provided." fi -# Check if the filename begins with /hosthome/, /opt/lofar2.0/tango or -# /opt/lofar2.0/ or if it is in the ${HOME} directory: -if [ ${1:0:10} != /hosthome/ -a ${1:0:20} != /opt/lofar2.0/tango/ -a ${1:0:14} != /opt/lofar2.0/ ]; then - pushd $(dirname ${file}) >/dev/null - full_path=${PWD} - popd >/dev/null - # Check if the file's directory begins with ${HOME}. Then it can be - # accessed via /hosthome. The replacement will then shorten the result. - home_replaced=${full_path#${HOME}} - if [ ${#home_replaced} -ne ${#full_path} ]; then - if [ ! -f ${file} ]; then - help "The file \"${1}\" does not exist." - fi +# copy file into container to read it from container, as the file's location +# in the container won't be the same as on the host. +docker cp "${file}" dsconfig:/tmp/dsconfig-load-settings.json - # The file can be accessed through /hosthome. Modify the parameter. - file=/hosthome${home_replaced}/$(basename ${file}) - fi -fi - -docker exec -it dsconfig json2tango --write ${file} +# write settings +docker exec -it dsconfig json2tango --write /tmp/dsconfig-load-settings.json diff --git a/sbin/update_ConfigDb.sh b/sbin/update_ConfigDb.sh index 0f22b48cb..25cb31a85 100755 --- a/sbin/update_ConfigDb.sh +++ b/sbin/update_ConfigDb.sh @@ -10,28 +10,9 @@ else help "A file name must be provided." fi -# Check if the filename begins with /hosthome/, /opt/lofar2.0/tango or -# /opt/lofar2.0/ or if it is in the ${HOME} directory: -if [ ${1:0:10} != /hosthome/ -a ${1:0:20} != /opt/lofar2.0/tango/ -a ${1:0:14} != /opt/lofar2.0/ ]; then - pushd $(dirname ${file}) >/dev/null - full_path=${PWD} - popd >/dev/null - # Check if the file's directory begins with ${HOME}. Then it can be - # accessed via /hosthome. The replacement will then shorten the result. - home_replaced=${full_path#${HOME}} - if [ ${#home_replaced} -ne ${#full_path} ]; then - if [ ! -f ${file} ]; then - help "The file \"${1}\" does not exist." - fi +# copy file into container to read it from container, as the file's location +# in the container won't be the same as on the host. +docker cp "${file}" dsconfig:/tmp/dsconfig-update-settings.json - # The file can be accessed through /hosthome. Modify the parameter. - file=/hosthome${home_replaced}/$(basename ${file}) - else - # The file is in one of the two: /opt/lofar2.0/tango/ /opt/lofar2.0/ - # Provide the full path since it is accessible from within the docker - # image because both directories are mounted. - file=${full_path}/$(basename ${file}) - fi -fi - -docker exec -it dsconfig json2tango --write --update ${file} +# update settings +docker exec -it dsconfig json2tango --write --update /tmp/dsconfig-update-settings.json -- GitLab