Blame Automation/Bash/Functions/Tuneup/tuneup_doBaseActions.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# tuneup_doBaseActions.sh -- This function builds one list of files to
Alain Reguera Delgado 8f60cb
# process for each file extension supported and applies maintainance
Alain Reguera Delgado 8f60cb
# tasks file by file for each one of them.
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 tuneup_doBaseActions {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    local TUNEUP_CONFIG_DIR=''
Alain Reguera Delgado 8f60cb
    local TUNEUP_FORMAT_DIR=''
Alain Reguera Delgado 8f60cb
    local TUNEUP_FORMAT_INIT=''
Alain Reguera Delgado 8f60cb
    local TUNEUP_EXTENSION=''
Alain Reguera Delgado 8f60cb
    local EXPORTID=''
Alain Reguera Delgado 8f60cb
    local FILE=''
Alain Reguera Delgado 8f60cb
    local FILES=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Print separator line.
Alain Reguera Delgado 8f60cb
    cli_printMessage '-' --as-separator-line
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Loop through list of supported file extensions. 
Alain Reguera Delgado 8f60cb
    for TUNEUP_EXTENSION in ${TUNEUP_EXTENSIONS};do
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Define format name based on supported file extensions.
Alain Reguera Delgado 8f60cb
        TUNEUP_FORMAT="${TUNEUP_EXTENSION}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Define specific functions export id.
Alain Reguera Delgado 8f60cb
        EXPORTID="${CLI_FUNCDIRNAM}/$(cli_getRepoName ${TUNEUP_FORMAT} -d)/${TUNEUP_FORMAT}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Define absolute path to directory where format-specific
Alain Reguera Delgado 8f60cb
        # functionalities are stored in.
Alain Reguera Delgado 8f60cb
        TUNEUP_FORMAT_DIR="${TUNEUP_BASEDIR}/$(cli_getRepoName \
Alain Reguera Delgado 8f60cb
            ${TUNEUP_FORMAT} -d)"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Define absolute path to format initialization script.
Alain Reguera Delgado 8f60cb
        TUNEUP_FORMAT_INIT="${TUNEUP_FORMAT_DIR}/$(cli_getRepoName ${TUNEUP_FORMAT} -f).sh"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Verify absolute path to format initialization script.  When
Alain Reguera Delgado 8f60cb
        # a file extension is provided, but no format initialization
Alain Reguera Delgado 8f60cb
        # script exists for it, continue with the next file extension
Alain Reguera Delgado 8f60cb
        # in the list.
Alain Reguera Delgado 8f60cb
        if [[ ! -f ${TUNEUP_FORMAT_INIT} ]];then
Alain Reguera Delgado 8f60cb
            continue
Alain Reguera Delgado 8f60cb
        fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Define absolute path to directory where format-specific
Alain Reguera Delgado 8f60cb
        # configurations are retrieved from.
Alain Reguera Delgado 8f60cb
        TUNEUP_CONFIG_DIR="${TUNEUP_FORMAT_DIR}/Config"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Build list of files to process using action value as
Alain Reguera Delgado 8f60cb
        # reference.
Alain Reguera Delgado 8f60cb
        FILES=$(cli_getFilesList ${ACTIONVAL} --pattern="^.*${FLAG_FILTER}\.${TUNEUP_EXTENSION}$")
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Verify list of files to process. Assuming no file is found,
Alain Reguera Delgado 8f60cb
        # evaluate the next supported file extension.
Alain Reguera Delgado 8f60cb
        if [[ $FILES == '' ]];then
Alain Reguera Delgado 8f60cb
            continue
Alain Reguera Delgado 8f60cb
        fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Export format-specific functionalities up to the
Alain Reguera Delgado 8f60cb
        # execution environment.
Alain Reguera Delgado 8f60cb
        cli_exportFunctions "${EXPORTID}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Execute format-specific maintenance tasks.
Alain Reguera Delgado 8f60cb
        for FILE in $FILES;do
Alain Reguera Delgado 8f60cb
            cli_printMessage "$FILE" --as-tuningup-line
Alain Reguera Delgado 8f60cb
            ${TUNEUP_FORMAT}
Alain Reguera Delgado 8f60cb
        done
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Unset format-specific functionalities from execution
Alain Reguera Delgado 8f60cb
        # environment.  This is required to prevent end up with more
Alain Reguera Delgado 8f60cb
        # than one format-specific function initialization, in those
Alain Reguera Delgado 8f60cb
        # cases when different template files are rendered in just one
Alain Reguera Delgado 8f60cb
        # execution of `centos-art.sh' script.
Alain Reguera Delgado 8f60cb
        cli_unsetFunctions "${EXPORTID}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    done
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}