diff --git a/bootstrap/bin/updatePythonEnv.sh b/bootstrap/bin/updatePythonEnv.sh deleted file mode 100755 index 112fb66adfec65cd31a1f36c10cca28c0976cf09..0000000000000000000000000000000000000000 --- a/bootstrap/bin/updatePythonEnv.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env bash -# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 - -venv=${VIRTUAL_ENV:?This is currently not a Python3 venv! Will not upgrade venv packages.} -echo -e "\nFound a Python3 venv in \"${VIRTUAL_ENV}\".\nWill now proceed with package upgrades.\n" - -pip="python3 -m pip" -upgrade_command="${pip} install --upgrade" - -if [ -z ${OS} ]; then - OS=$(uname) -fi -if [ ${OS} = Darwin ]; then - find=gfind -else - find=find -fi - -function upgrade() -{ - if [ ${#} -ge 1 ]; then - echo "Upgrading ${@}..." - ${upgrade_command} ${@} - if [ ${?} -eq 0 ]; then - echo -e "\nUpgrading ${@} done.\n\nNow \"deactivate\" and \"source ${venv}/bin/activate\".\n" - else - echo -e "\nSomething went wrong during the upgrade.\nCheck the output!\n" - fi - else - echo -e "\nNo package for upgrading given.\n" - fi -} - -upgrade pip wheel - -installed_packages=$(for i in $(python3 -m pip freeze | cut -d'=' -f1); do printf "%s " ${i}; done) -upgrade ${installed_packages} diff --git a/bootstrap/etc/requirements.txt b/bootstrap/etc/requirements.txt deleted file mode 100644 index 5502737a6308c9939be7a2fa4981707f965918ac..0000000000000000000000000000000000000000 --- a/bootstrap/etc/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -astropy -jupyter -matplotlib -numpy -opcua-client -pyqtgraph -PyQt5 -asyncua -dataclasses diff --git a/bootstrap/sbin/checkout_shallow_copy_lofar_repos.sh b/bootstrap/sbin/checkout_shallow_copy_lofar_repos.sh deleted file mode 100755 index 03c66b6b8891c130cefc844ff067dbca98350c18..0000000000000000000000000000000000000000 --- a/bootstrap/sbin/checkout_shallow_copy_lofar_repos.sh +++ /dev/null @@ -1,45 +0,0 @@ -#! /usr/bin/env bash -# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 - -# Clean out local dirs and then clone a shallow copy -# of LOFAR2.0 repos. - -# 2020-10-13, thomas -# Currently correct. -astron_gitlab=https://git.astron.nl/ -repo_dir=lofar2.0/ -branch=master - -for repo in lmc-base-classes ska-logging ska-docker opcua tango pypcc; do - cd ${repo} - # This will return 2 if the repo is clean. - clean="$(git status -u | wc -l)" - cd - - if [ "${clean}" = "2" ]; then - # The repo is clean, no new files, no modifications. - rm -rf ${repo} - git clone --depth 1 --branch ${branch} ${astron_gitlab}${repo_dir}${repo}.git - else - echo -e "*********\n\tThe repository ${repo} contains modifications.\n\tRestore the original content first before continuing.\nAborting now.\n" - exit -1 - fi -done - -# 2020-10-13, thomas -# I need to move this repo to lofar2.0. -repo=crossecho -repo_dir=jurges -rm -rf crossecho && git clone --depth 1 --branch add_simulation_mode_plus_patches ${astron_gitlab}${repo_dir}/${repo}.git - -if [ ! -s ska_logging -o $(readlink ska_logging) != ska-logging ]; then - echo "Creating symlink ska-logging -> ska_logging" - rm -f ska_logging - ln -s ska-logging ska_logging -fi - -if [ ! -s skabase -o $(readlink skabase) != lmc-base-classes ]; then - echo "Creating symlink lmc-base-classes -> skabase" - rm -f skabase - ln -s lmc-base-classes skabase -fi diff --git a/bootstrap/sbin/delete_all_docker_images.sh b/bootstrap/sbin/delete_all_docker_images.sh deleted file mode 100755 index 6af68c5f7ff6e599c0ecdfe8f13494e38840f56f..0000000000000000000000000000000000000000 --- a/bootstrap/sbin/delete_all_docker_images.sh +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env bash -# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 - -function help() -{ - echo "You need to add a parameter \"YES_DELETE_ALL\" in order to really remove all Docker images." - exit 0 -} - -if [ ${#} -ne 1 ]; then - help -elif [ "${1}" != "YES_DELETE_ALL" ]; then - help -fi - -read -p "If you certain that you want to delete all Docker images, then enter now \"YES_DO_IT\" " reply -if [ "${reply}" != "YES_DO_IT" ]; then - echo "You really need to enter \"YES_DO_IT\" in order to confirm." - exit 0 -else - images="$(for i in $(docker images | egrep -v "REPOSITORY" | awk '{printf "%s:%s\n", $1, $2}'); do printf "%s " ${i}; done)" - if [ ${#images} -eq 0 ]; then - echo "There are no images to delete." - else - echo -e "Will now delete the following Docker images:" - for image in ${images}; do - printf "\t%s\n" "${image}" - done - docker rmi ${images} - fi -fi - diff --git a/bootstrap/sbin/rebuild_system_from_scratch.sh b/bootstrap/sbin/rebuild_system_from_scratch.sh deleted file mode 100755 index ff363f21a10e0e01160d1a7460273de433a2c135..0000000000000000000000000000000000000000 --- a/bootstrap/sbin/rebuild_system_from_scratch.sh +++ /dev/null @@ -1,168 +0,0 @@ -#! /usr/bin/env bash -# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) -# SPDX-License-Identifier: Apache-2.0 - -HOME_DIR=${LOFAR20_DIR:-${PWD}} -if [ ! -d ${HOME_DIR}/bootstrap ]; then - # HOME_DIR/bootstrap needs to exist for this script to work. - echo -e "$(basename ${0}):\n\nERROR\n\tCannot run this script because the \"bootstrap\" cannot be found!\n\n" - exit 1 -fi - -# Check if Docker compose can be found. -DOCKER_COMPOSE="docker compose version" -${DOCKER_COMPOSE} >&/dev/null -ret=${?} -if [ ${ret} -ne 0 ]; then - DOCKER_COMPOSE="docker-compose version" - ${DOCKER_COMPOSE} >&/dev/null - ret=${?} -fi -if [ ${ret} -eq 0 ]; then - echo -e "\tFound Docker Compose: ${DOCKER_COMPOSE}" -else - echo -e "\tThis system appears to not have Docker compose installed. This means that the system cannot be rebuilt with this script." - return 1 -fi - -# Any error should terminate this script. -set -e - -# Save for the moment when tango will be cloned. -OLD_HOME_DIR=${HOME_DIR}.old - -trap ' exit ${?} ' ABRT EXIT HUP INT TERM QUIT ERR - - -function pull_images() -{ - (cd ${HOME_DIR}/docker-compose && make pull) -} - -function build_lofar_images() -{ - (cd ${HOME_DIR}/docker-compose && make build) -} - -function move_tango_dir_out_of_the_way() -{ - mv ${HOME_DIR} ${OLD_HOME_DIR} -} - -function remove_images() -{ - images="$(for i in $(docker images -q); do printf "%s " ${i}; done)" - if [ ${#images} -eq 0 ]; then - echo -e "\tThere are no images to delete." - else - echo -e "\tWill now delete the Docker images:" - docker rmi -f ${images} - fi -} - -function pull_tango() -{ - git clone https://git.astron.nl/lofar2.0/tango.git ${HOME_DIR} - # Now remove the old tango dir. - rm -rf ${OLD_HOME_DIR} -} - -function clean_images() -{ - # This can return a non-0 return code if the system - # has already been shut down. - # Therefore disable Bash's exit on error flag - set +e - (cd ${HOME_DIR}/docker-compose && make clean) - # And enable it again. - set -e -} - -function start_minimal_tango() -{ - (cd ${HOME_DIR}/docker-compose - make minimal - # There is an issue with the dsconfig container that it every - # other time just exits without telling why. - # Therefore start dsconfig, then wait for 10s to allow it - # to die and just start it again. - # Don't they say that the second time is always a charm? - make start dsconfig - echo -e "\tWaiting for dsconfig to settle down..." - sleep 10 - echo -e "\tDone.\n\tStarting dsconfig again." - make start dsconfig) -} - -function configure_tango_db() -{ - # This somehow returns with a non-0 return code, make Bash happy. - ${HOME_DIR}/sbin/update_ConfigDb.sh ${HOME_DIR}/CDB/LOFAR_ConfigDb.json || true -} - -function start_support_images() -{ - (cd ${HOME_DIR}/docker-compose && make start jupyter-lab) -} - -function start_lofar_images() -{ - (cd ${HOME_DIR}/docker-compose - make start device-recv - make start device-sdp) -} - - -# Clean out the Docker volumes. -echo "-> Stopping Docker images and cleaning cleaning up their volumes..." -clean_images -echo -e "\tDone.\n" - -# Move the tango repo dir out of the way. -echo "-> Moving the tango directory ${HOME_DIR} out of the way..." -move_tango_dir_out_of_the_way -echo -e "\tDone.\n" - -# Now pull the repo. -echo "-> Cloning tango's master branch to ${HOME_DIR}..." -pull_tango -echo -e "\tDone.\n" - -# Now clean out the docker images. -echo "-> Deleting all Docker images from this host..." -remove_images -echo -e "\tDone.\n" - -# Pull SKA's Docker images. -echo "-> Installing latest SKA Docker images on this host..." -pull_images -echo -e "\tDone.\n" - -# Build all of the LOFAR Docker images. -echo "-> Building LOFAR2.0 Docker images..." -build_lofar_images -echo -e "\tDone.\n" - -# Now start the basic Tango system, including dsconfig. -echo "-> Staring up a minimal Tango session..." -start_minimal_tango -echo -e "\tDone.\n" - -# Load LOFAR's TangoDB. -echo "-> Configuring the Tango DB for LOFAR2.0..." -configure_tango_db -echo -e "\tDone.\n" - -# Here I start Jupyter. -echo "-> Start LOFAR2.0 support containers (Jupyter, etc.)..." -start_support_images -echo -e "\tDone.\n" - -# And finally start all the LOFAR images. -echo "-> Start LOFAR2.0 containers..." -start_lofar_images -echo -e "\tDone.\n" - -# Now the system should be ready to use. -# For instance the cold start script could now be executed. -echo -e "-> LOFAR2.0 system rebuild was successful.\n\n" diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..17e98b131375011a62159fe49d737bc250daab41 --- /dev/null +++ b/setup.sh @@ -0,0 +1,54 @@ +#! /usr/bin/env bash +# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 + +# Set up the LOFAR2.0 environment. +# For the time being it is assumend that the LOFAR2.0 environment has to +# co-exist with a LOFAR1 environment. + +# Set these for the host where you run SKA's Tango Docker images. +# And export those directories for LOFAR in Tango Docker images. + +# Pass a directory as first parameter to this script. This will +# then be used as LOFAR20_DIR. Otherwise this file's directory +# be used to determine the tango directory location. +ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE})) +export LOFAR20_DIR=${1:-$(realpath ${ABSOLUTE_PATH}/../..)} + +if [ ! -f "${LOFAR20_DIR}/.git/hooks/post-checkout" ]; then + alias git="cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-checkout; cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-merge; unalias git; git" +fi + +# This needs to be modified for a development environment. +# In case you run multiple Docker networks on the same host in parallel, you need to specify a unique +# network name for each of them. +export NETWORK_MODE=tangonet + +# It is assumed that the Tango host, the computer that runs the TangoDB, is this host. +# If this is not true, then modify to the Tango host's FQDN and port. +# Example: export TANGO_HOST=station-xk25.astron.nl:10000 +export TANGO_HOST=$(hostname):10000 + +# +# NO MODIFICATION BEYOND THIS POINT! +# + +# Remove all LOFAR1 related environment modifications +function remove_lofar() +{ + tmp=${1//:/ } + echo "$(for new in $(for i in ${tmp}; do printf "%s\n" ${i}; done | egrep -v '/opt/lofar/|/opt/WinCC|/opt/stationtest|/opt/operations'); do printf "%s:" ${new}; done)" +} + +unset LOFARROOT +export PATH=$(remove_lofar ${PATH}) +export LD_LIBRARY_PATH=$(remove_lofar ${LD_LIBRARY_PATH}) +export PYTHON_PATH=$(remove_lofar ${PYTHON_PATH}) + + +# Allow read access for everybody to allow Docker the forwarding of X11. +chmod a+r ~/.Xauthority + +# Source the LOFAR2.0 Python3 venv if it exists. +[ -z ${VIRTUAL_ENV} ] && [ -d ${LOFAR20_DIR}/lofar2.0_venv ] && source ${LOFAR20_DIR}/lofar2.0_venv/bin/activate +