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

878a2b
#!/bin/bash
878a2b
#
878a2b
# tuneup_doBaseActions.sh -- This function builds one list of files to
878a2b
# process for each file extension supported and applies maintainance
878a2b
# tasks file by file for each one of them.
878a2b
#
878a2b
# Copyright (C) 2009, 2010, 2011 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function tuneup_doBaseActions {
878a2b
878a2b
    local TUNEUP_CONFIG_DIR=''
24ece8
    local TUNEUP_FORMAT_DIR=''
24ece8
    local TUNEUP_FORMAT_INIT=''
878a2b
    local TUNEUP_EXTENSION=''
878a2b
    local FILE=''
878a2b
    local FILES=''
878a2b
878a2b
    # Print separator line.
878a2b
    cli_printMessage '-' --as-separator-line
878a2b
878a2b
    # Loop through list of supported file extensions. 
878a2b
    for TUNEUP_EXTENSION in ${TUNEUP_EXTENSIONS};do
878a2b
24ece8
        # Define format name based on supported file extensions.
24ece8
        TUNEUP_FORMAT="${TUNEUP_EXTENSION}"
878a2b
24ece8
        # Define absolute path to directory where format-specific
878a2b
        # functionalities are stored in.
24ece8
        TUNEUP_FORMAT_DIR="${TUNEUP_BASEDIR}/$(cli_getRepoName \
24ece8
            ${TUNEUP_FORMAT} -d)"
878a2b
24ece8
        # Define absolute path to format initialization script.
96038f
        TUNEUP_FORMAT_INIT="${TUNEUP_FORMAT_DIR}/$(cli_getRepoName ${TUNEUP_FORMAT} -f).sh"
878a2b
24ece8
        # Verify absolute path to format initialization script.  When
24ece8
        # a file extension is provided, but no format initialization
878a2b
        # script exists for it, continue with the next file extension
878a2b
        # in the list.
24ece8
        if [[ ! -f ${TUNEUP_FORMAT_INIT} ]];then
878a2b
            continue
878a2b
        fi
878a2b
24ece8
        # Define absolute path to directory where format-specific
878a2b
        # configurations are retrived from.
24ece8
        TUNEUP_CONFIG_DIR="${TUNEUP_FORMAT_DIR}/Config"
878a2b
878a2b
        # Build list of files to process using action value as
878a2b
        # reference.
878a2b
        FILES=$(cli_getFilesList ${ACTIONVAL} --pattern="${FLAG_FILTER}\.${TUNEUP_EXTENSION}")
878a2b
878a2b
        # Verify list of files to process. Assuming no file is found,
878a2b
        # evaluate the next supported file extension.
878a2b
        if [[ $FILES == '' ]];then
878a2b
            continue
878a2b
        fi
878a2b
24ece8
        # Export format-specific functionalities up to the
878a2b
        # execution environment.
878a2b
        cli_exportFunctions "${TUNEUP_BASEDIR}/$(cli_getRepoName \
24ece8
            ${TUNEUP_FORMAT} -d)" "${TUNEUP_FORMAT}"
878a2b
24ece8
        # Execute format-specific maintainance tasks.
878a2b
        for FILE in $FILES;do
878a2b
            cli_printMessage "$FILE" --as-tuningup-line
24ece8
            ${TUNEUP_FORMAT}
878a2b
        done
878a2b
24ece8
        # Unset format-specific functionalities from execution
878a2b
        # environment.  This is required to prevent end up with more
24ece8
        # than one format-specifc function initialization, in those
878a2b
        # cases when different template files are rendered in just one
878a2b
        # execution of `centos-art.sh' script.
878a2b
        cli_unsetFunctions "${TUNEUP_BASEDIR}/$(cli_getRepoName \
24ece8
            ${TUNEUP_FORMAT} -d)" "${TUNEUP_FORMAT}"
878a2b
878a2b
    done
878a2b
878a2b
}