|
|
eb0e14 |
#!/bin/bash
|
|
|
eb0e14 |
#
|
|
|
ab1d67 |
# render_getConfigOption.sh -- This function standardizes the way
|
|
|
661b04 |
# action values are retrived from pre-rendition configuration files.
|
|
|
661b04 |
# Use this function whenever you need to retrive action values from
|
|
|
15b1d2 |
# pre-rendition configuration script.
|
|
|
eb0e14 |
#
|
|
|
ab1d67 |
# Usage: VAR=$(render_getConfigOption "ACTION" "FIELD")
|
|
|
eb0e14 |
#
|
|
|
69eed6 |
# VAR is the name of the variable where we store the option named
|
|
|
ab1d67 |
# returned by render_getConfigOption.
|
|
|
eb0e14 |
#
|
|
|
15b1d2 |
# ACTION is the string definition set in the pre-rendition
|
|
|
69eed6 |
# configuration script that holds the action name and its options
|
|
|
7cd8e9 |
# fields.
|
|
|
eb0e14 |
#
|
|
|
69eed6 |
# FIELD is the field number in the action string we want to retrive
|
|
|
69eed6 |
# option from. By default options start from third field on. The first
|
|
|
661b04 |
# field is reserved for the action type (i.e., POST or LAST), and the
|
|
|
dc167f |
# second field is reserved for the action itself (e.g., convertPngTo,
|
|
|
661b04 |
# renderSyslinux, renderKsplash, etc.).
|
|
|
eb0e14 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
eb0e14 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# This program is distributed in the hope that it will be useful, but
|
|
|
eb0e14 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
eb0e14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
eb0e14 |
# General Public License for more details.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# You should have received a copy of the GNU General Public License
|
|
|
eb0e14 |
# along with this program; if not, write to the Free Software
|
|
|
eb0e14 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
eb0e14 |
# USA.
|
|
|
eb0e14 |
#
|
|
|
eb0e14 |
# ----------------------------------------------------------------------
|
|
|
eb0e14 |
# $Id$
|
|
|
eb0e14 |
# ----------------------------------------------------------------------
|
|
|
eb0e14 |
|
|
|
ab1d67 |
function render_getConfigOption {
|
|
|
eb0e14 |
|
|
|
eb0e14 |
local ACTION="$1"
|
|
|
eb0e14 |
local FIELD="$2"
|
|
|
eb0e14 |
local VALUE=''
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Check action value. The action's value must be present in order
|
|
|
eb0e14 |
# for this function to work. It provides the string needed to
|
|
|
eb0e14 |
# retrive options from.
|
|
|
eb0e14 |
if [[ "$ACTION" == '' ]];then
|
|
|
eb0e14 |
cli_printMessage "`gettext "There is no action to work with."`"
|
|
|
eb0e14 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
eb0e14 |
fi
|
|
|
eb0e14 |
|
|
|
eb0e14 |
# Check field value. The field's value must match the cut's
|
|
|
eb0e14 |
# command specification of its -f option.
|
|
|
eb0e14 |
if [[ ! "$FIELD" =~ '^([0-9]+|[0-9]+-|-[0-9]+|[0-9]+-[0-9]+)$' ]];then
|
|
|
eb0e14 |
cli_printMessage "`gettext "The field specified is not valid."`"
|
|
|
eb0e14 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
eb0e14 |
fi
|
|
|
eb0e14 |
|
|
|
15b1d2 |
# Get option from pre-rendition configuration action definition.
|
|
|
eb0e14 |
VALUE=$(echo -n "$ACTION" | cut -d: -f${FIELD})
|
|
|
eb0e14 |
|
|
|
15b1d2 |
# Sanitate action value passed from pre-rendition configuration
|
|
|
eb0e14 |
# action definition.
|
|
|
eb0e14 |
VALUE=$(echo -n "${VALUE}" \
|
|
|
eb0e14 |
| sed -r 's!^ *!!g' \
|
|
|
eb0e14 |
| sed -r 's!( |,|;) *! !g' \
|
|
|
eb0e14 |
| sed -r 's! *$!!g')
|
|
|
eb0e14 |
|
|
|
1b89c2 |
# Output action value without trailing newline.
|
|
|
eb0e14 |
echo -n "$VALUE"
|
|
|
eb0e14 |
|
|
|
eb0e14 |
}
|