Blame Scripts/CentOS-Art/centos-art.sh

64b8e7
#!/bin/bash
64b8e7
#
5afc23
# centos-art.sh -- The CentOS Artwork Repository automation tool.
64b8e7
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
dcd347
#
dcd347
# This program is free software; you can redistribute it and/or modify
dcd347
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
dcd347
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
64b8e7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
64b8e7
# General Public License for more details.
64b8e7
#
64b8e7
# You should have received a copy of the GNU General Public License
64b8e7
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
64b8e7
# ----------------------------------------------------------------------
64b8e7
# $Id$
64b8e7
# ----------------------------------------------------------------------
64b8e7
5afc23
# Initialize personal data.
5afc23
declare -xr CLI_PROGRAM='centos-art'
5afc23
declare -xr CLI_PROGRAM_ID=$$
5afc23
declare -xr CLI_VERSION='1.0 (beta)'
64b8e7
5afc23
# Initialize paths.
5afc23
declare -xr CLI_WRKCOPY="${HOME}/artwork"
61a2f1
declare -xr CLI_BASEDIR="${CLI_WRKCOPY}/trunk/Scripts/CentOS-Art"
5afc23
declare -xr CLI_TEMPDIR='/tmp'
64b8e7
5afc23
# Initialize internazionalization through GNU gettext.
64b8e7
. gettext.sh
5afc23
declare -xr TEXTDOMAIN=${CLI_PROGRAM}.sh
5afc23
declare -xr TEXTDOMAINDIR=${CLI_WRKCOPY}/trunk/L10n/Scripts
64b8e7
5afc23
# Verify the working copy directory. Be sure it is
5afc23
# `/home/centos/artwork'.  Otherwise, end the script execution.  We
5afc23
# cannot continue if the working copy is stored in a place other than
5afc23
# `/home/centos/artwork'. This restriction is what let us to reuse
5afc23
# contents using absolute paths inside a distributed environment like
5afc23
# that one provided by The CentOS Artwork Repository.
5afc23
if [[ ! -d ${CLI_WRKCOPY} ]];then
5afc23
    echo "`eval_gettext "The working copy must be under \\\"\\\$CLI_WRKCOPY\\\"."`" > /dev/stderr
5afc23
    exit
5afc23
fi
5afc23
5afc23
# Initialize common functions.
64b8e7
FILES=$(ls ${CLI_BASEDIR}/Functions/{cli,cli_*}.sh)
64b8e7
for FILE in ${FILES};do
64b8e7
    if [[ -x ${FILE} ]];then
64b8e7
        . ${FILE}
64b8e7
        FUNCTION=$(grep '^function ' ${FILE} | cut -d' ' -f2)
64b8e7
        export -f ${FUNCTION}
64b8e7
    else
5afc23
        echo `eval_gettext "The \\\"\\\$FILE\\\" needs to have execution rights."` > /dev/stderr
64b8e7
        exit
64b8e7
    fi
64b8e7
done
64b8e7
5afc23
# Unset all variables not considered global in order to start common
5afc23
# functions with a clean environment.
64b8e7
unset FILE
64b8e7
unset FILES
64b8e7
unset FUNCTION
64b8e7
db22a7
# Trap signals in order to terminate the script execution correctly
db22a7
# (e.g., removing all temporal files before leaving).  Trapping the
db22a7
# exit signal seems to be enough by now, since it is always present as
db22a7
# part of the script execution flow. Each time the centos-art.sh
db22a7
# script is executed it will inevitably end with an EXIT signal at
db22a7
# some point of its execution, even if it is interrupted in the middle
db22a7
# of its execution (e.g., through `Ctrl+C').
db22a7
trap cli_terminateScriptExecution 0
2646ba
64b8e7
# Initialize command-line interface.
64b8e7
cli "$@"