Sequencer - Allow further arguments and steps with '-c'
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
## Version information
|
||||
|
||||
VERSION_REV=15
|
||||
VERSION_MAJOR=1
|
||||
VERSION_MAJOR=2
|
||||
VERSION_MINOR=0
|
||||
|
||||
## Start of generic script part
|
||||
@@ -505,7 +505,8 @@ listProfiles() {
|
||||
# 3 : No configuration created
|
||||
initSeqConfig() {
|
||||
local arg
|
||||
local answer
|
||||
local answer=n
|
||||
local retVal=255
|
||||
local sourceAlways=0
|
||||
local createEmpty=0
|
||||
local seqProfiles=0
|
||||
@@ -546,14 +547,14 @@ initSeqConfig() {
|
||||
if [ -s "$configLoc" ] ; then
|
||||
echoseq " [I] Using configuration file: $configLoc"
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
. "$configLoc"
|
||||
exe . "$configLoc"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Ask for config creation if not existent
|
||||
if [ $QUIET -eq 0 ] && [ $DRY -eq 0 ]; then
|
||||
echo " [I] Configuration $configLoc missing"
|
||||
read -p "Create it now? y/[n]? " answer
|
||||
exe read -p "Create it now? y/[n]? " answer
|
||||
case $answer in
|
||||
[yY])
|
||||
;;
|
||||
@@ -574,28 +575,27 @@ initSeqConfig() {
|
||||
|
||||
echoerr " [I] Using existing configuration: $configExists"
|
||||
echoerr " (Moved to $configDir)"
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
. "$configLoc"
|
||||
return 0
|
||||
fi
|
||||
|
||||
exe install -m 600 -T "$configTemplate" "$configLoc"
|
||||
endReturn -o $? "Failed to create configuration"
|
||||
|
||||
if [ $sourceAlways -eq 0 ] ; then
|
||||
if [ $SEQ_CONFIG_EDIT -eq 0 ] ; then
|
||||
echoerr " [W] Seq configuration created from template but not used"
|
||||
echoerr " Please modify "$configLoc" first and restart sequence"
|
||||
fi
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
return 1
|
||||
exe . "$configLoc"
|
||||
retVal=0
|
||||
else
|
||||
echo " [W] Using seq configuration from template $configTemplate"
|
||||
echo " (Copied to $configDir)"
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
. "$configTemplate"
|
||||
return 0
|
||||
# Install new template to the final location
|
||||
exe install -m 600 -T "$configTemplate" "$configLoc"
|
||||
endReturn -o $? "Failed to create configuration"
|
||||
|
||||
if [ $sourceAlways -eq 0 ] ; then
|
||||
if [ $SEQ_CONFIG_EDIT -eq 0 ] ; then
|
||||
echoerr " [W] Seq configuration created from template but not used"
|
||||
echoerr " Please modify "$configLoc" first"
|
||||
fi
|
||||
retVal=1
|
||||
else
|
||||
echo " [W] Using seq configuration from template $configTemplate"
|
||||
echo " (Copied to $configDir)"
|
||||
exe . "$configTemplate"
|
||||
retVal=0
|
||||
fi
|
||||
fi
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
else
|
||||
echo " [W] Seq configuration template not found"
|
||||
fi
|
||||
@@ -605,11 +605,26 @@ initSeqConfig() {
|
||||
echo " [W] Created empty configuration file $configLoc"
|
||||
exe touch "$configLoc"
|
||||
exe chmod 600 "$configLoc"
|
||||
return 2
|
||||
SEQ_CONFIG_FILE="$configLoc"
|
||||
retVal=2
|
||||
fi
|
||||
|
||||
echoerr " [E] No seq configuration created"
|
||||
return 3
|
||||
# Give the user a chance to edit the create config file
|
||||
if [ $retVal -eq 255 ]; then
|
||||
echoerr " [E] No seq configuration created"
|
||||
retVal=3
|
||||
elif [ $QUIET -eq 0 ] && [ $DRY -eq 0 ]; then
|
||||
exe read -p "Edit configuration file now? y/[n]? " answer
|
||||
case $answer in
|
||||
[yY])
|
||||
exe "$DEFAULT_EDITOR_SYSTEM" "$configLoc"
|
||||
exe . "$configLoc"
|
||||
retVal=0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return $retVal
|
||||
}
|
||||
|
||||
# addConf <CONF_MODE> [FILE_MODE] <SOURCE> <DESTINATION_FILE>
|
||||
@@ -1187,6 +1202,7 @@ main() {
|
||||
local START=0
|
||||
local STARTALL
|
||||
local EMPTYCALL=1
|
||||
local quietSave=
|
||||
|
||||
# options check
|
||||
for arg in "$@" ; do
|
||||
@@ -1195,7 +1211,6 @@ main() {
|
||||
STARTALL="-a"
|
||||
shift;;
|
||||
--config|-c) # open sequence configuration file
|
||||
QUIET=2
|
||||
SEQ_CONFIG_EDIT=1
|
||||
shift;;
|
||||
--dry-run|-d) # shows what would be done
|
||||
@@ -1243,8 +1258,11 @@ main() {
|
||||
exit 0;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Don't show help if only configuration should be edited
|
||||
[ $SEQ_CONFIG_EDIT -ne 0 ] && [ -z "$1" ] && QUIET=2
|
||||
|
||||
if [ -z "$1" ] || [ "$1" == "" ] ; then
|
||||
if [ -z "$1" ] ; then
|
||||
if [ $QUIET -eq 0 ] ; then
|
||||
# Empty -> show help
|
||||
displayHelp
|
||||
@@ -1299,13 +1317,17 @@ main() {
|
||||
|
||||
# Create/edit configuration file
|
||||
if [ $SEQ_CONFIG_EDIT -ne 0 ] ; then
|
||||
# Suppress step_config output for editing
|
||||
quietSave=$QUIET
|
||||
QUIET=2
|
||||
step_config "${STEP_ARGS[@]}"
|
||||
QUIET=$quietSave
|
||||
if [ -w "$SEQ_CONFIG_FILE" ]; then
|
||||
"$DEFAULT_EDITOR_SYSTEM" "$SEQ_CONFIG_FILE"
|
||||
exe "$DEFAULT_EDITOR_SYSTEM" "$SEQ_CONFIG_FILE"
|
||||
else
|
||||
echoerr " [E] No configuration file available"
|
||||
fi
|
||||
exit 0
|
||||
[ $EMPTYCALL -ne 0 ] && exit 0
|
||||
fi
|
||||
|
||||
checkStep "${START[0]}"
|
||||
|
Reference in New Issue
Block a user