|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# cli_getActions.sh -- This function loads funtionalities supported by
|
|
|
4c79b5 |
# centos-art.sh script.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# Copyright (C) 2009-2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is free software; you can redistribute it and/or modify
|
|
|
4c79b5 |
# it under the terms of the GNU General Public License as published by
|
|
|
4c79b5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
4c79b5 |
# (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c79b5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# You should have received a copy of the GNU General Public License
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function cli_getActions {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define variables as local to avoid conflicts outside.
|
|
|
4c79b5 |
local ACTIONDIR=''
|
|
|
4c79b5 |
local ACTIONFILES=''
|
|
|
4c79b5 |
local ACTIONSCRIPT=''
|
|
|
4c79b5 |
local ACTIONFUN=''
|
|
|
a23bb7 |
local REPOFUNDIR=''
|
|
|
a23bb7 |
|
|
|
a23bb7 |
# Define path to directory where actions are stored inside the
|
|
|
a23bb7 |
# repository.
|
|
|
a23bb7 |
REPOFUNDIR=/home/centos/artwork/trunk/Scripts/Bash/Functions
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define action directory.
|
|
|
a31714 |
ACTIONDIR=$(cli_getRepoName $ACTION 'd')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define action file name.
|
|
|
a23bb7 |
ACTIONSCRIPT=${REPOFUNDIR}/${ACTIONDIR}/${ACTION}.sh
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Check action existence.
|
|
|
4c79b5 |
if [[ ! -f $ACTIONSCRIPT ]];then
|
|
|
4c79b5 |
cli_printMessage "`gettext "The action provided is not valid."`"
|
|
|
1f1b3c |
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Build action-specifc script file list.
|
|
|
a23bb7 |
ACTIONFILES=$(ls ${REPOFUNDIR}/${ACTIONDIR}/${ACTION}*.sh)
|
|
|
4c79b5 |
|
|
|
4c79b5 |
for FILE in $ACTIONFILES;do
|
|
|
4c79b5 |
|
|
|
4c79b5 |
if [[ -x ${FILE} ]];then
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Initialize action-specific functions.
|
|
|
4c79b5 |
. $FILE
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Export action-specific functions to current shell script
|
|
|
4c79b5 |
# environment.
|
|
|
4c79b5 |
ACTIONFUN=$(grep '^function ' $FILE | cut -d' ' -f2)
|
|
|
4c79b5 |
export -f $ACTIONFUN
|
|
|
4c79b5 |
|
|
|
4c79b5 |
else
|
|
|
4c79b5 |
|
|
|
4c79b5 |
cli_printMessage "`eval_gettext "The \\\$FILE hasn't execution rights."`"
|
|
|
1f1b3c |
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
done
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Execute action passed to centos-art.sh script.
|
|
|
4c79b5 |
eval $ACTION
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|