|
Alain Reguera Delgado |
8f60cb |
#!/bin/bash
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# conf.sh -- This function standardizes the way images are produced
|
|
Alain Reguera Delgado |
8f60cb |
# from configuration files.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# Copyright (C) 2009-2013 The CentOS Project
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
8f60cb |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
8f60cb |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
8f60cb |
# your option) any later version.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
8f60cb |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
8f60cb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
8f60cb |
# General Public License for more details.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
8f60cb |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
8f60cb |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
# $Id$
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
function conf {
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Initialize local variables.
|
|
Alain Reguera Delgado |
8f60cb |
local MODEL=''
|
|
Alain Reguera Delgado |
8f60cb |
local -a MODELS
|
|
Alain Reguera Delgado |
8f60cb |
local FORMAT=''
|
|
Alain Reguera Delgado |
8f60cb |
local HEIGHT=''
|
|
Alain Reguera Delgado |
8f60cb |
local FGCOLOR=''
|
|
Alain Reguera Delgado |
8f60cb |
local BGCOLOR=''
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define list with all section names. These are the final file
|
|
Alain Reguera Delgado |
8f60cb |
# names we want to produce images for.
|
|
Alain Reguera Delgado |
8f60cb |
local FILENAME=''
|
|
Alain Reguera Delgado |
8f60cb |
local FILENAMES=$(cli_getConfigSectionNames $TEMPLATE)
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
for FILENAME in $FILENAMES;do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Retrieve models you want to produce the image from. Notice
|
|
Alain Reguera Delgado |
8f60cb |
# that relative path passed in this option must point to one
|
|
Alain Reguera Delgado |
8f60cb |
# existent file inside the working copy.
|
|
Alain Reguera Delgado |
8f60cb |
for MODEL in $(cli_getConfigValue "$TEMPLATE" "$FILENAME" "models");do
|
|
Alain Reguera Delgado |
8f60cb |
MODELS[((++${#MODELS[*]}))]=${TCAR_WORKDIR}/${MODEL}
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Retrieve formats you want to produce the image for. This
|
|
Alain Reguera Delgado |
8f60cb |
# variable contains one or more image format supported by
|
|
Alain Reguera Delgado |
8f60cb |
# ImageMagick. For example, `xpm', `jpg', 'tiff', etc.
|
|
Alain Reguera Delgado |
8f60cb |
local FORMATS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "formats")
|
|
Alain Reguera Delgado |
8f60cb |
if [[ -z ${FORMATS} ]];then
|
|
Alain Reguera Delgado |
8f60cb |
FORMATS="xpm pdf jpg tif"
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Retrieve heights you want to produce the image for. This
|
|
Alain Reguera Delgado |
8f60cb |
# variable contains one or more numerical values. For example,
|
|
Alain Reguera Delgado |
8f60cb |
# `16', `24', `32', etc.
|
|
Alain Reguera Delgado |
8f60cb |
local HEIGHTS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "heights")
|
|
Alain Reguera Delgado |
8f60cb |
if [[ -z ${HEIGHTS} ]];then
|
|
Alain Reguera Delgado |
8f60cb |
HEIGHTS="16 20 22 24 32 36 38 40 48 64 72 78 96 112 124 128 148 164 196 200 512"
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Retrieve foreground colors you want to produce the image
|
|
Alain Reguera Delgado |
8f60cb |
# for. This variable contains one or more color number in
|
|
Alain Reguera Delgado |
8f60cb |
# hexadecimal format. For example, `000000', `ffffff', etc.
|
|
Alain Reguera Delgado |
8f60cb |
local FGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "fgcolors")
|
|
Alain Reguera Delgado |
8f60cb |
if [[ -z ${FGCOLORS} ]];then
|
|
Alain Reguera Delgado |
8f60cb |
FGCOLORS="000000"
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Retrieve background colors you want to produce the image
|
|
Alain Reguera Delgado |
8f60cb |
# for. This variable contains one or more color number in
|
|
Alain Reguera Delgado |
8f60cb |
# hexadecimal format with opacity information included.
|
|
Alain Reguera Delgado |
8f60cb |
# Opacity is specified between 0.0 and 1.0 where 0.0 is full
|
|
Alain Reguera Delgado |
8f60cb |
# transparency and 1.0 full opacity. For example, the
|
|
Alain Reguera Delgado |
8f60cb |
# following values are accepted: `000000-0', `ffffff-1', etc.
|
|
Alain Reguera Delgado |
8f60cb |
local BGCOLORS=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "bgcolors")
|
|
Alain Reguera Delgado |
8f60cb |
if [[ -z ${BGCOLORS} ]];then
|
|
Alain Reguera Delgado |
8f60cb |
BGCOLORS="000000-0"
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Retrieve command-line you want execute to produce the image.
|
|
Alain Reguera Delgado |
8f60cb |
# For example, `/usr/bin/convert +append'
|
|
Alain Reguera Delgado |
8f60cb |
local COMMAND=$(cli_getConfigValue "$TEMPLATE" "$FILENAME" "command")
|
|
Alain Reguera Delgado |
8f60cb |
if [[ -z ${COMMAND} ]];then
|
|
Alain Reguera Delgado |
8f60cb |
COMMAND=/bin/cp
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
for FGCOLOR in $FGCOLORS;do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify value passed as foreground color.
|
|
Alain Reguera Delgado |
8f60cb |
cli_checkFiles ${FGCOLOR} --match="^[a-fA-F0-9]{3,6}$"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
for BGCOLOR in $BGCOLORS;do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify value passed as background color.
|
|
Alain Reguera Delgado |
8f60cb |
cli_checkFiles ${BGCOLOR} --match="^[a-fA-F0-9]{6}-(0|1)$"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
for HEIGHT in $HEIGHTS;do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify value passed as height.
|
|
Alain Reguera Delgado |
8f60cb |
cli_checkFiles ${HEIGHT} --match="^[[:digit:]]+$"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Do base rendition actions.
|
|
Alain Reguera Delgado |
8f60cb |
conf_setBaseRendition
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Reset models list to prevent it from growing for each file
|
|
Alain Reguera Delgado |
8f60cb |
# name (configuration section) iteration and create this way
|
|
Alain Reguera Delgado |
8f60cb |
# unexpected images as final result.
|
|
Alain Reguera Delgado |
8f60cb |
unset MODELS
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
}
|