Use available configuration file if exists in the same directory as the template
This commit is contained in:
@@ -101,10 +101,10 @@ helpApi() {
|
||||
echo " [OPTION]"
|
||||
echo " -t : Source config also if created from template"
|
||||
echo " Returns"
|
||||
echo " 0 : Sourced configuration or"
|
||||
echo " (-t) : Created and sourced configuration from template"
|
||||
echo " 1 : Created configuration from template but not sourced"
|
||||
echo " 2 : or created empty configuration"
|
||||
echo " 0 : sourced configuration or"
|
||||
echo " (-t) : created and sourced configuration from template"
|
||||
echo " 1 : created configuration from template but not sourced"
|
||||
echo " 2 : created empty configuration"
|
||||
echo
|
||||
echo " addConf <OPTIONS> [SOURCE TYPE] <SOURCE> <DESTINATION FILE>"
|
||||
echo " Trying to write or append text or a file (<SOURCE>) to a destination file."
|
||||
@@ -279,9 +279,9 @@ endReturn() {
|
||||
# -t : Source config also if created from template
|
||||
# Return
|
||||
# 0 : Sourced configuration or
|
||||
# (-t) : Created and sourced configuration from template
|
||||
# (-t) : created and sourced configuration from template
|
||||
# 1 : Created configuration from template but not sourced
|
||||
# 2 : or created empty configuration
|
||||
# 2 : Created empty configuration
|
||||
initSeqConfig() {
|
||||
local sourceAlways=0
|
||||
for arg in "$@" ; do
|
||||
@@ -311,6 +311,19 @@ initSeqConfig() {
|
||||
|
||||
# Config does not exist, check for template
|
||||
if [ -s "$configTemplate" ] ; then
|
||||
|
||||
# Check first if there is an existing configuration at the templates position
|
||||
local configExists="$(dirname $configTemplate)/$1"
|
||||
if [ -s "$configExists" ] ; then
|
||||
exe mv "$configExists" "$configLoc"
|
||||
endReturn -o $? "Unable to use existing configuration: $configExists"
|
||||
|
||||
echoerr " [I] Using existing configuration: $configExists"
|
||||
echoerr " (Moved to $SEQ_CONFIG_HOME)"
|
||||
. "$configLoc"
|
||||
return 0
|
||||
fi
|
||||
|
||||
exe cp -ar "$configTemplate" "$configLoc"
|
||||
endReturn -o $? "Failed to create configuration"
|
||||
|
||||
@@ -320,6 +333,7 @@ initSeqConfig() {
|
||||
return 1
|
||||
else
|
||||
echo " [W] Using seq configuration from template $configTemplate"
|
||||
echo " (Copied to $SEQ_CONFIG_HOME)"
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
. "$configLoc"
|
||||
return 0
|
||||
@@ -724,6 +738,7 @@ displayHelp() {
|
||||
echo " - step_${i}_info() missing"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user