Refining initSeqConfig function

Option to choose if empty config should be created (Is not by default)
This commit is contained in:
2020-06-04 15:19:17 +02:00
parent 4c50812346
commit 7a61dcd718

View File

@@ -7,9 +7,9 @@
## Version information
VERSION_REV=10
VERSION_REV=11
VERSION_MAJOR=0
VERSION_MINOR=2
VERSION_MINOR=0
## 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 " [OPTION]"
echo " -t : Source config also if created from template"
echo " -e : Create empty configuration if no template is found"
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 : created empty configuration"
echo " 3 : No configuration created"
echo
echo " addConf <OPTIONS> [SOURCE TYPE] <SOURCE> <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
# [OPTION]
# -t : Source config also if created from template
# -e : Create empty configuration if no template is found
# Return
# 0 : Sourced configuration or
# (-t) : created and sourced configuration from template
# 1 : Created configuration from template but not sourced
# 2 : Created empty configuration
# 3 : No configuration created
initSeqConfig() {
local sourceAlways=0
local createEmpty=0
for arg in "$@" ; do
case "$1" in
-t)
sourceAlways=1
shift
;;
-e)
createEmpty=1
shift
;;
esac
done
@@ -347,13 +356,18 @@ initSeqConfig() {
return 0
fi
else
echo " [W] Seq configuration template empty"
echo " [W] Seq configuration template not found"
fi
if [ $createEmpty -ne 0 ] ; then
# Create empty config file
echo " [W] Created empty configuration file $configLoc"
exe touch "$configLoc"
return 2
fi
echoerr " [E] No seq configuration created"
return 3
}
# addConf <CONF_MODE> [FILE_MODE] <SOURCE> <DESTINATION_FILE>