Blame Scripts/Functions/Tuneup/tuneup.sh

9f1608
#!/bin/bash
9f1608
#
66b51c
# tuneup.sh -- This function groups maintainance tasks which are
66b51c
# applied to files based on their extension.
9f1608
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
fa95b1
# the Free Software Foundation; either version 2 of the License, or
fa95b1
# (at your option) any later version.
fa95b1
#
9f1608
# This program is distributed in the hope that it will be useful, but
9f1608
# WITHOUT ANY WARRANTY; without even the implied warranty of
9f1608
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
9f1608
# General Public License for more details.
9f1608
#
9f1608
# You should have received a copy of the GNU General Public License
9f1608
# along with this program; if not, write to the Free Software
9f1608
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
9f1608
# USA.
9f1608
# ----------------------------------------------------------------------
9f1608
# $Id$
9f1608
# ----------------------------------------------------------------------
9f1608
66b51c
function tuneup {
9f1608
66b51c
    local ACTIONNAM=''
66b51c
    local ACTIONVAL=''
9f1608
66b51c
    # Interpret arguments and options passed through command-line.
66b51c
    tuneup_getArguments
ffdd74
66b51c
    # Redefine positional parameters using ARGUMENTS. At this point,
66b51c
    # option arguments have been removed from ARGUMENTS variable and
66b51c
    # only non-option arguments remain in it. 
1a9d63
    eval set -- "$ARGUMENTS"
1a9d63
66b51c
    # Define action name. No matter what option be passed to
66b51c
    # centos-art, there is only one action to perform (i.e., build the
66b51c
    # list of files and interpretation of file extensions for further
66b51c
    # processing).
66b51c
    ACTIONNAM="${FUNCNAME}_doBaseActions"
1a9d63
66b51c
    # Define action value. We use non-option arguments to define the
66b51c
    # action value (ACTIONVAL) variable.
66b51c
    for ACTIONVAL in "$@";do
66b51c
        
66b51c
        # Check action value. Be sure the action value matches the
66b51c
        # convenctions defined for source locations inside the working
66b51c
        # copy.
66b51c
        cli_checkRepoDirSource
1a9d63
66b51c
        # Syncronize changes between repository and working copy. At
66b51c
        # this point, changes in the repository are merged in the
66b51c
        # working copy and changes in the working copy committed up to
66b51c
        # repository.
66b51c
        cli_syncroRepoChanges
1a9d63
66b51c
        # Execute action name.
66b51c
        if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
66b51c
            eval $ACTIONNAM
66b51c
        else
66b51c
            cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
66b51c
            cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
66b51c
        fi
1a9d63
66b51c
        # Commit changes from working copy to central repository only.
66b51c
        # At this point, changes in the repository are not merged in
66b51c
        # the working copy, but chages in the working copy do are
66b51c
        # committed up to repository.
66b51c
        cli_commitRepoChanges
1a9d63
1a9d63
    done
1a9d63
9f1608
}