#!/bin/sh trap InstallationInterrupted 2 #This function checks which pipelines have an available Reflex workflow #and stores in file "${download_dir}"/available_pipelines the following info: #Pipeline Version Data Pipeline-kit Demodataset GetAvailablePipelines() { cd "${tempdir}" if [ $offline -eq 0 ] ; then $httpcommand http://w4n.hq.eso.org/sci/software/pipelines/reflex_${release_channel}.txt > /dev/null 2>&1 if [ $? -ne 0 ]; then echo ERROR: Could not retrieve available pipelines. echo ERROR: Please make sure you have access to ESO webpages echo ERROR: If problem persists, contact usd-help@eso.org Cleanup exit 1 fi sort -k 1 reflex_${release_channel}.txt | uniq > available_pipelines_sorted \mv -f available_pipelines_sorted available_pipelines if [ ! -s available_pipelines ] then echo echo ERROR: No pipelines are available in this release channel Cleanup exit 1 fi \rm -f "${tempdir}/index.html" \cp available_pipelines "${download_dir}" else if [ ! -f "${download_dir}"/available_pipelines ] ; then echo ERROR: The following file needed in offline mode is missing: echo ERROR: ${download_dir}/available_pipelines Cleanup exit 1 fi fi } GetInstalledPipelines() { if [ -f "${installation_dir}/etc/vltpipe_reflex_install/installed_pipelines" ] then echo ================================================================== echo The following pipelines and associated demo dataset echo are already installed in your system: echo 'Instrument Version' awk '{printf("%-16s %-22s\n",$1,$2)}' "${installation_dir}/etc/vltpipe_reflex_install/installed_pipelines" echo echo The current procedure will first delete all the installed pipelines echo \(but not the datasets\) and then install the requested ones echo \(unless all currently installed pipelines are exactly echo the same as the all requested pipelines\) printf "Do you want to continue [Y/n]? " read -r proceed proceed=`echo $proceed | tr '[:upper:]' '[:lower:]'` if [ "x$proceed" = "xn" ] ; then echo Aborting Cleanup exit 1 fi fi } GetInstalledReflex() { if [ -f "${installation_dir}/etc/vltpipe_reflex_install/installed_reflex" ] then echo ================================================================== echo The following Reflex version is already installed in you system: cat "${installation_dir}/etc/vltpipe_reflex_install/installed_reflex" | sed 's%ftp://ftp.eso.org/pub/dfs/reflex/%%g' | sed 's%.tar.gz%%g' fi } #This function will show the available pipelines and their versions and #will prompt for the desired pipelines to be installed GetPipelinesToInstall() { cd "${tempdir}" echo ================================================================== echo The following list contains the latest available versions of echo pipelines with workflows published by the VLT pipelines team echo Please specify ALL the pipelines you want to install. echo WARNING: It is not possible to add, upgrade or delete individual echo pipelines to an existing installation. Any change in the choice of echo pipelines at a later time or any upgrade of a pipeline will require a echo complete re-installation of ALL pipelines. echo echo Please specify \'A\' to install all available pipelines \(recommended\), or a echo selection of pipelines by writing a space-separated list of the PipeIDs. echo 'PipeID Instrument Version ' awk '{printf("%-9d %-16s %-22s %-s\n",NR,$1,$2,$5)}' "${download_dir}"/available_pipelines echo while : do printf "Input PipeIDs for pipelines to install [A]: " read -r pipeline_numbers_to_install if [ -z "$pipeline_numbers_to_install" ] ; then pipeline_numbers_to_install="A" fi \rm -f pipelines_to_install number_pipes=`wc -l < ${download_dir}/available_pipelines` cat -n "${download_dir}"/available_pipelines | while read pipeid pipename pipever somethings do echo ${pipeid} ${pipename} ${pipever} ${pipeline_numbers_to_install} | awk -v number_pipes="$number_pipes" '{for(i=4; i<=NF; i++){if( $i != "A" && ( ( $i != $i + 0 ) || ( ( $i == $i + 0 ) && ( ( $i < 1 ) || ( $i > number_pipes ) ) ) ) ) {print "WARNING: Invalid input. Enter numbers in the valid range or A."}; if( $i == $1 || $i == "A" ){printf("%s %s\n", $2, $3)}}}' >> pipelines_to_install done grep WARNING pipelines_to_install | head -1 if grep WARNING pipelines_to_install > /dev/null then echo else if [ -s pipelines_to_install ] then break else echo echo WARNING: No pipeline has been specified. Please try again echo fi fi done sort -k 1 pipelines_to_install | uniq > pipelines_to_install_sorted \mv -f pipelines_to_install_sorted pipelines_to_install if [ -f "${installation_dir}/etc/vltpipe_reflex_install/installed_pipelines" ] then sort -k 1 "${installation_dir}/etc/vltpipe_reflex_install/installed_pipelines" > installed_pipelines_sorted join -j 1 -v 2 pipelines_to_install installed_pipelines_sorted > pipelines_to_remove local lines_pipe_remove=`wc -l < pipelines_to_remove` if [ $lines_pipe_remove -eq 0 ] then \rm -f pipelines_to_remove fi diff pipelines_to_install installed_pipelines_sorted > difference_installed_pipelines local lines_diff_inst=`wc -l < difference_installed_pipelines` if [ $lines_diff_inst -eq 0 ] then \rm -f pipelines_to_install fi fi echo } #This function will select the desired demo data to be installed GetPipelineDemoDataToInstall() { cd "${tempdir}" echo ================================================================== echo Pipeline workflows are distributed with demo data that allows echo to run the workflow right away. echo Please specify \'A\' to install all available demo data \(recommended\), echo \'None\' to not install any demo data, or a echo selection of demo data by writing a space-separated list of the PipeIDs. echo 'PipeID Instrument Version' awk '{printf("%-9d %-16s %-22s\n",NR,$1,$2)}' pipelines_to_install echo while : do printf "Input PipeIDs for demo data to install [A]: " read -r pipedata_numbers_to_install if [ -z "$pipedata_numbers_to_install" ] ; then pipedata_numbers_to_install="A" fi \rm -f pipedata_to_install number_pipe_data=`wc -l < pipelines_to_install` cat -n pipelines_to_install | while read pipeid pipename pipever somethings do echo ${pipeid} ${pipename} ${pipever} ${pipedata_numbers_to_install} | awk -v number_pipe_data="$number_pipe_data" '{for(i=4; i<=NF; i++){if( $i != "None" && $i != "A" && ( ( $i != $i + 0 ) || ( ( $i == $i + 0 ) && ( ( $i < 1 ) || ( $i > number_pipe_data ) ) ) ) ) {print "WARNING: Invalid input. Enter numbers in the valid range, None or A."}; if( $i == $1 || $i == "A" ){printf("%s %s\n", $2, $3)}}}' >> pipedata_to_install done grep WARNING pipedata_to_install | head -1 if grep WARNING pipedata_to_install > /dev/null then echo else break fi done echo } GetReflexToInstall() { cd "$tempdir" echo ================================================================== echo The following Reflex version is the latest one available: cat "${download_dir}"/reflex_version cp "${download_dir}"/reflex_version reflex_to_install if [ -f "${installation_dir}/etc/vltpipe_reflex_install/installed_reflex" ] then diff "${tempdir}/reflex_to_install" "${installation_dir}/etc/vltpipe_reflex_install/installed_reflex" > difference_installed_reflex local lines_diff_inst=`wc -l < difference_installed_reflex` if [ $lines_diff_inst -eq 0 ] then \rm -f "${tempdir}/reflex_to_install" else cp "${installation_dir}/etc/vltpipe_reflex_install/installed_reflex" "${tempdir}/reflex_to_remove" fi fi } GetAvailableReflexVersion() { cd "${tempdir}" if [ $offline -eq 0 ] ; then ${httpcommand} http://www.eso.org/sci/software/reflex/releases/${release_channel}/index.html > /dev/null 2>&1 if [ $? -ne 0 ]; then echo ERROR: Could not retrieve available Reflex versions. echo ERROR: Please make sure you have access to ESO webpages echo ERROR: If problem persists, contact usd-help@eso.org Cleanup exit 1 fi if [ `uname` = "Linux" ] ; then grep Linux index.html > index_platform.html elif [ `uname` = "Darwin" ] ; then grep "OS X" index.html > index_platform.html else echo ERROR: Non-supported operating system Cleanup exit 1 fi awk '/tar.gz/' index_platform.html | awk -F "<|>" '{gsub(/a href=/,"",$2); gsub(/"/,"",$2); print $2}' > reflex_package cat reflex_package | sed 's%ftp://ftp.eso.org/pub/dfs/reflex/%%g' | sed 's%.tar.gz%%g' > reflex_version # echo The available version of Reflex is: # cat reflex_version echo \rm -f "${tempdir}/index.html" \cp reflex_version "${download_dir}" else if [ ! -f "${download_dir}"/reflex_version ] ; then echo ERROR: The following file needed in offline mode is missing: echo ERROR: ${download_dir}/reflex_version Cleanup exit 1 fi fi } WriteInstalledPackagesConfiguration() { CreateDirectory "${installation_dir}/etc/vltpipe_reflex_install" if [ -f "${tempdir}/pipelines_to_install" ] ; then cp "${tempdir}/pipelines_to_install" "${installation_dir}/etc/vltpipe_reflex_install/installed_pipelines" fi if [ -f "${tempdir}/reflex_to_install" ] ; then cp "${download_dir}/reflex_version" "${installation_dir}/etc/vltpipe_reflex_install/installed_reflex" fi } AskOffline() { echo ================================================================== echo This install script requires an internet connection to check for echo the latest versions of the software and download them if necessary. echo It can work without an internet connection if the download directory echo \($download_dir\) contains already the needed files, echo either from a previous run of the script or copied from some media. printf "Do you want to use your internet connection [Y/n]? " read -r offline offline=`echo $offline | tr '[:upper:]' '[:lower:]'` if [ "x$offline" = "xn" ] ; then offline=1 else offline=0 fi } #Present a summary of the steps to be done and will exit if not confirmed ConfirmInstallation() { cd "${tempdir}" echo ================================================================== if [ -f pipelines_to_install ] ; then echo The following pipelines will be installed/reinstalled: cat pipelines_to_install echo echo The following demo data sets will be installed: cat pipedata_to_install else echo No pipelines or associated demo dataset will be installed. echo Current installed pipelines and associated demo dataset are kept. fi echo if [ -f reflex_to_install ] ; then echo The following Reflex version will be installed: cat reflex_to_install else echo The current Reflex version will be kept. fi echo echo ================================================================== if [ ! -f reflex_to_install ] && [ ! -f pipelines_to_install ] ; then echo Current Reflex and pipeline installations will be kept. echo There is nothing to be done. Exiting Cleanup exit 1 fi echo "The following directories will be used:" echo "Directory for temporary downloaded files: " $download_dir echo "Directory for installation of all software: " $installation_dir echo "Directory for demo datasets: " $dataset_dir echo printf "Please confirm to proceed [Y/n]: " read -r proceed proceed=`echo $proceed | tr '[:upper:]' '[:lower:]'` if [ "x$proceed" = "xn" ] ; then echo Aborting Cleanup exit 1 fi echo WARNING: Please, do not interrupt the installation from this point on echo WARNING: Otherwise you might get a broken installation } #Do the installation of the pipelines InstallPipelines() { if [ -f "${tempdir}/pipelines_to_install" ] ; then cd "${download_dir}" local all_pipeline_kits= local all_pipeline_data= while read pipename pipeversion do echo Downloading ${pipename} pipeline local pipekit=`grep ${pipename} "${download_dir}/available_pipelines" | awk '{print $3}' ` local pipe_kit_name=`echo $pipekit | awk -F'/' '{print $(NF)}'` if [ $offline -eq 0 ] ; then ${httpcommand} $pipekit > /dev/null 2>&1 if [ $? -ne 0 ]; then echo ERROR: Could not retrieve pipeline kit. Check disk space or permissions echo ERROR: You might also want to delete old downloads from ${download_dir} Cleanup exit 1 fi ${httpcommand} $pipekit.cksum > /dev/null 2>&1 else if [ ! -f $pipe_kit_name ] ; then echo ERROR: The following file needed in offline mode is missing: echo ERROR: "${download_dir}"/$pipe_kit_name Cleanup exit 1 fi fi all_pipeline_kits=`echo $all_pipeline_kits "${download_dir}/$pipe_kit_name"` cut -f 1,2 -d' ' $pipe_kit_name.cksum > "${tempdir}/$pipe_kit_name.cksum.orig" cat $pipe_kit_name | cksum > "${tempdir}/$pipe_kit_name.cksum.computed" diff "${tempdir}/$pipe_kit_name.cksum.computed" "${tempdir}/$pipe_kit_name.cksum.orig" > /dev/null if [ ! $? -eq 0 ] then echo ERROR: The pipeline kit contains errors in the checksum. echo Remove ${download_dir} and start over. Cleanup exit 1 fi done < "${tempdir}/pipelines_to_install" echo Downloading pipeline installation script if [ $offline -eq 0 ] ; then \rm -f install_pipelinekit ${httpcommand} http://www.eso.org/sci/software/pipelines/releases/${release_channel}/install_pipelinekit > /dev/null 2>&1 chmod u+x install_pipelinekit else if [ ! -f install_pipelinekit ] ; then echo ERROR: The following file needed in offline mode is missing: echo ERROR: "${download_dir}"/install_pipelinekit Cleanup exit 1 fi fi echo echo Executing pipeline installation script starting at `date`. echo This might take a while, around 10 minutes per pipeline. echo Inspect the following file if you want to check progress: echo ${download_dir}/install.log echo ./install_pipelinekit -ignore_esorex_rc -ignore_gasgano "${installation_dir}" "${installation_dir}" $all_pipeline_kits > "${tempdir}/install_pipelinekit.log" 2>&1 if [ $? -ne 0 ]; then echo ERROR: Could not install pipelines. echo ERROR: Check ${download_dir}/install.log to verify what went wrong echo ERROR: If error persists, send a report to usd-help@eso.org echo ERROR: including the following files: echo ${download_dir}/install.log find ${download_dir} -name config.log Cleanup exit 1 fi echo Installation of pipelines successful. echo Installing pipeline demo data while read pipename pipeversion do if [ ! -d "${dataset_dir}/reflex_input" ] ; then CreateDirectory "${dataset_dir}/reflex_input" fi if grep $pipename "${tempdir}/pipedata_to_install" > /dev/null 2>&1 ; then echo Downloading ${pipename} data local pipedata=`grep ${pipename} "${download_dir}"/available_pipelines | awk '{print $4}' ` local pipe_data_name=`echo $pipedata | awk -F'/' '{print $(NF)}' ` if [ $offline -eq 0 ] ; then ${httpcommand} $pipedata > /dev/null 2>&1 if [ $? -ne 0 ]; then echo ERROR: Could not retrieve pipeline data $pipedata. echo ERROR: Check disk space or permissions Cleanup exit 1 fi else if [ ! -f $pipe_data_name ] ; then echo ERROR: The following file needed in offline mode is missing: echo ERROR: "${download_dir}"/$pipe_data_name Cleanup exit 1 fi fi echo Installing ${pipename} data tar zxvf $pipe_data_name -C "${dataset_dir}/reflex_input" > /dev/null 2>&1 if [ $? -ne 0 ]; then echo WARNING: Could not install pipeline data. Check disk space or permissions echo WARNING: Installation will continue without this data being installed fi fi done < "${tempdir}/pipelines_to_install" echo Installation of pipeline data succeed. fi } InstallReflex() { if [ -f "${tempdir}/reflex_to_install" ] ; then cd "${download_dir}" echo Installing Reflex... local reflex_local_file="${download_dir}"/`cat "${tempdir}/reflex_to_install"`.tar.gz if [ $offline -eq 0 ] ; then ${httpcommand} `cat "${tempdir}/reflex_package"` > /dev/null 2>&1 if [ $? -ne 0 ]; then echo ERROR: Could not get Reflex package. Check disk space or permissions Cleanup exit 1 fi else if [ ! -f $reflex_local_file ] ; then echo ERROR: The following file needed in offline mode is missing: echo ERROR: $reflex_local_file Cleanup exit 1 fi fi cd "${installation_dir}" tar xzf $reflex_local_file -C "${installation_dir}" if [ $? -ne 0 ]; then echo ERROR: Could not install Reflex package. Check disk space or permissions Cleanup exit 1 fi fi } InstallInstallationScript() { CreateDirectory "${installation_dir}/bin" cd "$tempdir" if [ $offline -eq 0 ] ; then ${httpcommand} ftp://ftp.eso.org/pub/dfs/reflex/install_reflex > /dev/null 2>&1 cp install_reflex "${installation_dir}/bin" chmod u+x "${installation_dir}/bin/install_reflex" cp install_reflex "${download_dir}" else if [ ! -f "${download_dir}"/install_reflex ] ; then echo ERROR: The following file needed in offline mode is missing: echo ERROR: "{$download_dir}"/install_reflex Cleanup exit 1 fi fi } RemoveCurrentPipelines() { if [ -f pipelines_to_install ] ; then echo Purging installed pipelines \rm -rf "${installation_dir}/bin" "${installation_dir}/etc" "${installation_dir}/lib" "${installation_dir}/share" "${installation_dir}/calib" "${installation_dir}/include" "${installation_dir}/man" fi } RemoveCurrentReflex() { if [ -f "${tempdir}/reflex_to_remove" ] ; then echo Purging installed Reflex `cat "${tempdir}/reflex_to_remove"` \rm -rf "${installation_dir}"/`cat "${tempdir}/reflex_to_remove"` fi } WriteDummyRecipeConfig() { touch ${installation_dir}/etc/dummy_recipe_config.rc } WriteReflexCommand() { reflex_version=`cat "${download_dir}/reflex_version"` cat > "${installation_dir}/bin/reflex" < "${installation_dir}/bin/reflex_set_memory" <\${memory_min}m\\`;; esac done max_line=\`grep max \$memory_file\` isnumber=0 while [ \$isnumber -eq 0 ] do printf "Maximum amount of memory (in Megabytes) for Reflex: [unchanged] " read -r memory_max case \$memory_max in '') printf "Maximum memory setting not changed\n"; isnumber=999 ;; *[!0-9]*) printf "Cannot understand number\n"; isnumber=0 ;; *) isnumber=1 ; max_line=\`echo \\${memory_max}m\\`;; esac done cd ${installation_dir}/reflex* cat > build-area/settings/memory.xml < Default Memory Properties \$max_line \$min_line EOF2 echo " Memory config set to:" echo \$max_line echo \$min_line EOF chmod +x "${installation_dir}/bin/reflex_set_memory" } HowToRunMessages() { echo ================================================================== echo Run the following command to execute Reflex echo ${installation_dir}/bin/reflex echo You might want to define an alias for this command, e.g. echo For sh / bash / zsh: echo alias reflex=${installation_dir}/bin/reflex echo For csh / tcsh: echo alias reflex ${installation_dir}/bin/reflex echo To customize the memory Reflex will use, please run: echo ${installation_dir}/bin/reflex_set_memory echo ================================================================== } #Creates a temporary unique directory and stores its name in the #variable name pased as first argument MakeTempDir() { local _tempdir=$1 mytempdir=$(mktemp -d "$download_dir"/pipeline_sources.XXXXXXXXXXXX) || { echo "ERROR creating a temporary file" >&2; exit 1; } eval $_tempdir="'$mytempdir'" } #Remove completely the temporal directory RemoveTempDir() { \rm -rf "$tempdir" } #Remove the directories left by the install_pipelinekit script RemoveInstallPipelineKitTempDir() { \rm -rf "${download_dir}"/pipeline-kit-*tmp } #Check that the superset of python modules are available CheckPythonModules() { cd "$tempdir" cat > python_check </dev/null if [ ! $? -eq 0 ] ; then echo WARNING: Some of the following Python modules are not installed in your system: echo WARNING: pyfits matplotlib wxPython matplotlib-wx optparse gettext types re sys math echo WARNING: Some pipeline workflows might require them. echo printf "Do you want to continue anyway? [y/N] " read -r proceed proceed=`echo $proceed | tr '[:upper:]' '[:lower:]'` if [ ! "x$proceed" = "xy" ] ; then echo Aborting Cleanup exit 1 fi fi } #Check that python is installed and that the version is enough to run Reflex CheckPythonVersion() { CheckCommandExist python python -c "import sys; sys.exit(sys.version_info < (2,6,0) or sys.version_info >= (3,0,0))" retval=$? if [ $retval -ne 0 ]; then echo echo WARNING: The following Python version is installed in your system python -V echo WARNING: Some of the available workflows use functionality echo WARNING: only available in version Python 2.6.0 or greater echo WARNING: and will not work properly with the installed version. echo WARNING: Additionally, python 3.x is not yet supported. printf "Do you want to continue anyway? [y/N] " read -r proceed proceed=`echo $proceed | tr '[:upper:]' '[:lower:]'` if [ ! "x$proceed" = "xy" ] ; then echo Aborting Cleanup exit 1 fi fi } #Check that java is installed and that the version is enough to run Reflex CheckJavaVersion() { CheckCommandExist java local java_min_version="1.7.0" local java_version=`java -version 2>&1 | grep "java version" | sed 's/.*"\(.*\)".*/\1/' | sed 's/_.*//g'` local java_version_stripped=`echo $java_version | sed 's/\.//g'` local java_min_version_stripped=`echo $java_min_version | sed 's/\.//g'` if [ ! $java_version_stripped -ge $java_min_version_stripped ] ; then echo echo ERROR: The following Java version is installed in your system: $java_version echo ERROR: This java version is incompatible with Reflex. echo ERROR: Please install java greater than ${java_min_version} Cleanup exit 1 fi } GetScriptOptions() { #Default release channel release_channel=devel while getopts "d:i:s:h" option_name; do case "$option_name" in d) download_dir="$OPTARG";; i) installation_dir="$OPTARG";; s) dataset_dir="$OPTARG";; h) PrintUsageAndExit;; [?]) PrintUsageAndExit ;; esac done } PrintUsageAndExit() { version=`echo \$Revision: 1.121 $ | cut -f 2 -d' '` echo This is the $0 script to install Reflex. Version $version echo This script allows to install Reflex together with pipelines echo with Reflex workflows support. It retrieves the latest versions echo of the pipelines from the ESO servers. An offline mode also exists. echo Please follow the instructions that appear in the screen. echo echo "Usage: $0 [-d DOWNLOAD_DIR] [-i INSTALL_DIR] [-s DATA_DIR] [-h]" echo echo " -d DOWNLOAD_DIR The directory where to download all the data." echo " If not given, the script will ask" echo " -i INSTALL_DIR The directory where to install the software," echo " including Reflex and the pipelines." echo " If not given, the script will ask" echo " -s DATA_DIR The directory where to download all the data." echo " The products of the pipeline, logs and" echo " bookkeeping will also be stored here." echo " If not given, the script will ask" echo " If not given, the script will ask" echo echo " Example: install_reflex -d d_dir -i i_dir -s d_dir" Cleanup exit 1 } #Get the name of the directories GetConfigDirectories() { if [ -z "$download_dir" ] ; then printf "Input directory for temporary downloaded files (> 500 Mb) [download_reflex]: " read -r download_dir if [ -z "$download_dir" ] ; then download_dir="download_reflex" fi fi test `pwd` -ef $download_dir if [ $? -eq 0 ] ; then echo "ERROR: The download dir is the same as current one. Choose other" Cleanup exit 1 fi if [ -z "$installation_dir" ] ; then printf "Input directory for installation of all software (> 500 Mb) [install]: " read -r installation_dir if [ -z "$installation_dir" ] ; then installation_dir="install" fi fi if [ -z "$dataset_dir" ] ; then printf "Input directory for installation of demo datasets (variable size) [data_wkf]: " read -r dataset_dir if [ -z "$dataset_dir" ] ; then dataset_dir="data_wkf" fi fi if [ ! -d "${download_dir}" ] ; then CreateDirectory "${download_dir}" fi if [ ! -d "${installation_dir}" ] ; then CreateDirectory "${installation_dir}" fi if [ ! -d "${dataset_dir}" ] ; then CreateDirectory "${dataset_dir}" fi local base_dir=$PWD cd "${base_dir}" cd "${download_dir}" download_dir=${PWD} cd "${base_dir}" cd "${installation_dir}" installation_dir=${PWD} cd "${base_dir}" cd "${dataset_dir}" dataset_dir=${PWD} echo Using the following directory configuration echo Download directory: ${download_dir} echo Installation directory: ${installation_dir} echo Demo dataset directory: ${dataset_dir} echo } GetReleaseChannel() { if [ "$release_channel" != "stable" ] && [ "$release_channel" != "testing" ] && [ "$release_channel" != "devel" ] && [ "$release_channel" != "legacy" ] ; then echo Unknown release channel $release_channel Cleanup exit 1 fi if [ "$release_channel" != "stable" ] ; then echo Using release channel $release_channel fi } CreateDirectory() { echo "Creating dir '$1'" mkdir -p "$1" > /dev/null 2> /dev/null retval=$? if [ $retval -ne 0 ]; then echo ERROR: Could not create dir $1. Verify path or premissions Cleanup exit 1 fi } #Check if a command is in the path CheckCommandExist() { exec_com=$1 command -v $exec_com > /dev/null 2> /dev/null local retval=$? if [ $retval -ne 0 ]; then echo ERROR: $exec_com is not installed in your system. Cleanup exit 1 fi } #Check that the needed programas are in the path CheckTextUtils() { CheckCommandExist awk CheckCommandExist tr CheckCommandExist cat CheckCommandExist sed CheckCommandExist grep CheckCommandExist mkdir CheckCommandExist rm CheckCommandExist cksum CheckCommandExist basename CheckCommandExist touch } #Get the command used to retrieve web pages. It can be wget or curl GetHttpCommand() { local _httpcommand=$1 command -v wget > /dev/null 2> /dev/null retval=$? if [ $retval -ne 0 ]; then command -v curl > /dev/null 2> /dev/null retval=$? if [ $retval -ne 0 ]; then echo ERROR: Neither wget or curl are installed. Please install them. Cleanup exit 1 else local myhttpcommand='curl -O -C -' fi else local myhttpcommand='wget -c' fi eval $_httpcommand="'$myhttpcommand'" } PrintWelcome() { echo ====================================================================== echo " Welcome to the installation script for Reflex and pipeline workflows" echo ====================================================================== } ReplaceWorkflowDataPath() { #Do this only if pipelines have been installed if [ -f "${tempdir}/pipelines_to_install" ] ; then # replace data dir in the workflows find "${installation_dir}/share/reflex/workflows" -name "*.xml" -exec sh -c 'file="{}" ; sed "s%ROOT_DATA_PATH_TO_REPLACE%'${dataset_dir}'%g" "$file" > "$file.edit" ; mv "$file.edit" "$file" ' \; # replace calib dir in the workflows find "${installation_dir}/share/reflex/workflows" -name "*.xml" -exec sh -c 'file="{}" ; sed "s%CALIB_DATA_PATH_TO_REPLACE%'${installation_dir}/calib'%g" "$file" > "$file.edit" ; mv "$file.edit" "$file" ' \; fi } MakeWorkflowLinks() { #Do this only if pipelines have been installed local kepler_wkf_dir=$HOME/KeplerData/workflows/MyWorkflows if [ ! -d $kepler_wkf_dir ] ; then CreateDirectory $kepler_wkf_dir fi #Link the installed workflows for wkf_dir in "${installation_dir}"/share/reflex/workflows/* do local dirname=`basename $wkf_dir` if [ -L "${kepler_wkf_dir}"/$dirname ] ; then echo WARNING: A link to the pipeline $dirname already exists pointing echo WARNING: to `ls -l "${kepler_wkf_dir}"/$dirname` printf "Do you want to change it to the current installation [Y/n]? " read -r proceed proceed=`echo $proceed | tr '[:upper:]' '[:lower:]'` if [ "x$proceed" = "xn" ] ; then echo "${kepler_wkf_dir}"/$dirname has been kept else \rm -f "${kepler_wkf_dir}"/$dirname ln -s $wkf_dir $kepler_wkf_dir fi else ln -s $wkf_dir $kepler_wkf_dir fi done #Link the demo Reflex workflows if [ -f "${tempdir}/reflex_to_install" ] ; then if [ -L "${kepler_wkf_dir}"/eso-demo-workflows ] ; then \rm -f "${kepler_wkf_dir}"/eso-demo-workflows fi reflex_version=`cat "${tempdir}/reflex_to_install"` ln -s "${installation_dir}/${reflex_version}/eso-reflex/eso-demo-workflows" $kepler_wkf_dir fi } RemoveKeplerDataESO() { if [ -d $HOME/KeplerData/modules/eso-reflex ] ; then echo WARNING: The installation has detected the following directory: echo WARNING: $HOME/KeplerData/modules/eso-reflex echo WARNING: This means that a previous installation of Reflex echo WARNING: existed, which is known to gives problems in some cases. echo WARNING: Additionally, the $HOME/.kepler, echo WARNING: $HOME/KeplerData/kepler.modules and $HOME/KeplerData/MyData echo WARNING: directories should also be removed. printf "Do you want to delete these directories [Y/n]? " read -r proceed proceed=`echo $proceed | tr '[:upper:]' '[:lower:]'` if [ "x$proceed" = "xn" ] ; then echo $HOME/KeplerData has been kept else \rm -rf $HOME/KeplerData/modules \rm -rf $HOME/KeplerData/kepler.modules \rm -rf $HOME/KeplerData/MyData \rm -rf $HOME/.kepler echo $HOME/KeplerData and $HOME/.kepler have been removed fi fi } Cleanup() { #RemoveTempDir #RemoveInstallPipelineKitTempDir : } InstallationInterrupted() { echo echo Installation interrupted Cleanup exit 1 } PrintWelcome GetScriptOptions $@ GetConfigDirectories AskOffline GetReleaseChannel MakeTempDir tempdir CheckJavaVersion CheckTextUtils CheckPythonVersion CheckPythonModules GetHttpCommand httpcommand GetAvailableReflexVersion GetAvailablePipelines GetInstalledReflex GetInstalledPipelines GetReflexToInstall GetPipelinesToInstall GetPipelineDemoDataToInstall ConfirmInstallation RemoveCurrentPipelines RemoveCurrentReflex InstallPipelines InstallReflex InstallInstallationScript WriteDummyRecipeConfig WriteReflexCommand ReplaceWorkflowDataPath MakeWorkflowLinks WriteInstalledPackagesConfiguration RemoveKeplerDataESO WriteSetMemoryCommand HowToRunMessages Cleanup exit