Blame Scripts/Bash/centos-art.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# centos-art.sh -- The CentOS Artwork Repository automation tool.
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
# Initialize personal data.
878a2b
declare -xr CLI_PROGRAM='centos-art'
878a2b
declare -xr CLI_PROGRAM_ID=$$
878a2b
declare -xr CLI_VERSION='1.0 (beta)'
878a2b
878a2b
# Initialize paths.
878a2b
declare -xr CLI_WRKCOPY="${HOME}/artwork"
947cfd
declare -xr CLI_BASEDIR="${CLI_WRKCOPY}/trunk/Scripts/Bash"
878a2b
declare -xr CLI_TEMPDIR='/tmp'
878a2b
878a2b
# Initialize internazionalization through GNU gettext.
878a2b
. gettext.sh
878a2b
declare -xr TEXTDOMAIN=${CLI_PROGRAM}.sh
878a2b
declare -xr TEXTDOMAINDIR=${CLI_WRKCOPY}/branches/L10n/Scripts/Bash
878a2b
878a2b
# Verify the working copy directory. Be sure it is
878a2b
# `/home/centos/artwork'.  Otherwise, end the script execution.  We
878a2b
# cannot continue if the working copy is stored in a place other than
878a2b
# `/home/centos/artwork'. This restriction is what let us to reuse
878a2b
# contents using absolute paths inside a distributed environment like
878a2b
# that one provided by The CentOS Artwork Repository.
878a2b
if [[ ! -d ${CLI_WRKCOPY} ]];then
878a2b
    echo "`eval_gettext "The working copy must be under \\\"\\\$CLI_WRKCOPY\\\"."`" > /dev/stderr
878a2b
    exit
878a2b
fi
878a2b
878a2b
# Initialize common functions.
878a2b
FILES=$(ls ${CLI_BASEDIR}/Functions/{cli,cli_*}.sh)
878a2b
for FILE in ${FILES};do
878a2b
    if [[ -x ${FILE} ]];then
878a2b
        . ${FILE}
878a2b
        FUNCTION=$(grep '^function ' ${FILE} | cut -d' ' -f2)
878a2b
        export -f ${FUNCTION}
878a2b
    else
878a2b
        echo `eval_gettext "The \\\"\\\$FILE\\\" needs to have execution rights."` > /dev/stderr
878a2b
        exit
878a2b
    fi
878a2b
done
878a2b
878a2b
# Unset all variables not considered global in order to start common
878a2b
# functions with a clean environment.
878a2b
unset FILE
878a2b
unset FILES
878a2b
unset FUNCTION
878a2b
878a2b
# Trap signals in order to terminate the script execution correctly
878a2b
# (e.g., removing all temporal files before leaving).  Trapping the
878a2b
# exit signal seems to be enough by now, since it is always present as
878a2b
# part of the script execution flow. Each time the centos-art.sh
878a2b
# script is executed it will inevitably end with an EXIT signal at
878a2b
# some point of its execution, even if it is interrupted in the middle
878a2b
# of its execution (e.g., through `Ctrl+C').
878a2b
trap cli_terminateScriptExecution 0
878a2b
878a2b
# Initialize command-line interface.
878a2b
cli "$@"