Verifies profile support before executing profile options
New option to list available profiles
This commit is contained in:
@@ -8,8 +8,8 @@
|
|||||||
## Version information
|
## Version information
|
||||||
|
|
||||||
VERSION_REV=13
|
VERSION_REV=13
|
||||||
VERSION_MAJOR=0
|
VERSION_MAJOR=1
|
||||||
VERSION_MINOR=1
|
VERSION_MINOR=0
|
||||||
|
|
||||||
## Start of generic script part
|
## Start of generic script part
|
||||||
|
|
||||||
@@ -26,9 +26,11 @@ ALIAS=
|
|||||||
CONTEXT_HELP=0
|
CONTEXT_HELP=0
|
||||||
SEQ_CONFIG_EDIT=0
|
SEQ_CONFIG_EDIT=0
|
||||||
SEQ_CONFIG_NAME=".seqs"
|
SEQ_CONFIG_NAME=".seqs"
|
||||||
SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME"
|
|
||||||
SEQ_CONFIG_FILE=
|
SEQ_CONFIG_FILE=
|
||||||
SEQ_PROFILE_NAME=default
|
SEQ_CONFIG_HOME="$HOME/$SEQ_CONFIG_NAME"
|
||||||
|
SEQ_PROFILE_SUPPORT=0
|
||||||
|
SEQ_PROFILE_NAME=
|
||||||
|
SEQ_PROFILE_LIST=0
|
||||||
TEMPLATE_NAME=seqTemplateExample.sh
|
TEMPLATE_NAME=seqTemplateExample.sh
|
||||||
MISSING_CONF=missingConf.log
|
MISSING_CONF=missingConf.log
|
||||||
VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}"
|
VERSION_STRING="${VERSION_REV}.${VERSION_MAJOR}.${VERSION_MINOR}"
|
||||||
@@ -65,6 +67,7 @@ Usage: ${0##*/} [OPTIONS] [STEP NUMBER(s) or ALIAS] [STEP ARGUMENTS]
|
|||||||
(e.g. exe,addconf,echerr,...)
|
(e.g. exe,addconf,echerr,...)
|
||||||
--profile, -p : Sequence configuration profile name (default: "default")
|
--profile, -p : Sequence configuration profile name (default: "default")
|
||||||
(if supported by sequence)
|
(if supported by sequence)
|
||||||
|
-pl : List available profiles
|
||||||
--quiet, -q : Don't ask for permission to execute steps
|
--quiet, -q : Don't ask for permission to execute steps
|
||||||
If called without starting step number, only this help is shown
|
If called without starting step number, only this help is shown
|
||||||
-qq : Same as --quiet but suppresses regular sequencer.sh output
|
-qq : Same as --quiet but suppresses regular sequencer.sh output
|
||||||
@@ -420,6 +423,22 @@ endReturn() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# listProfiles [OPTION]
|
||||||
|
# List all available profiles for current user
|
||||||
|
# [OPTION]
|
||||||
|
# -q : only check for profile support
|
||||||
|
listProfiles() {
|
||||||
|
local file=
|
||||||
|
if [ $SEQ_PROFILE_SUPPORT -eq 0 ]; then
|
||||||
|
echoerr " [E] $0 does not support configuration profiles"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
[ "$1" == "-q" ] && return 0
|
||||||
|
for file in $(ls "$SEQ_CONFIG_HOME"); do
|
||||||
|
echo ${file%.*}
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# initSeqConfig [OPTION] <NAME> [TEMPLATE]
|
# initSeqConfig [OPTION] <NAME> [TEMPLATE]
|
||||||
# Create a configuration file in the users' home.
|
# Create a configuration file in the users' home.
|
||||||
# Source it if already existent
|
# Source it if already existent
|
||||||
@@ -457,6 +476,8 @@ initSeqConfig() {
|
|||||||
|
|
||||||
local configLoc="$SEQ_CONFIG_HOME/$1"
|
local configLoc="$SEQ_CONFIG_HOME/$1"
|
||||||
if [ $seqProfiles -ne 0 ] ; then
|
if [ $seqProfiles -ne 0 ] ; then
|
||||||
|
SEQ_PROFILE_SUPPORT=1
|
||||||
|
[ -z "$SEQ_PROFILE_NAME" ] && SEQ_PROFILE_NAME=default
|
||||||
configLoc="$SEQ_CONFIG_HOME/$1/${SEQ_PROFILE_NAME}.cfg"
|
configLoc="$SEQ_CONFIG_HOME/$1/${SEQ_PROFILE_NAME}.cfg"
|
||||||
fi
|
fi
|
||||||
local configDir="$(dirname $configLoc)"
|
local configDir="$(dirname $configLoc)"
|
||||||
@@ -1033,27 +1054,27 @@ main() {
|
|||||||
--config|-c) # open sequence configuration file
|
--config|-c) # open sequence configuration file
|
||||||
QUIET=2
|
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
|
||||||
DRY=1
|
DRY=1
|
||||||
SEQUENCER_ARGS+=" $1"
|
SEQUENCER_ARGS+=" $1"
|
||||||
shift
|
shift;;
|
||||||
;;
|
|
||||||
--help|-h) # show only help
|
--help|-h) # show only help
|
||||||
displayHelp 1
|
displayHelp 1
|
||||||
exit 0;
|
exit 0;;
|
||||||
;;
|
|
||||||
--helpapi|-ha) #show build-in functions
|
--helpapi|-ha) #show build-in functions
|
||||||
helpApi
|
helpApi
|
||||||
exit 0;
|
exit 0;;
|
||||||
;;
|
|
||||||
--profile|-p) # seq profile name
|
--profile|-p) # seq profile name
|
||||||
SEQUENCER_ARGS+=" $1 $2"
|
SEQUENCER_ARGS+=" $1 $2"
|
||||||
shift
|
shift
|
||||||
SEQ_PROFILE_NAME="$1"
|
# Cover the case when only -p is given without profile name
|
||||||
shift
|
[ -z "$1" ] && SEQ_PROFILE_NAME=default || SEQ_PROFILE_NAME="$1"
|
||||||
;;
|
shift;;
|
||||||
|
-pl) # List available profiles
|
||||||
|
QUIET=2
|
||||||
|
SEQ_PROFILE_LIST=1
|
||||||
|
shift;;
|
||||||
--quiet|-q|-qq) # detect if option quiet is available
|
--quiet|-q|-qq) # detect if option quiet is available
|
||||||
SEQUENCER_ARGS+=" $1"
|
SEQUENCER_ARGS+=" $1"
|
||||||
if [ "$1" == "-qq" ] ; then
|
if [ "$1" == "-qq" ] ; then
|
||||||
@@ -1061,22 +1082,18 @@ main() {
|
|||||||
else
|
else
|
||||||
QUIET=1
|
QUIET=1
|
||||||
fi
|
fi
|
||||||
shift
|
shift;;
|
||||||
;;
|
|
||||||
--single|-s) # execute only one step and stop
|
--single|-s) # execute only one step and stop
|
||||||
SEQUENCER_ARGS+=" $1"
|
SEQUENCER_ARGS+=" $1"
|
||||||
SINGLE=1
|
SINGLE=1
|
||||||
shift
|
shift;;
|
||||||
;;
|
|
||||||
--verbose|-v) # set verbose flag
|
--verbose|-v) # set verbose flag
|
||||||
SEQUENCER_ARGS+=" $1"
|
SEQUENCER_ARGS+=" $1"
|
||||||
VERBOSE=1
|
VERBOSE=1
|
||||||
shift
|
shift;;
|
||||||
;;
|
|
||||||
--version) # version request
|
--version) # version request
|
||||||
showVersion
|
showVersion
|
||||||
exit 0;
|
exit 0;;
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -1144,6 +1161,13 @@ main() {
|
|||||||
echoerr " [E] Sequence does not have a configuration file"
|
echoerr " [E] Sequence does not have a configuration file"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for profile support
|
||||||
|
if [ $SEQ_PROFILE_LIST -ne 0 ]; then
|
||||||
|
listProfiles; exit $?
|
||||||
|
elif [ ! -z "$SEQ_PROFILE_NAME" ]; then
|
||||||
|
listProfiles -q || exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# check if more than one step is given and select execution mode
|
# check if more than one step is given and select execution mode
|
||||||
if [ $SINGLE -ne 0 ] ; then
|
if [ $SINGLE -ne 0 ] ; then
|
||||||
|
Reference in New Issue
Block a user