#! /bin/bash # # Necessary preparations/configurations for the reproduction pipeline. # # Original author: # Your name # Contributing author(s): # Copyright (C) YYYY, Your Name. # # This script is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This script is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # A copy of the GNU General Public License is available at # . # Top level locations cdir=reproduce/config pdir=$cdir/pipeline pconf=$pdir/LOCAL.mk ptconf=$pdir/LOCAL_tmp.mk poconf=$pdir/LOCAL_old.mk gconf=$cdir/gnuastro/gnuastro-local.conf # Functions. function add_top_notice() { if echo "# DO NOT EDIT MANUALLY: this is an automatically generated file." > $1 then echo "#" >> $1 echo "# This file is generated from the reproduction" >> $1 echo "# pipeline's './configure' script. Please re-run" >> $1 echo "# that command." >> $1 else exit 1 fi } # If `LOCAL.mk' already exists, then copy it to an `.old' file. if [ -f $pconf ]; then if mv $pconf $poconf; then echo echo "-------" echo "WARNING" echo "-------" echo " Existing configuration moved to '$poconf'." echo echo else exit 1 fi fi # Using the base file, prepare the output file. cp $pconf.in $ptconf # Tell the user to edit the directories. echo echo "-----------------------------------------" echo "Reproduction pipeline local configuration" echo "-----------------------------------------" echo echo "Local settings include things like top-level directories," echo "or processing steps (e.g., if you want a final PDF output)." echo echo "Pressing 'y' will open the local settings file in an editor" echo "so you can modify the default values if you want. Each" echo "variable is thoroughly described in the comments (lines" echo "starting with a '#') above it." echo while [ "$userread" != "y" -a "$userread" != "n" ] do read -p"Edit the default local configuration (y/n)? " userread done # Open an editor if the user wants to edit the file. if [ $userread = "y" ]; then # Open a text editor to set the given directories if emacs $ptconf; then ready=1 elif gedit $ptconf; then ready=1 elif vi $ptconf; then ready=1 else echo echo "=================" echo "IMPORTANT WARNING" echo "=================" echo "No common text editor was found on this system." echo "Please set the values in the following files manually:" echo " - $pconf" # --------- Delete for no Gnuastro --------- echo " - $gconf" # ------------------------------------------ echo "=================" echo ready=0 fi else ready=1 fi # --------- Delete for no Gnuastro --------- # From the input file, set the Gnuastro configuration file. mm=$(awk '$1=="MINMAPSIZE"{print $3}' $ptconf) add_top_notice $gconf echo "minmapsize $mm" >> $gconf # ------------------------------------------ # Make the final file that will be used. add_top_notice $pconf cat $ptconf >> $pconf rm $ptconf # Print a final notice. echo if [ $ready = 1 ]; then echo "This reproduction pipeline has been configured for this system." echo "Please run the following command to start the pipeline:" else echo "AFTER MANUALLY EDITING THE FILE(S) ABOVE, please run the following" echo "commands to run the pipeline." fi echo "(Replace '8' with the number of CPU threads available)" echo echo " make -j8" echo echo "To change the configuration later, please re-run './configure'," echo "DO NOT manually edit the relevant files." echo