Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 330 lines (294 sloc) 13.2 KB
#!/usr/bin/env bash
#compound opts=(verbose=)
ME=install_forcast
usage=$'
[+NAME?install_forcast - install drip in a specific directory and modify paths in configuration file]
[+DESCRIPTION?Given a input directory or tar file containing the source this tool will move
the source to the destination directory and modify text files to match the specified
directories to the directories of the installation]
[c:copy from a given location. If not specified the tool assumes that the destination directory contains the source
and data]
[v:verbose?Print files as they are transferred.]
[+EXAMPLE]{
[+./install_drip /home/mcharcos/Downloads/forcast /usr/local/drip?Install drip at /usr/local/drip by
copying the source from the forcast directory in Downloads.]
[+./install_drip /home/mcharcos/Downloads/forcast.tar /usr/local/drip?Install drip at /usr/local/drip by
untaring the forcast.tar in directory in Downloads and copying the uncompressed files to the destination.]}
[+EXIT VAUES]{
[+0?Success.]
[+1?Failure.]}
[+SEE ALSO? none]'
path_sep="/"
destination=${!#%$path_sep}
source=$destination
# Read input options
while getopts v:s:hg option
do
case "${option}"
in
v) echo "verbose";;
s) source=${OPTARG%$path_sep};;
h) echo $usage && exit 0;;
esac
done
if [ "$#" -lt 1 ]; then
echo "Usage: install_drip -s source - v -g destination_directory"
echo " Source should be a directory with structure "
echo " + drip${path_sep}work"
echo " + drip${path_sep}data"
echo " If not specified the destination should contain this file structure"
echo
if [ "$#" -eq 0 ]; then
echo "Missing destination"
exit 1
fi
fi
# Move or extract source in destination (if necessary)
# and verify the directory structure
./forcast_dir_setup $source $destination
if [ $? -ne 0 ]; then
echo "Installation failed"
exit 1
fi
# define the work and the data directory
inst_work=$(cd "$destination${path_sep}work" && pwd)
echo "Source code directory: $inst_work"
inst_data=$(cd "$destination${path_sep}data" && pwd)
echo "Data directory: $inst_data"
inst_libs=$(cd "$destination${path_sep}libs" && pwd)
echo "Library directory: $inst_libs"
# Modify configuration files: dripconf.txt and guiconf.txt
# for drip and fg
if [[ -d "$destination${path_sep}work${path_sep}drip" ]]; then
echo "========"
echo "= DRIP ="
echo "========"
echo "Setting drip pipeline configuration..."
echo "Modifying dripconf and guiconf files..."
echo "Calling: ./config_setup $inst_work${path_sep}drip $inst_data"
./config_setup $inst_work${path_sep}drip $inst_data
if [ $? -ne 0 ]; then
echo "Installation failed"
exit 1
fi
# Create drip_startup file
fstart="drip_startup"
if [[ -f $inst_work${path_sep}$fstart ]]; then
echo "Removed existing $fstart"
rm $inst_work${path_sep}$fstart
fi
echo "Creating $fstart..."
touch $inst_work${path_sep}$fstart
echo "device, true_color=24" >> $inst_work${path_sep}$fstart
echo "device, decomposed=0" >> $inst_work${path_sep}$fstart
echo "device, retain=2" >> $inst_work${path_sep}$fstart
echo "" >> $inst_work${path_sep}$fstart
echo "!PATH= '+$inst_work${path_sep}drip${path_sep}:+$inst_work${path_sep}common${path_sep}:+$inst_libs${path_sep}:+' +!PATH + ':+' +!dir" >> $inst_work${path_sep}$fstart
echo "!PATH=EXPAND_PATH(!PATH,/all_dirs)" >> $inst_work${path_sep}$fstart
fi
if [[ -d "$destination${path_sep}work${path_sep}fg" ]]; then
echo "========"
echo "= FG ="
echo "========"
echo "Setting drip pipeline configuration..."
echo "Modifying dripconf and guiconf files..."
echo "Calling: ./config_setup $inst_work${path_sep}fg $inst_data"
./config_setup "$inst_work${path_sep}fg" "$inst_data"
if [ $? -ne 0 ]; then
echo "Installation failed"
exit 1
fi
# Create fg_startup file
fstart="fg_startup"
if [[ -f $inst_work${path_sep}$fstart ]]; then
echo "Removed existing $fstart"
rm $inst_work${path_sep}$fstart
fi
echo "Creating $fstart..."
touch $inst_work${path_sep}$fstart
echo "device, true_color=24" >> $inst_work${path_sep}$fstart
echo "device, decomposed=0" >> $inst_work${path_sep}$fstart
echo "device, retain=2" >> $inst_work${path_sep}$fstart
echo "" >> $inst_work${path_sep}$fstart
echo "!PATH= '+$inst_work${path_sep}fg${path_sep}:+$inst_work${path_sep}common${path_sep}:+$inst_libs${path_sep}:+' +!PATH + ':+' +' +!dir" >> $inst_work${path_sep}$fstart
echo "!PATH=EXPAND_PATH(!PATH,/all_dirs)" >> $inst_work${path_sep}$fstart
fi
######################################################################
# Create other useful files including
# - Wrapper to run the pipeline with dcs
# = An executable to run drip, fg, gdrip and gfg in mode bash
######################################################################
# Now we are going to create an executable (shell wrapper) as a shorcut for running drip
if [[ -d "$destination${path_sep}work${path_sep}drip" ]]; then
dripdir=$(cd $destination${path_sep}work${path_sep}drip${path_sep} && pwd)
dripexec="$dripdir${path_sep}drip_gui"
if [[ -f $dripexec ]]; then rm $dripexec; fi
touch $dripexec
echo "gdrip" >> $dripexec
dripexec="$dripdir${path_sep}gdrip"
if [[ -f $dripexec ]]; then rm $dripexec; fi
touch $dripexec
chmod a+x $dripexec
chmod a+w $dripdir${path_sep}conffiles
echo "#!/usr/bin/env bash" >> $dripexec
echo "" >> $dripexec
echo " while getopts rpcdua option" >> $dripexec
echo "do" >> $dripexec
echo " case \"\${option}\"" >> $dripexec
echo " in" >> $dripexec
echo " r) rflag=1;;" >> $dripexec
echo " p) pflag=1;;" >> $dripexec
echo " c) cflag=1;;" >> $dripexec
echo " d) dflag=1;;" >> $dripexec
echo " u) uflag=1;;" >> $dripexec
echo " a) aflag=1;;" >> $dripexec
echo " esac" >> $dripexec
echo "done" >> $dripexec
echo "" >> $dripexec
echo "if [ ! -z \"\$dflag\" ]; then" >> $dripexec
echo " dripconf=$inst_work${path_sep}drip${path_sep}dripconf.txt" >> $dripexec
echo " guiconf=$inst_work${path_sep}drip${path_sep}guiconf.txt" >> $dripexec
echo "else" >> $dripexec
echo " if [ ! -z \"\$uflag\" ]; then " >> $dripexec
echo " dripconf=\"$inst_work${path_sep}drip${path_sep}conffiles${path_sep}dripconf\${USER}.txt\"" >> $dripexec
echo " guiconf=\"$inst_work${path_sep}drip${path_sep}conffiles${path_sep}guiconf\${USER}.txt\"" >> $dripexec
echo " else" >> $dripexec
echo " dripconf=\"/tmp/\$(basename dripconf)\$\$\$\$.txt\"" >> $dripexec
echo " guiconf=\"/tmp/\$(basename guiconf)\$\$\$\$.txt\"" >> $dripexec
echo " tempconf='y'" >> $dripexec
echo " fi" >> $dripexec
echo " if ! [[ -f \$dripconf ]]; then " >> $dripexec
echo " cp $inst_work${path_sep}drip${path_sep}dripconf.txt \$dripconf" >> $dripexec
echo " fi" >> $dripexec
echo " if ! [[ -f \$guiconf ]]; then " >> $dripexec
echo " cp $inst_work${path_sep}drip${path_sep}guiconf.txt \$guiconf" >> $dripexec
echo " fi" >> $dripexec
echo "fi" >> $dripexec
echo "" >> $dripexec
echo "export DRIPCONF_CURRENT=\$dripconf" >> $dripexec
echo "export GUICONF_CURRENT=\$guiconf" >> $dripexec
echo "echo \"Dripconf file is \$dripconf\"" >> $dripexec
echo "echo \"Guiconf file is \$guiconf\"" >> $dripexec
echo "" >> $dripexec
echo "if [ ! -z \"\$rflag\" ]; then" >> $dripexec
echo " echo \"Updating LOADDATAPATH...\"" >> $dripexec
echo " perl -pi -e \"s|.*loaddatapath\s*=.*|LOADDATAPATH='\$(pwd)/'|i\" \$guiconf" >> $dripexec
echo "fi" >> $dripexec
echo "if [ ! -z \"\$pflag\" ]; then" >> $dripexec
echo " echo \"Updating SAVEPATH...\"" >> $dripexec
echo " perl -pi -e \"s|.*savepath\s*=.*|SAVEPATH='\$(pwd)/'|i\" \$guiconf" >> $dripexec
echo "fi" >> $dripexec
echo "if [ ! -z \"\$cflag\" ]; then" >> $dripexec
echo " echo \"Updating SAVECALPATH...\"" >> $dripexec
echo " perl -pi -e \"s|.*savecalpath\s*=.*|SAVECALPATH='\$(pwd)/'|i\" \$guiconf" >> $dripexec
echo "fi" >> $dripexec
echo "" >> $dripexec
echo "if [ ! -z \"\$aflag\" ]; then" >> $dripexec
echo " if [[ -n \$DPS_DRIP_CORMERGE ]]; then" >> $dripexec
echo " echo \"Modifying CORMERGE...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*cormerge\s*=.*|CORMERGE='\$DPS_DRIP_CORMERGE'|i\" \$dripconf" >> $dripexec
echo " else" >> $dripexec
echo " echo \"DRIP_CORMERGE is not set \"" >> $dripexec
echo " fi;" >> $dripexec
echo " if [[ -n \$DPS_DRIP_CORCOADD ]]; then" >> $dripexec
echo " echo \"Modifying CORCOADD...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*corcoadd\s*=.*|CORCOADD='\$DPS_DRIP_CORCOADD'|i\" \$dripconf" >> $dripexec
echo " else" >> $dripexec
echo " echo \"DRIP_CORCOADD is not set \"" >> $dripexec
echo " fi;" >> $dripexec
echo " if [[ -n \$DPS_DRIP_JBCLEAN ]]; then" >> $dripexec
echo " echo \"Modifying JBCLEAN...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*jbclean\s*=.*|JBCLEAN='\$DPS_DRIP_JBCLEAN'|i\" \$dripconf" >> $dripexec
echo " else" >> $dripexec
echo " echo \"DRIP_JBCLEAN is not set \"" >> $dripexec
echo " fi;" >> $dripexec
echo " if [[ -n \$DPS_DRIP_NLINSIZE ]]; then" >> $dripexec
echo " echo \"Modifying NLINSIZE...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*nlinsize\s*=.*|NLINSIZE='\$DPS_DRIP_NLINSIZE'|i\" \$dripconf" >> $dripexec
echo " else" >> $dripexec
echo " echo \"DRIP_NLINSIZE is not set \"" >> $dripexec
echo " fi;" >> $dripexec
echo "" >> $dripexec
echo "fi" >> $dripexec
echo "" >> $dripexec
echo "export IDL_STARTUP=$inst_work${path_sep}drip_startup" >> $dripexec
echo "Starting DRIP..." >> $dripexec
echo "if [ ! -z \"\$aflag\" ]; then" >> $dripexec
echo " (" >> $dripexec
echo " echo \"drip_pipe, 'inputset.lst',outDMfile='outputset.lst',outlist=['merged','coadded','undistorted']\"" >> $dripexec
echo " )|idl" >> $dripexec
echo "else" >> $dripexec
echo " idl $dripdir${path_sep}drip_gui" >> $dripexec
echo "fi" >> $dripexec
echo "" >> $dripexec
echo "if [ \"\$tempconf\" == 'y' ]; then" >> $dripexec
echo " echo \"Removing temporary files: \$dripconf and \$guiconf\"" >> $dripexec
echo " rm \$dripconf" >> $dripexec
echo " rm \$guiconf" >> $dripexec
echo "fi" >> $dripexec
chmod u+x $dripexec
echo "Add this line to your .bashrc file:"
echo " alias gdrip=$dripdir${path_sep}gdrip"
echo "You will be able to run drip from any directory"
fi
if [[ -d "$destination${path_sep}work${path_sep}fg" ]]; then
dripdir="$destination${path_sep}work${path_sep}fg${path_sep}"
dripdir=$(cd $dripdir && pwd)
dripexec="$dripdir${path_sep}fg"
if [[ -f $dripexec ]]; then rm $dripexec; fi
touch $dripexec
echo "#!/usr/bin/env bash" >> $dripexec
echo "(" >> $dripexec
echo " echo \"@$dripdir${path_sep}fgstart.start\"" >> $dripexec
echo " echo \"gui\"" >> $dripexec
#echo " echo \"input=''\"" >> $dripexec
#echo " echo \"while (input ne 'q') do begin\"" >> $dripexec
#echo " echo \"read, "Press q to quit: ", input\"" >> $dripexec
#echo " echo \"endwhile\"" >> $dripexec
echo ")|idl" >> $dripexec
chmod u+x $dripexec
echo "Add this line to your .bashrc file:"
echo " alias gfg=$dripdir${path_sep}gfg"
echo "You will be able to run fg from any directory"
fi
# Create wrapper for drip in dcs
if [[ -d "$destination${path_sep}work${path_sep}drip" ]]; then
dripdir=$(cd $destination${path_sep}work${path_sep}drip${path_sep} && pwd)
dripexec="$dripdir${path_sep}drip_auto"
if [[ -f $dripexec ]]; then rm $dripexec; fi
touch $dripexec
echo "#!/usr/bin/env bash" >> $dripexec
echo "" >> $dripexec
echo "if [[ -n \$DPS_DRIP_CORMERGE ]]; then" >> $dripexec
echo " echo \"Modifying CORMERGE...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*cormerge\s*=.*|CORMERGE='\$DPS_DRIP_CORMERGE'|i\" $inst_work${path_sep}drip${path_sep}dripconf.txt" >> $dripexec
echo "else" >> $dripexec
echo " echo \"DRIP_CORMERGE is not set \"" >> $dripexec
echo "fi;" >> $dripexec
echo "if [[ -n \$DPS_DRIP_CORCOADD ]]; then" >> $dripexec
echo " echo \"Modifying CORCOADD...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*corcoadd\s*=.*|CORCOADD='\$DPS_DRIP_CORCOADD'|i\" $inst_work${path_sep}drip${path_sep}dripconf.txt" >> $dripexec
echo "else" >> $dripexec
echo " echo \"DRIP_CORCOADD is not set \"" >> $dripexec
echo "fi;" >> $dripexec
echo "if [[ -n \$DPS_DRIP_JBCLEAN ]]; then" >> $dripexec
echo " echo \"Modifying JBCLEAN...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*jbclean\s*=.*|JBCLEAN='\$DPS_DRIP_JBCLEAN'|i\" $inst_work${path_sep}drip${path_sep}dripconf.txt" >> $dripexec
echo "else" >> $dripexec
echo " echo \"DRIP_JBCLEAN is not set \"" >> $dripexec
echo "fi;" >> $dripexec
echo "if [[ -n \$DPS_DRIP_NLINSIZE ]]; then" >> $dripexec
echo " echo \"Modifying NLINSIZE...\"" >> $dripexec
echo " perl -pi -e \"s|^\s*nlinsize\s*=.*|NLINSIZE='\$DPS_DRIP_NLINSIZE'|i\" $inst_work${path_sep}drip${path_sep}dripconf.txt" >> $dripexec
echo "else" >> $dripexec
echo " echo \"DRIP_NLINSIZE is not set \"" >> $dripexec
echo "fi;" >> $dripexec
echo "" >> $dripexec
echo "Starting DRIP..." >> $dripexec
echo "" >> $dripexec
echo "(" >> $dripexec
echo "echo \"drip_pipe, 'inputset.lst',outDMfile='outputset.lst',outlist=['merged','coadded','undistorted']\"" >> $dripexec
echo ")|idl" >> $dripexec
chmod u+x $dripexec
fi
exit 0
Jump to Line
Something went wrong with that request. Please try again.