|
|
64b8e7 |
#!/bin/bash
|
|
|
64b8e7 |
#
|
|
|
64b8e7 |
# centos-art.sh -- This file is the initialization script, the first
|
|
|
64b8e7 |
# script the centos-art command executes.
|
|
|
64b8e7 |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
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 |
|
|
|
64b8e7 |
# Most paths are built from HOME variable on, so we need to make our
|
|
|
64b8e7 |
# best to make it contain a valid value before any path be built from
|
|
|
64b8e7 |
# it. Using HOME variable gives us some flexibility to store the
|
|
|
64b8e7 |
# repository filesystem in a location different from `/home/centos',
|
|
|
64b8e7 |
# the default home directory centos-art assumes if HOME variable is
|
|
|
64b8e7 |
# empty or malformed.
|
|
|
64b8e7 |
[[ ! $HOME =~ '^/home/[[:alnum:]]+' ]] && HOME='/home/centos'
|
|
|
64b8e7 |
|
|
|
64b8e7 |
# Initialize personal information.
|
|
|
64b8e7 |
export CLI_PROGRAM='centos-art'
|
|
|
2646ba |
export CLI_PROGRAM_ID=$$
|
|
|
64b8e7 |
export CLI_VERSION='1.0 (beta)'
|
|
|
64b8e7 |
export CLI_BASEDIR="${HOME}/artwork/trunk/Scripts"
|
|
|
2646ba |
export CLI_TEMPDIR='/tmp'
|
|
|
64b8e7 |
|
|
|
64b8e7 |
# Initizalize internazionalization through gettext.
|
|
|
64b8e7 |
. gettext.sh
|
|
|
64b8e7 |
export TEXTDOMAIN=${CLI_PROGRAM}.sh
|
|
|
9de418 |
export TEXTDOMAINDIR=${HOME}/artwork/trunk/Locales/Scripts
|
|
|
64b8e7 |
|
|
|
64b8e7 |
# Initialize common function scripts.
|
|
|
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
|
|
|
64b8e7 |
echo `gettext "The ${FILE} needs to have execution rights."` > /dev/stderr
|
|
|
64b8e7 |
exit
|
|
|
64b8e7 |
fi
|
|
|
64b8e7 |
done
|
|
|
64b8e7 |
|
|
|
64b8e7 |
# Unset all variables not considered global in order to start cli
|
|
|
64b8e7 |
# execution 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 "$@"
|