Refining initSeqConfig function
Option to choose if empty config should be created (Is not by default)
This commit is contained in:
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
## Version information
|
## Version information
|
||||||
|
|
||||||
VERSION_REV=10
|
VERSION_REV=11
|
||||||
VERSION_MAJOR=0
|
VERSION_MAJOR=0
|
||||||
VERSION_MINOR=2
|
VERSION_MINOR=0
|
||||||
|
|
||||||
## Start of generic script part
|
## Start of generic script part
|
||||||
|
|
||||||
@@ -100,11 +100,13 @@ helpApi() {
|
|||||||
echo " Create a configuration file in $SEQ_CONFIG_HOME/ and source it if already existent."
|
echo " Create a configuration file in $SEQ_CONFIG_HOME/ and source it if already existent."
|
||||||
echo " [OPTION]"
|
echo " [OPTION]"
|
||||||
echo " -t : Source config also if created from template"
|
echo " -t : Source config also if created from template"
|
||||||
|
echo " -e : Create empty configuration if no template is found"
|
||||||
echo " Returns"
|
echo " Returns"
|
||||||
echo " 0 : sourced configuration or"
|
echo " 0 : sourced configuration or"
|
||||||
echo " (-t) : created and sourced configuration from template"
|
echo " (-t) : created and sourced configuration from template"
|
||||||
echo " 1 : created configuration from template but not sourced"
|
echo " 1 : created configuration from template but not sourced"
|
||||||
echo " 2 : created empty configuration"
|
echo " 2 : created empty configuration"
|
||||||
|
echo " 3 : No configuration created"
|
||||||
echo
|
echo
|
||||||
echo " addConf <OPTIONS> [SOURCE TYPE] <SOURCE> <DESTINATION FILE>"
|
echo " addConf <OPTIONS> [SOURCE TYPE] <SOURCE> <DESTINATION FILE>"
|
||||||
echo " Trying to write or append text or a file (<SOURCE>) to a destination file."
|
echo " Trying to write or append text or a file (<SOURCE>) to a destination file."
|
||||||
@@ -285,19 +287,26 @@ endReturn() {
|
|||||||
# Source it if already existent
|
# Source it if already existent
|
||||||
# [OPTION]
|
# [OPTION]
|
||||||
# -t : Source config also if created from template
|
# -t : Source config also if created from template
|
||||||
|
# -e : Create empty configuration if no template is found
|
||||||
# Return
|
# Return
|
||||||
# 0 : Sourced configuration or
|
# 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
|
# 1 : Created configuration from template but not sourced
|
||||||
# 2 : Created empty configuration
|
# 2 : Created empty configuration
|
||||||
|
# 3 : No configuration created
|
||||||
initSeqConfig() {
|
initSeqConfig() {
|
||||||
local sourceAlways=0
|
local sourceAlways=0
|
||||||
|
local createEmpty=0
|
||||||
for arg in "$@" ; do
|
for arg in "$@" ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-t)
|
-t)
|
||||||
sourceAlways=1
|
sourceAlways=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-e)
|
||||||
|
createEmpty=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -347,13 +356,18 @@ initSeqConfig() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " [W] Seq configuration template empty"
|
echo " [W] Seq configuration template not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $createEmpty -ne 0 ] ; then
|
||||||
# Create empty config file
|
# Create empty config file
|
||||||
echo " [W] Created empty configuration file $configLoc"
|
echo " [W] Created empty configuration file $configLoc"
|
||||||
exe touch "$configLoc"
|
exe touch "$configLoc"
|
||||||
return 2
|
return 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echoerr " [E] No seq configuration created"
|
||||||
|
return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
# addConf <CONF_MODE> [FILE_MODE] <SOURCE> <DESTINATION_FILE>
|
# addConf <CONF_MODE> [FILE_MODE] <SOURCE> <DESTINATION_FILE>
|
||||||
|
Reference in New Issue
Block a user