|
Alain Reguera Delgado |
733076 |
#!/bin/bash
|
|
Alain Reguera Delgado |
733076 |
######################################################################
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# conf.sh -- This module prepares configuration files used by both
|
|
Alain Reguera Delgado |
733076 |
# render and locale modules.
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# To build the configuration file, this module creates a list of
|
|
Alain Reguera Delgado |
733076 |
# files to process based on the arguments provided in the
|
|
Alain Reguera Delgado |
733076 |
# command-line line. With this list, then, it creates the
|
|
Alain Reguera Delgado |
733076 |
# configuration file using configuration templates for each file
|
|
Alain Reguera Delgado |
733076 |
# extension supported inside the repository.
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# The configuration file this module creates doesn't include options
|
|
Alain Reguera Delgado |
733076 |
# like brand which require information about the image you are about
|
|
Alain Reguera Delgado |
733076 |
# to produce. The intention of this module is create the
|
|
Alain Reguera Delgado |
733076 |
# configuration files you need to produce content right away in the
|
|
Alain Reguera Delgado |
733076 |
# simplest way possible and then letting you improve it as needed.
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# The name and location of the final configuration file is that
|
|
Alain Reguera Delgado |
733076 |
# passed as argument to prepare module in the command-line.
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# Written by:
|
|
Alain Reguera Delgado |
733076 |
# * Alain Reguera Delgado <al@centos.org.cu>, 2013
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# Copyright (C) 2009-2013 The CentOS Artwork SIG
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
733076 |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
733076 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
733076 |
# your option) any later version.
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
733076 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
733076 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
733076 |
# General Public License for more details.
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
733076 |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
733076 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
733076 |
#
|
|
Alain Reguera Delgado |
733076 |
######################################################################
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
function conf {
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
# Verify that a configuration file was provided as argument.
|
|
Alain Reguera Delgado |
733076 |
if [[ $# -eq 0 ]];then
|
|
Alain Reguera Delgado |
733076 |
tcar_printMessage "`gettext "The configuration file wasn't provided."`" --as-error-line
|
|
Alain Reguera Delgado |
733076 |
fi
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
# Define configuration file.
|
|
Alain Reguera Delgado |
733076 |
local CONF_FILE=$(tcar_checkRepoDirSource "${1}")
|
|
Alain Reguera Delgado |
733076 |
tcar_checkFiles -m "\.conf$" ${CONF_FILE}
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
# Define parent directory of configuration file.
|
|
Alain Reguera Delgado |
733076 |
local CONF_DIR=$(dirname ${CONF_FILE})
|
|
Alain Reguera Delgado |
733076 |
tcar_checkFiles -ed "${CONF_DIR}"
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
# Build the list of files to process. This is all the source files
|
|
Alain Reguera Delgado |
733076 |
# we want to produce th configuration file for.
|
|
Alain Reguera Delgado |
733076 |
local SOURCE_FILES=$(tcar_getFilesList ${CONF_DIR} \
|
|
Alain Reguera Delgado |
733076 |
--mindepth=1 --maxdepth=1 --type=f \
|
|
Alain Reguera Delgado |
733076 |
--pattern='.+\.(svgz|svg|asciidoc)$')
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
# Verify the list of files to process.
|
|
Alain Reguera Delgado |
733076 |
tcar_checkFiles -ef ${SOURCE_FILES}
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
# Print action message.
|
|
Alain Reguera Delgado |
733076 |
tcar_printMessage "${CONF_FILE}" --as-creating-line
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
# Process list of files.
|
|
Alain Reguera Delgado |
733076 |
for SOURCE_FILE in ${SOURCE_FILES};do
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
local CONF_FILE_NAME=$(tcar_getFileName "${SOURCE_FILE}")
|
|
Alain Reguera Delgado |
733076 |
local CONF_FILE_EXTENSION=$(tcar_getFileExtension "${SOURCE_FILE}")
|
|
Alain Reguera Delgado |
733076 |
local CONF_FILE_TEMPLATE=${TCAR_MODULE_DIR_CONFIGS}/${CONF_FILE_EXTENSION}.render.conf.tpl
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
sed -r "s/=SECTION=/${CONF_FILE_NAME}/g" ${CONF_FILE_TEMPLATE} >> ${CONF_FILE}
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
done
|
|
Alain Reguera Delgado |
733076 |
|
|
Alain Reguera Delgado |
733076 |
}
|