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