From 3b853ab6e1c3b2c54b8571a6cad3b9af04de4d77 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 23 2010 13:54:22 +0000 Subject: Update 'prepare' action for centos-art.sh script. --- diff --git a/Scripts/Bash/Functions/Prepare/prepare.sh b/Scripts/Bash/Functions/Prepare/prepare.sh index d561f87..7503967 100755 --- a/Scripts/Bash/Functions/Prepare/prepare.sh +++ b/Scripts/Bash/Functions/Prepare/prepare.sh @@ -21,18 +21,14 @@ # USA. # # ---------------------------------------------------------------------- -# $Id: prepare.sh 62 2010-09-17 12:18:21Z al $ +# $Id$ # ---------------------------------------------------------------------- function prepare { - # Check paths. - prepare_forUsingPaths + # Define prepare variables. - # Check packages. - prepare_forUsingPackages - - # Output successful message. - cli_printMessage "`gettext "Your workstation is ready for using centos-art.sh script."`" "AsHeadingLine" + # Define prepare actions. + prepare_getActions } diff --git a/Scripts/Bash/Functions/Prepare/prepare_forUsingCli.sh b/Scripts/Bash/Functions/Prepare/prepare_forUsingCli.sh new file mode 100755 index 0000000..f27f4c0 --- /dev/null +++ b/Scripts/Bash/Functions/Prepare/prepare_forUsingCli.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# prepare_forUsingCli.sh -- This function +# +# Copyright (C) 2009-2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_forUsingCli { + + # Define variables as local to avoid conflicts outside. + local -a REPODIRS + local -a REPOFILES + local -a REPOLINKS + + # Define directories required by the centos-art.sh script command + # line interface. + REPODIRS[0]=/home/centos + REPODIRS[1]=/home/centos/bin + REPODIRS[2]=/home/centos/artwork/trunk/Scripts/Bash + + # Define files required by the centos-art.sh script command line + # interface. + REPOFILES=${REPODIRS[2]}/centos-art.sh + + # Define symbolic links required by the centos-art.sh script + # command line interface. + REPOLINKS=${REPODIRS[1]}/centos-art + + # Check defined directories, files, and symbolic links. + cli_checkFiles ${REPOFILES[@]} 'f' + cli_checkFiles ${REPOLINKS[@]} 'h' + +} diff --git a/Scripts/Bash/Functions/Prepare/prepare_forUsingFonts.sh b/Scripts/Bash/Functions/Prepare/prepare_forUsingFonts.sh new file mode 100644 index 0000000..7fef458 --- /dev/null +++ b/Scripts/Bash/Functions/Prepare/prepare_forUsingFonts.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# +# prepare_forUsingFonts.sh -- This function checks user's fonts +# directory. In order for some artworks to be rendered correctly, +# denmark font needs to be available. By default, denmark font doesn't +# come with CentOS distribution so create a symbolic link (from the +# one we have inside repository) to make it available if it isn't yet. +# +# Copyright (C) 2009-2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_forUsingFonts { + + # Define variables as local to avoid conflicts outside. + local -a REPODIRS + local -a REPOFILES + local -a REPOLINKS + + # Define font related directories. + REPODIRS[0]=/home/centos/.fonts + REPODIRS[1]=/home/centos/artwork/trunk/Identity/Fonts/Ttf + + # Define font related files. + REPOFILES=${REPODIRS[0]}/denmark.ttf + + # Define font related symbolic links. + REPOLINKS=${REPODIRS[1]}/denmark.ttf + + # Check defined directories, files, and symbolic links. + cli_checkFiles "${REPODIRS[@]}" + cli_checkFiles "${REPOFILES[@]}" + cli_checkFiles "${REPOLINKS[@]}" + +} diff --git a/Scripts/Bash/Functions/Prepare/prepare_forUsingInkscape.sh b/Scripts/Bash/Functions/Prepare/prepare_forUsingInkscape.sh new file mode 100755 index 0000000..4ea3f5e --- /dev/null +++ b/Scripts/Bash/Functions/Prepare/prepare_forUsingInkscape.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# +# prepare_forUsingInkscape.sh -- This function prepares user's +# ~/.inkscape configurations directory to use CentOS defaults (e.g., +# palettes, patterns, etc). +# +# Copyright (C) 2009-2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_forUsingInkscape { + + # Define variables as local to avoid conflicts outside. + local -a REPODIRS + local -a REPOFILES + local -a REPOLINKS + + # Define directories required by the centos-art.sh script command + # line interface. + REPODIRS[0]=/home/centos/.inkscape/palettes + REPODIRS[1]=/home/centos/artwork/trunk/Identity/Colors + + # Define files required by the centos-art.sh script command line + # interface. + REPOFILES=${REPODIRS[1]}/CentOS.gpl + + # Define symbolic links required by the centos-art.sh script + # command line interface. + REPOLINKS=${REPODIRS[0]}/CentOS.gpl + + # Check defined directories, files, and symbolic links. + cli_checkFiles "${REPODIRS[@]}" + cli_checkFiles "${REPOFILES[@]}" + cli_checkFiles "${REPOLINKS[@]}" + +} diff --git a/Scripts/Bash/Functions/Prepare/prepare_forUsingPackages.sh b/Scripts/Bash/Functions/Prepare/prepare_forUsingPackages.sh index 46b8af5..4e8feaf 100644 --- a/Scripts/Bash/Functions/Prepare/prepare_forUsingPackages.sh +++ b/Scripts/Bash/Functions/Prepare/prepare_forUsingPackages.sh @@ -23,100 +23,39 @@ # USA. # # ---------------------------------------------------------------------- -# $Id: prepare_forUsingPackages.sh 65 2010-09-18 03:18:50Z al $ +# $Id$ # ---------------------------------------------------------------------- function prepare_forUsingPackages { - # Output action message. - cli_printMessage "`gettext "Packages"`" "AsHeadingLine" - # Define variables as local to avoid conflicts outside. local PACKAGE='' local PACKAGES='' - local PACKAGES_FROM_THIRDS='' - local MISSING_PACKAGES='' - local MISSING_PACKAGES_COUNTER=0 - local MISSING_PACKAGES_REPORT='' - local MISSING_PACKAGES_FROM_THIRDS='' - local MISSING_PACKAGES_FROM_THIRDS_COUNTER=0 + local PACKAGE_INFO='' # Define required packages needed by centos-art.sh script. PACKAGES="bash inkscape ImageMagick netpbm netpbm-progs syslinux gimp coreutils texinfo info tetex-latex tetex-fonts - tetex-doc tetex-xdvi tetex-dvips gettext sudo yum texi2html" + tetex-doc tetex-xdvi tetex-dvips gettext texi2html" # Define, from required packages, packages being from third # parties (i.e., packages not included in rhel, nor centos [base] # repository.). PACKAGES_FROM_THIRDS="(inkscape|blender)" - # Query RPM's database looking for required packages and build - # list of missing packages. + # Output table of packages needed by centos-art.sh script. for PACKAGE in $PACKAGES;do - rpm -q "$PACKAGE" >> /dev/null - if [[ $? -gt 0 ]];then - MISSING_PACKAGES="$PACKAGE $MISSING_PACKAGES" - MISSING_PACKAGES_COUNTER=$(($MISSING_PACKAGES_COUNTER + 1)) - if [[ $PACKAGE =~ $PACKAGES_FROM_THIRDS ]];then - MISSING_PACKAGES_FROM_THIRDS="$PACKAGE $MISSING_PACKAGES_FROM_THIRDS" - MISSING_PACKAGES_FROM_THIRDS_COUNTER=$(($MISSING_PACKAGES_FROM_THIRDS_COUNTER + 1)) - fi - fi - done - - # Check required packages. - if [[ $MISSING_PACKAGES_COUNTER -gt 0 ]];then - - cli_printMessage "`ngettext "The following package needs to be installed:"\ - "The following packages need to be installed:"\ - $MISSING_PACKAGES_COUNTER`" - for PACKAGE in $MISSING_PACKAGES;do - cli_printMessage $PACKAGE "AsResponseLine" - done - cli_printMessage "`gettext "Do you want to install the packages now?"`" "AsYesOrNoRequestLine" - - # Before installing packages, output a warning about - # centos-art.sh required packages being from third parties (if - # any). - if [[ $MISSING_PACKAGES_FROM_THIRDS_COUNTER -gt 0 ]];then - - # Give format to missing packages from third parties. - MISSING_PACKAGES_FROM_THIRDS=$(echo $MISSING_PACKAGES_FROM_THIRDS \ - | sed -r -e 's![[:space:]]+$!!' -e 's![[:space:]]+!, !g') - - cli_printMessage "`eval_ngettext \ - "The package \\\"\\\$MISSING_PACKAGES_FROM_THIRDS\\\" is not part of CentOS distribution. In order to install this package, you need to install third party repositories first. For more information about installing third party repositories on CentOS distribution, see the url: http://wiki.centos.org/AdditionalResourses/Repositories."\ - "The packages \\\"\\\$MISSING_PACKAGES_FROM_THIRDS\\\" are not part of CentOS distribution. In order to install these packages, you need to install third party repositories first. For more information about installing third party repositories on CentOS distribution, see the url: http://wiki.centos.org/AdditionalResourses/Repositories." $MISSING_PACKAGES_FROM_THIRDS_COUNTER`" "AsWarningLine" - - cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine" - - fi - - # Use sudo to install packages. By default user names - # need to be set inside sudoers configuration file - # (/etc/sudoers) in order to perform sudo commands. - sudo yum install $MISSING_PACKAGES - - # Re-check packages. This is needed for those situations where - # the user chooses not to install the required packages when - # yum request for confirmation. If we don't re-check install - # package the successful message is display after answering - # negatively to yum's confirmation message. Additionally, it - # helps to let the user know that third party packages are - # still missing when third party repositories are not - # installed inside CentOS distribution. - for PACKAGE in $PACKAGES;do - rpm -q "$PACKAGE" >> /dev/null - if [[ $? -gt 0 ]];then - prepare_forUsingPackages - fi - done - - else - - cli_printMessage "`gettext "The packages required by centos-art.sh script are already installed."`" - - fi - + PACKAGE_INFO=$(rpm -q --queryformat "%{SUMMARY}" $PACKAGE \ + | tr "\n" ' ' | sed -r 's!^([[:alpha:]])!\u\1!' ) + cli_printMessage "$PACKAGE | $PACKAGE_INFO" + done \ + | egrep -i $REGEX \ + | awk 'BEGIN {FS="|"; format ="%15s|%s\n" + printf "--------------------------------------------------------------------------------\n" + printf format, "'`gettext "Package"`' ", " '`gettext "Description"`'" + printf "--------------------------------------------------------------------------------\n"} + {printf format, substr($1,0,15), $2} + END {printf "--------------------------------------------------------------------------------\n"}' + + cli_printMessage "$(caller)" "AsToKnowMoreLine" } diff --git a/Scripts/Bash/Functions/Prepare/prepare_forUsingPaths.sh b/Scripts/Bash/Functions/Prepare/prepare_forUsingPaths.sh index 0d9f093..961ecb6 100644 --- a/Scripts/Bash/Functions/Prepare/prepare_forUsingPaths.sh +++ b/Scripts/Bash/Functions/Prepare/prepare_forUsingPaths.sh @@ -22,82 +22,16 @@ # USA. # # ---------------------------------------------------------------------- -# $Id: prepare_forUsingPaths.sh 98 2010-09-19 16:01:53Z al $ +# $Id$ # ---------------------------------------------------------------------- function prepare_forUsingPaths { # Output action message. - cli_printMessage "`gettext "Directories and files"`" "AsHeadingLine" + cli_printMessage "`gettext "Checking paths"`" - # Define variables as local to avoid conflicts outside. - local DIRECTORY='' - - # Check centos user's home directory. - cli_printMessage "${REPO_PATHS[0]}" "AsResponseLine" - if [[ ! -d ${REPO_PATHS[0]} ]];then - cli_printMessage "`gettext "The following directory doesn't exist:"`" - cli_printMessage "${REPO_PATHS[0]}" "AsResponseLine" - cli_printMessage "`gettext "Do you want to create the directory now?"`" "AsYesOrNoRequestLine" - eval sudo useradd centos - eval sudo passwd centos - fi - - # Check centos user's bin directory. - cli_printMessage "${REPO_PATHS[1]}" "AsResponseLine" - if [[ ! -d ${REPO_PATHS[1]} ]];then - cli_printMessage "`gettext "The following directory doesn't exist:"`" - cli_printMessage "${REPO_PATHS[1]}" "AsResponseLine" - cli_printMessage "`gettext "Do you want to create the directory now?"`" "AsYesOrNoRequestLine" - eval mkdir ${REPO_PATHS[1]} - fi - - # Check centos-art.sh invocation link. - cli_printMessage "${REPO_PATHS[2]}" "AsResponseLine" - if [[ ! -h ${REPO_PATHS[2]} ]];then - cli_printMessage "`gettext "The following symbolic link doesn't exist:"`" - cli_printMessage "${REPO_PATHS[2]}" "AsResponseLine" - cli_printMessage "`gettext "Do you want to create the link now?"`" "AsYesOrNoRequestLine" - - # Check centos-art.sh script file before creating its - # invocation link. - cli_printMessage "${REPO_PATHS[3]}" "AsResponseLine" - if [[ -f ${REPO_PATHS[3]} ]];then - eval ln -fs ${REPO_PATHS[3]} ${REPO_PATHS[2]} - else - cli_printMessage "`gettext "The following file doesn't exist:"`" - cli_printMessage "${REPO_PATHS[3]}" "AsResponseLine" - cli_printMessage "trunk/Scripts/Bash/Functions/Prepare --filter='prepare_forUsingPaths.sh" "AsToKnowMoreLine" - fi - fi - - # Check user's fonts directory. In order for some artworks to be - # rendered correctly, denmark font needs to be available. By - # default, denmark font doesn't come with CentOS distribution so - # create a symbolic link (from the one we have inside repository) - # to make it available if it isn't yet. - if [[ ! -d ${REPO_PATHS[6]} ]];then - cli_printMessage "`gettext "The following directory doesn't exist:"`" - cli_printMessage "${REPO_PATHS[6]}" "AsResponseLine" - cli_printMessage "`gettext "Do you want to create the directory now?"`" "AsYesOrNoRequestLine" - mkdir ${REPO_PATHS[6]} - fi - if [[ ! -f ${REPO_PATHS[6]}/denmark.ttf ]];then - if [[ ! -h ${REPO_PATHS[6]}/denmark.ttf ]];then - cli_printMessage "`gettext "The following file doesn't exist:"`" - cli_printMessage "${REPO_PATHS[6]}/denmark.ttf" "AsResponseLine" - cli_printMessage "`gettext "Do you want to create the link now?"`" "AsYesOrNoRequestLine" - ln -sf ${REPO_PATHS[7]}/denmark.ttf ${REPO_PATHS[6]}/denmark.ttf - fi - fi - - cli_printMessage "`gettext "Permissions"`" "AsHeadingLine" - - # Reset script files permissions. This is to be sure script files - # are using the correct file permissions. Otherwise some script - # may not be loaded. - cli_printMessage "${REPO_PATHS[4]}" "AsResponseLine" - eval "chmod -R 755 ${REPO_PATHS[4]}" - eval "chown -R $USER:$USER ${REPO_PATHS[4]}" + prepare_forUsingCli + prepare_forUsingFonts + prepare_forUsingInkscape } diff --git a/Scripts/Bash/Functions/Prepare/prepare_getActions.sh b/Scripts/Bash/Functions/Prepare/prepare_getActions.sh new file mode 100755 index 0000000..f2aa680 --- /dev/null +++ b/Scripts/Bash/Functions/Prepare/prepare_getActions.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# +# prepare_getActions.sh -- This function defines prepare actions. +# +# Copyright (C) 2009-2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function prepare_getActions { + + case $OPTIONNAM in + + --packages ) + prepare_forUsingPackages + ;; + + --paths ) + prepare_forUsingPaths + ;; + + * ) + cli_printMessage "`gettext "The option provided is not valid."`" + + esac + + cli_printMessage "$(caller)" "AsToKnowMoreLine" + +} +