|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
23c7a5 |
# cli_checkActionArguments.sh -- This function provides input
|
|
|
23c7a5 |
# validation for action value (ACTIONVAL) variable.
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
|
|
|
7cd8e9 |
|
|
|
7cd8e9 |
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
|
|
|
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 |
|
|
|
23c7a5 |
function cli_checkActionArguments {
|
|
|
4c79b5 |
|
|
|
a58b61 |
|
|
|
a58b61 |
if [[ $ACTIONVAL =~ '(\.\.(/)?)' ]];then
|
|
|
a58b61 |
cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine'
|
|
|
1f1b3c |
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
|
|
4c79b5 |
fi
|
|
|
a58b61 |
if [[ ! $ACTIONVAL =~ '^[A-Za-z0-9\.:/-]+$' ]];then
|
|
|
a58b61 |
cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine'
|
|
|
1f1b3c |
cli_printMessage "$(caller)" "AsToKnowMoreLine"
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
a58b61 |
# Re-define action value to build repository absolute path from
|
|
|
a58b61 |
|
|
|
a58b61 |
# /home/centos/artwork/ from all centos-art.sh output (in order to
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
if [[ $ACTIONVAL =~ '^(trunk|branches|tags)' ]];then
|
|
|
a58b61 |
ACTIONVAL=/home/centos/artwork/$ACTIONVAL
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
a58b61 |
# Re-define action value to build repository absolute path from
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
if [[ -d ${ACTIONVAL} ]];then
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
a58b61 |
pushd "$ACTIONVAL" > /dev/null
|
|
|
4c79b5 |
|
|
|
a58b61 |
|
|
|
23c7a5 |
if [[ $(pwd) =~ '^/home/centos/artwork' ]];then
|
|
|
a58b61 |
# Re-define action value using absolute path.
|
|
|
a58b61 |
ACTIONVAL=$(pwd)
|
|
|
a58b61 |
else
|
|
|
a58b61 |
cli_printMessage "`gettext "The location provided is not valid."`" 'AsErrorLine'
|
|
|
02e00f |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
a58b61 |
fi
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
popd > /dev/null
|
|
|
a58b61 |
|
|
|
a58b61 |
elif [[ -f ${ACTIONVAL} ]];then
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
pushd "$(dirname $ACTIONVAL)" > /dev/null
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
23c7a5 |
if [[ $(pwd) =~ '^/home/centos/artwork' ]];then
|
|
|
a58b61 |
# Re-define action value using absolute path.
|
|
|
a58b61 |
ACTIONVAL=$(pwd)/$(basename $ACTIONVAL)
|
|
|
a58b61 |
else
|
|
|
a58b61 |
cli_printMessage "`gettext "The location provided is not valid."`" 'AsErrorLine'
|
|
|
02e00f |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
a58b61 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
popd > /dev/null
|
|
|
4c79b5 |
|
|
|
4c79b5 |
else
|
|
|
a58b61 |
|
|
|
a58b61 |
|
|
|
a58b61 |
if [[ ! $ACTIONVAL =~ '^(https|http)://projects.centos.org/svn/artwork/.+$' ]];then
|
|
|
a58b61 |
cli_printMessage "`gettext "The location provided is not valid."`" 'AsErrorLine'
|
|
|
02e00f |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
a58b61 |
fi
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|