|
|
64b8e7 |
#!/bin/bash
|
|
|
64b8e7 |
#
|
|
|
64b8e7 |
|
|
|
64b8e7 |
# script the centos-art command executes.
|
|
|
64b8e7 |
#
|
|
|
2d3646 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
dcd347 |
#
|
|
|
dcd347 |
# This program is free software; you can redistribute it and/or modify
|
|
|
dcd347 |
|
|
|
dcd347 |
|
|
|
dcd347 |
|
|
|
dcd347 |
#
|
|
|
74a058 |
|
|
|
74a058 |
|
|
|
64b8e7 |
|
|
|
64b8e7 |
# General Public License for more details.
|
|
|
64b8e7 |
#
|
|
|
64b8e7 |
|
|
|
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 |
|
|
|
64b8e7 |
|
|
|
64b8e7 |
|
|
|
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 |
|
|
|
64b8e7 |
unset FILE
|
|
|
64b8e7 |
unset FILES
|
|
|
64b8e7 |
unset FUNCTION
|
|
|
64b8e7 |
|
|
|
db22a7 |
# Trap signals in order to terminate the script execution correctly
|
|
|
db22a7 |
|
|
|
db22a7 |
# exit signal seems to be enough by now, since it is always present as
|
|
|
db22a7 |
|
|
|
db22a7 |
|
|
|
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 "$@"
|