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=''
878a2b
    local TUNEUP_BACKEND_DIR=''
878a2b
    local TUNEUP_BACKEND_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
878a2b
        # Define backend name based on supported file extensions.
878a2b
        TUNEUP_BACKEND="${TUNEUP_EXTENSION}"
878a2b
878a2b
        # Define absolute path to directory where backend-specific
878a2b
        # functionalities are stored in.
878a2b
        TUNEUP_BACKEND_DIR="${TUNEUP_BASEDIR}/$(cli_getRepoName \
878a2b
            ${TUNEUP_BACKEND} -d)"
878a2b
878a2b
        # Define absolute path to backend initialization script.
878a2b
        TUNEUP_BACKEND_INIT="${TUNEUP_BACKEND_DIR}/$(cli_getRepoName ${TUNEUP_BACKEND} -f)"
878a2b
878a2b
        # Verify absolute path to backend initialization script.  When
878a2b
        # a file extension is provided, but no backend initialization
878a2b
        # script exists for it, continue with the next file extension
878a2b
        # in the list.
878a2b
        if [[ ! -f ${TUNEUP_BACKEND_INIT} ]];then
878a2b
            continue
878a2b
        fi
878a2b
878a2b
        # Define absolute path to directory where backend-specific
878a2b
        # configurations are retrived from.
878a2b
        TUNEUP_CONFIG_DIR="${TUNEUP_BACKEND_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
878a2b
        # Export backend-specific functionalities up to the
878a2b
        # execution environment.
878a2b
        cli_exportFunctions "${TUNEUP_BASEDIR}/$(cli_getRepoName \
878a2b
            ${TUNEUP_BACKEND} -d)" "${TUNEUP_BACKEND}"
878a2b
878a2b
        # Execute backend-specific maintainance tasks.
878a2b
        for FILE in $FILES;do
878a2b
            cli_printMessage "$FILE" --as-tuningup-line
878a2b
            ${TUNEUP_BACKEND}
878a2b
        done
878a2b
878a2b
        # Unset backend-specific functionalities from execution
878a2b
        # environment.  This is required to prevent end up with more
878a2b
        # than one backend-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 \
878a2b
            ${TUNEUP_BACKEND} -d)" "${TUNEUP_BACKEND}"
878a2b
878a2b
    done
878a2b
878a2b
}