exit 5
fi
+declare -a ADD_PUPPET_AGENT_ARGS=()
+TIMINGS="n"
+
detect_color
DESCRIPTION=$( cat <<-EOF
#------------------------------------------------------------------------------
usage() {
cat <<-EOF
- Usage: ${BASE_NAME} [Common Options]
+ Usage: ${BASE_NAME} [Common Options] [-t|--timing] [-- ADDITIIONAL_OPTION_FOR_PUPPET ...]
${BASE_NAME} [-h|--help]
${BASE_NAME} [-V|--version]
+ Special Options:
+ -t|--timing Display statistics about real, user and system time on execution of puppet agent.
+
Common Options:
${STD_USAGE_MSG}
EOF
local tmp=
local base_dir=
+ local arg=
set +e
- tmp=$( getopt -o ${STD_SHORT_OPTIONS} --long ${STD_LONG_OPTIONS} -n "${BASE_NAME}" -- "$@" )
+ tmp=$( getopt -o ${STD_SHORT_OPTIONS}t \
+ --long ${STD_LONG_OPTIONS},timing \
+ -n "${BASE_NAME}" -- "$@" )
if [[ $? != 0 ]] ; then
echo "" >&2
usage >&2
declare -p REMAINING_ARGS
fi
- if [[ "${#REMAINING_OPTS[@]}" -gt 0 ]] ; then
- error "Unknown options: ${REMAINING_OPTS[*]}"
- echo >&2
- usage >&2
- exit 2
- fi
+ local len="${#REMAINING_OPTS[*]}"
+ local i="0"
+ while [[ "$i" -lt "${len}" ]] ; do
+
+ arg="${REMAINING_OPTS[$i]}"
+
+ case "${arg}" in
+ -t|--timing)
+ TIMINGS="y"
+ i=$(( $i + 1 ))
+ ;;
+ *) echo -e "Internal error - option '${RED}${arg}${NORMAL} was wrong!"
+ exit 1
+ ;;
+ esac
+
+ done
if [[ "${#REMAINING_ARGS[@]}" != "0" ]] ; then
- error "Invalig arguments given: ${REMAINING_ARGS[*]}"
- echo >&2
- usage >&2
- exit 2
+ i="0"
+ for arg in "${REMAINING_ARGS[@]}" ; do
+ if [[ "${i}" == "0" && "${arg}" == '--' ]] ; then
+ continue
+ fi
+ i=$(( $i + 1 ))
+ ADD_PUPPET_AGENT_ARGS+=( "${arg}" )
+ done
fi
if [[ $(id -u -n) != "root" ]] ; then
i=$(( $1 + 1 ))
done
- local cmd="${PUPPET_BIN} agent --test"
+ local cmd=""
+ if [[ "${TIMINGS}" == "y" ]] ; then
+ cmd="time "
+ fi
+ cmd+="${PUPPET_BIN} agent --test"
if [[ "${SIMULATE}" == "y" ]] ; then
cmd+=" --noop"
fi
+ if [[ "${#ADD_PUPPET_AGENT_ARGS[@]}" != "0" ]] ; then
+ cmd+=" ${ADD_PUPPET_AGENT_ARGS[@]}"
+ fi
debug "Executing: ${cmd}"
set +e
eval ${cmd}