|
|
1d2b07 |
#!/bin/bash
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# conf.sh -- This function standardizes the way images are produced
|
|
|
1d2b07 |
# from configuration files.
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# This program is free software; you can redistribute it and/or modify
|
|
|
1d2b07 |
# it under the terms of the GNU General Public License as published by
|
|
|
1d2b07 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
1d2b07 |
# your option) any later version.
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# This program is distributed in the hope that it will be useful, but
|
|
|
1d2b07 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
1d2b07 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
1d2b07 |
# General Public License for more details.
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# You should have received a copy of the GNU General Public License
|
|
|
1d2b07 |
# along with this program; if not, write to the Free Software
|
|
|
1d2b07 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
1d2b07 |
#
|
|
|
1d2b07 |
# ----------------------------------------------------------------------
|
|
|
1d2b07 |
# $Id$
|
|
|
1d2b07 |
# ----------------------------------------------------------------------
|
|
|
1d2b07 |
|
|
|
1d2b07 |
function conf {
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Initialize local variables.
|
|
|
1d2b07 |
local MODEL=''
|
|
|
1d2b07 |
local -a MODELS
|
|
|
1d2b07 |
local FORMAT=''
|
|
|
1d2b07 |
local FORMATS=''
|
|
|
1d2b07 |
local HEIGHT=''
|
|
|
1d2b07 |
local HEIGHTS=''
|
|
|
1d2b07 |
local FGCOLOR=''
|
|
|
1d2b07 |
local FGCOLORS=''
|
|
|
1d2b07 |
local BGCOLOR=''
|
|
|
1d2b07 |
local BGCOLORS=''
|
|
|
1d2b07 |
local COMMAND=''
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Define list with all section names. These are the final file
|
|
|
1d2b07 |
# names we want to produce images for.
|
|
|
1d2b07 |
local FILENAME=''
|
|
|
1d2b07 |
local FILENAMES=$(cli_getConfigSectionNames $TEMPLATE)
|
|
|
1d2b07 |
|
|
|
1d2b07 |
for FILENAME in $FILENAMES;do
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Retrieve models you want to produce the image from. Notice
|
|
|
1d2b07 |
# that relative path passed in this option must begin with
|
|
|
1d2b07 |
# `trunk/' directory and point to an existent file.
|
|
|
1d2b07 |
for MODEL in $(cli_getConfigValue "$TEMPLATE" "$FILENAME" "models");do
|
|
|
1d2b07 |
MODELS[((++${#MODELS[*]}))]=${TCAR_WORKDIR}/${MODEL}
|
|
|
1d2b07 |
done
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Retrieve formats you want to produce the image for. This
|
|
|
1d2b07 |
# variable contains one or more image format supported by
|
|
|
1d2b07 |
# ImageMagick. For example, `xpm', `jpg', 'tiff', etc.
|
|
|
1d2b07 |
FORMATS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "formats")
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Retrieve heights you want to produce the image for. This
|
|
|
1d2b07 |
# variable contains one or more numerical values. For example,
|
|
|
1d2b07 |
# `16', `24', `32', etc.
|
|
|
1d2b07 |
HEIGHTS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "heights")
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Retrieve foreground colors you want to produce the image
|
|
|
1d2b07 |
# for. This variable contains one or more color number in
|
|
|
1d2b07 |
# hexadecimal format. For example, `000000', `ffffff', etc.
|
|
|
1d2b07 |
FGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "fgcolors")
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Retrieve background colors you want to produce the image
|
|
|
1d2b07 |
# for. This variable contains one or more color number in
|
|
|
1d2b07 |
# hexadecimal format with opacity information included.
|
|
|
1d2b07 |
# Opacity is specified between 0.0 and 1.0 where 0.0 is full
|
|
|
1d2b07 |
# transparency and 1.0 full opacity. For example, the
|
|
|
1d2b07 |
# following values are accepted: `000000-0', `ffffff-1', etc.
|
|
|
1d2b07 |
BGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "bgcolors")
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Retrieve command-line you want execute to produce the image.
|
|
|
1d2b07 |
# For example, `/usr/bin/convert +append'
|
|
|
1d2b07 |
COMMAND=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "command")
|
|
|
1d2b07 |
|
|
|
1d2b07 |
for FGCOLOR in $FGCOLORS;do
|
|
|
1d2b07 |
for BGCOLOR in $BGCOLORS;do
|
|
|
1d2b07 |
for HEIGHT in $HEIGHTS;do
|
|
|
1d2b07 |
conf_doBaseActions
|
|
|
1d2b07 |
done
|
|
|
1d2b07 |
done
|
|
|
1d2b07 |
done
|
|
|
1d2b07 |
|
|
|
1d2b07 |
# Reset models list to prevent it from growing for each file
|
|
|
1d2b07 |
# name (configuration section) iteration and create this way
|
|
|
1d2b07 |
# unexpected images as final result.
|
|
|
1d2b07 |
unset MODELS
|
|
|
1d2b07 |
|
|
|
1d2b07 |
done
|
|
|
1d2b07 |
|
|
|
1d2b07 |
}
|