Blame Scripts/centos-art.sh

64b8e7
#!/bin/bash
64b8e7
#
64b8e7
# centos-art.sh -- This file is the initialization script, the first
64b8e7
# script the centos-art command executes.
64b8e7
#
64b8e7
# Copyright (C) 2009-2011  Alain Reguera Delgado
64b8e7
# 
64b8e7
# This program is free software; you can redistribute it and/or
64b8e7
# modify it under the terms of the GNU General Public License as
64b8e7
# published by the Free Software Foundation; either version 2 of the
64b8e7
# License, or (at your option) any later version.
64b8e7
# 
64b8e7
# This program is distributed in the hope that it will be useful, but
64b8e7
# 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
64b8e7
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
64b8e7
# USA.
64b8e7
# 
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'
64b8e7
export CLI_VERSION='1.0 (beta)'
64b8e7
export CLI_BASEDIR="${HOME}/artwork/trunk/Scripts"
64b8e7
64b8e7
# Initizalize internazionalization through gettext.
64b8e7
. gettext.sh
64b8e7
export TEXTDOMAIN=${CLI_PROGRAM}.sh
64b8e7
export TEXTDOMAINDIR=${HOME}/artwork/trunk/Locales
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
64b8e7
# Initialize command-line interface.
64b8e7
cli "$@"