# setup - notices and documentation at the end of the file

PS1='\[\033[01;34m\]\w$\[\033[00m\] '            # delete to avoid changing the prompt

export VERHOME=${BASH_SOURCE/\/lib\/setup/}      # home=/foo/ver
PATH=$VERHOME/bin:$PATH

if [ -z ${PYTHONPATH+x} ]                        # create variable PYTHONPATH if it does not exist
 then export PYTHONPATH=$VERHOME/lib             # /foo/ver/lib
 else export PYTHONPATH=$VERHOME/lib:$PYTHONPATH # /foo/ver/lib:/bar/ori
fi

#------------------------------------------------#-------------------------------------------#
uflag=no_new                                     # uuid flag
ufile=$VERHOME/lib/uuid.txt                      # uuid file
ucur=$(cat $ufile)                               # uuid current
usys='151BCD68-299A-490D-BE1C-A4294A232AE8'      # uuid system

if [ $usys = $ucur ] ; then                      # generate new uuid if file contains the system uuid
  uuidgen > $ufile
  uflag=new
fi

#------------------------------------------------#-------------------------------------------#
# if lib/setup exists and .bash_profile does not contain the source string, add it to the profile file
pflag=no_insertion                               # profile flag
pfile="$HOME/.bash_profile"                      # profile file
sfile="$VERHOME/lib/setup"                       # setup file
ts=$(date "+%y%m%d-%H%M%S")                      # timestamp
pros="[ -a $sfile ] && source $sfile # Vereda $ts $usys execute only if setup file exists" # profile string

if [ -a "$sfile" ] && ! grep -q "$usys" "$pfile" ; then
 echo "$pros" >> "$pfile"
 pflag=insertion
fi

#------------------------------------------------#-------------------------------------------#
printf "description:log of the last execution of \"source ver/lib/setup\", command line or in \"~/.bash_profile\"
timestamp:$ts
uuid=$uflag
bash_profile=$pflag
VERHOME:$VERHOME
PYTHONPATH:$PYTHONPATH
PATH:$PATH
" > $VERHOME/lib/log.txt

#------------------------------------------------#-------------------------------------------#
<<notices
title:setup
description:vereda setup; it changes  PATH and PYTHONPATH
version:1
date:2023-11-05
creator:M.T. Carrasco Benitez
rights:CC BY-SA - Creative Commons Attribution-ShareAlike
notices
