Blame Scripts/Bash/Cli/init.sh

4c79b5
#!/bin/bash
4c79b5
#
7b46a4
# init.sh -- This file is the centos-art initialization script, the
7b46a4
# first script the centos-art command executes.
4c79b5
#
72c8a5
# Copyright (C) 2009-2011  Alain Reguera Delgado
4c79b5
# 
72c8a5
# This program is free software; you can redistribute it and/or
72c8a5
# modify it under the terms of the GNU General Public License as
72c8a5
# published by the Free Software Foundation; either version 2 of the
72c8a5
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
7b46a4
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
7b46a4
# Most paths are built from HOME variable on, so we need to make our
7b46a4
# best to make it contain a valid value before any path be built from
7b46a4
# it. Using HOME variable gives us some flexibility to store the
7b46a4
# repository filesystem in a location different from `/home/centos',
7b46a4
# the default home directory centos-art assumes if HOME variable is
7b46a4
# empty or malformed.
7b46a4
[[ ! $HOME =~ '^/home/[[:alnum:]]+' ]] && HOME='/home/centos'
7b46a4
7b46a4
# Initialize personal information.
7b46a4
export CLI_PROGRAM='centos-art'
7b46a4
export CLI_VERSION='1.0 (beta)'
1dbe14
export CLI_BASEDIR="${HOME}/artwork/trunk/Scripts/Bash/Cli"
03faa2
e67b3a
# Initizalize internazionalization through gettext.
e67b3a
. gettext.sh
e67b3a
export TEXTDOMAIN=${CLI_PROGRAM}.sh
e67b3a
export TEXTDOMAINDIR=${HOME}/artwork/trunk/Locales/Scripts/Bash
e67b3a
7b46a4
# Initialize common function scripts.
7b46a4
FILES=$(ls ${CLI_BASEDIR}/Functions/{cli,cli_*}.sh)
7b46a4
for FILE in ${FILES};do
7b46a4
    if [[ -x ${FILE} ]];then
7b46a4
        . ${FILE}
7b46a4
        FUNCTION=$(grep '^function ' ${FILE} | cut -d' ' -f2)
7b46a4
        export -f ${FUNCTION}
03faa2
    else
7b46a4
        echo `gettext "The ${FILE} needs to have execution rights."` > /dev/stderr
03faa2
        exit
03faa2
    fi
03faa2
done
03faa2
03faa2
# Unset all variables not considered global in order to start cli
03faa2
# execution with a clean environment.
03faa2
unset FILE
03faa2
unset FILES
03faa2
unset FUNCTION
4c79b5
7b46a4
# Initialize command-line interface.
4c79b5
cli "$@"