diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify.sh b/Scripts/Bash/Cli/Functions/Prepare/verify.sh new file mode 100755 index 0000000..0265eae --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# verify.sh -- This function verifies your workstation for using +# centos-art.sh script. +# +# Copyright (C) 2009-2011 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 verify { + + # Define command-line interface. + verify_getActions + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doEnvironment.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doEnvironment.sh new file mode 100755 index 0000000..10eddd5 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doEnvironment.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# +# verify_doEnvironment.sh -- This function outputs a brief description +# of environment variables used by `centos-art.sh' script. +# +# Copyright (C) 2009-2011 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 verify_doEnvironment { + + local -a VARS + local -a INFO + local COUNT=0 + + # Define name of environment variables used by centos-art.sh + # script. + VARS[0]='EDITOR' + VARS[1]='TZ' + VARS[2]='TEXTDOMAIN' + VARS[3]='TEXTDOMAINDIR' + VARS[4]='LANG' + + # Define description of environment variables. + INFO[0]="`gettext "Default text editor"`" + INFO[1]="`gettext "Default time zone representation"`" + INFO[2]="`gettext "Default domain used to retrieve translated messages"`" + INFO[3]="`gettext "Default directory used to retrive translated messages"`" + INFO[4]="`gettext "Default locale information"`" + + until [[ $COUNT -eq ${#VARS[*]} ]];do + + # Let user to reduce output using regular expression as + # reference. + if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then + + # Output list of environment variables using indirect + # expansion (what a beautiful feature!) to output variable + # value. + cli_printMessage "${INFO[$COUNT]}:" + cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" 'AsResponseLine' + + fi + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkCheck.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkCheck.sh new file mode 100755 index 0000000..32088aa --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkCheck.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# +# verify_doLinkCheck.sh -- This function receives a list of required +# symbolic links and verifies them. This function enforces relation +# between link names and their targets (previously defined in +# verify_doLinks.sh function). +# +# Copyright (C) 2009-2011 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 verify_doLinkCheck { + + local -a LINKS_TARGET + local LINKS_COUNT=0 + + until [[ $LINKS_COUNT -eq ${#LINKS[*]} ]];do + + if [[ -h ${LINKS[$LINKS_COUNT]} ]]; then + + # At this point the required link does exist but we don't + # know if its target is the one it should be. Get target + # from required link in order to check it later. + LINKS_TARGET[$LINKS_COUNT]=$(stat --format='%N' ${LINKS[$LINKS_COUNT]} \ + | tr '`' ' ' | tr "'" ' ' | tr -s ' ' | cut -d' ' -f4) + + # Check required target from required link in order to + # know if it is indeed the one it should be. Otherwise add + # required link to list of missing links. + if [[ ${LINKS_TARGET[$LINKS_COUNT]} != ${TARGETS[$LINKS_COUNT]} ]] ;then + LINKS_MISSING[$LINKS_COUNT]=${LINKS[$LINKS_COUNT]} + LINKS_MISSING_ID="$LINKS_MISSING_ID $LINKS_COUNT" + fi + + else + + # At this point the required link doesn't exist at all. + # Add required link to list of missing links. + LINKS_MISSING[$LINKS_COUNT]=${LINKS[$LINKS_COUNT]} + LINKS_MISSING_ID="$LINKS_MISSING_ID $LINKS_COUNT" + + fi + + # Increase link counter. + LINKS_COUNT=$(($LINKS_COUNT + 1)) + + done + + # Stript out leading spaces from missing links ids. + LINKS_MISSING_ID=$(echo $LINKS_MISSING_ID | sed 's!^ +!!') + + # If there is no missing link, end script execution with a + # descriptive output. + if [[ ${#LINKS_MISSING[*]} -eq 0 ]];then + cli_printMessage "`gettext "The required links are already installed."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkInstall.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkInstall.sh new file mode 100755 index 0000000..302a5f5 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkInstall.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# verify_doLinkInstall.sh -- This function receives a list of missing +# links and installs them using `ln'. +# +# Copyright (C) 2009-2011 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 verify_doLinkInstall { + + local ID=0 + local LINKS_PARENT='' + local WARNING='' + + for ID in $LINKS_MISSING_ID;do + + # Verify parent directory of missing link names that have a + # file as target. If the parent directory doesn't exist, + # create it first before creating links inside it. Because + # links are not created yet, we use their related targets as + # reference to determine what type of link we are creating. + if [[ -f ${TARGETS[$ID]} ]];then + LINKS_PARENT=$(dirname "${LINKS[$ID]}") + cli_checkFiles $LINKS_PARENT 'd' + fi + + # Verify missing link that already exists as regular file. If + # a regular file exists with the same name of a required link, + # warn the user about it and continue with the next file in + # the list of missing links that need to be installed. + if [[ -f ${LINKS[$ID]} ]];then + WARNING=" (`gettext "Already exists as regular file."`)" + cli_printMessage "${LINKS[$ID]}${WARNING}" 'AsResponseLine' + continue + fi + + # Create symbolic link. + ln -s ${TARGETS[$ID]} ${LINKS[$ID]} + + done + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkReport.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkReport.sh new file mode 100755 index 0000000..a47255e --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinkReport.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# verify_doLinkReport.sh -- This function outputs information about +# missing links that need to be installed and a confirmation question +# for users to accept the installation action. +# +# Copyright (C) 2009-2011 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 verify_doLinkReport { + + local LINK='' + local LINKS_MISSING_MAX=0 + + # Define max number of missing links. + LINKS_MISSING_MAX=${#LINKS_MISSING[*]} + + # Output list header. + cli_printMessage "`ngettext "The following link will be installed" \ + "The following links will be installed" "$LINKS_MISSING_MAX"`:" + + # Output list body. + for LINK in ${LINKS_MISSING[@]};do + cli_printMessage "${LINK}" 'AsResponseLine' + done + + # Request confirmation for further link installation. + cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doLinks.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinks.sh new file mode 100755 index 0000000..dcc5dd3 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doLinks.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# verify_doLinks.sh -- This function verifies required links your +# workstation needs in order to run the centos-art command correctly. +# If any required link is missing, the `centos-art.sh' script asks you +# to confirm their installation. When installing links, the +# `centos-art.sh' script uses the `ln' command to achieve the task. +# +# Copyright (C) 2009-2011 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 verify_doLinks { + + local -a LINKS + local -a TARGETS + local -a LINKS_MISSING + local LINKS_MISSING_ID='' + + # Define link names. + LINKS[0]=${HOME}/bin/centos-art + LINKS[1]=${HOME}/.fonts/denmark.ttf + LINKS[2]=${HOME}/.inkscape/palettes/CentOS.gpl + LINKS[3]=${HOME}/.$(rpm -q gimp | cut -d. -f-2)/palettes/CentOS.gpl + LINKS[4]=${HOME}/artwork/branches/Scripts + + # Define link targets. Use array index as reference to know + # relation between link names and targets. Be sure both link names + # and link targets use the same array index value. + TARGETS[0]=${CLI_BASEDIR}/init.sh + TARGETS[1]=$(cli_getRepoTLDir)/Identity/Fonts/Ttf/denmark.ttf + TARGETS[2]=$(cli_getRepoTLDir)/Identity/Colors/CentOS.gpl + TARGETS[3]=${TARGETS[2]} + TARGETS[4]=$(cli_getRepoTLDir)/Scripts/ + + verify_doLinkCheck + verify_doLinkReport + verify_doLinkInstall + + # At this point all required links must be installed. To confirm + # required links installation let's verify them once more. + verify_doLinks + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageCheck.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageCheck.sh new file mode 100755 index 0000000..1b675e5 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageCheck.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# +# verify_doPackageCheck.sh -- This function receives a list of +# packages and verifies if they are currently installed in your +# system. Third party package verification is also done here. +# +# Copyright (C) 2009-2011 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 verify_doPackageCheck { + + local PACKAGE='' + + # Check package manager command existance. + cli_checkFiles '/bin/rpm' 'x' + + for PACKAGE in $PACKAGES;do + + # Query your system's RPM database. + rpm -q --queryformat "%{NAME}\n" $PACKAGE --quiet + + # Define missing packages. + if [[ $? -ne 0 ]];then + PACKAGES_MISSING[$PACKAGES_COUNT]=$PACKAGE + fi + + # Increase package counter. + PACKAGES_COUNT=$(($PACKAGES_COUNT + 1)) + + done + + # In there is no missing package, end script execution with a + # descriptive output. + if [[ ${#PACKAGES_MISSING[*]} -eq 0 ]];then + cli_printMessage "`gettext "The required packages are already installed."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageInstall.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageInstall.sh new file mode 100755 index 0000000..da0d5e6 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageInstall.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# verify_doPackageInstall.sh -- This function receives a list of +# missing packages and installs them using sudo yum. +# +# Copyright (C) 2009-2011 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 verify_doPackageInstall { + + # Verify `yum' command existence. + cli_checkFiles '/usr/bin/yum' 'x' + + # Use sudo to install packages in your system through yum. + sudo yum install ${PACKAGES_MISSING[*]} + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageReport.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageReport.sh new file mode 100755 index 0000000..95a755a --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackageReport.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# verify_doPackageReport.sh -- This function receives one list of +# missing packages and another list of packages from third party +# repository that were marked as missing packages. +# +# Copyright (C) 2009-2011 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 verify_doPackageReport { + + local PACKAGE='' + local WARNING='' + + cli_printMessage "`ngettext "The following package needs to be installed" \ + "The following packages need to be installed" \ + "$PACKAGES_COUNT"`:" + + for PACKAGE in ${PACKAGES_MISSING[@]};do + + # Is this package from third party? + if [[ $PACKAGE =~ $PACKAGES_THIRD_FLAG_FILTER ]];then + WARNING=" (`gettext "requires third party repository!"`)" + fi + + cli_printMessage "${PACKAGE}${WARNING}" 'AsResponseLine' + + done + + cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_doPackages.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackages.sh new file mode 100644 index 0000000..77ab1df --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_doPackages.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# +# verify_doPackages.sh -- This function verifies required packages +# your workstation needs in order to run the centos-art command +# correctly. If there are missing packages, the `centos-art.sh' script +# asks you to confirm their installation. When installing packages, +# the `centos-art.sh' script uses the yum application in order to +# achieve the task. +# +# Copyright (C) 2009-2011 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 verify_doPackages { + + local PACKAGES='' + local PACKAGES_THIRD_FLAG_FILTER='' + local -a PACKAGES_MISSING + local PACKAGES_COUNT=0 + + # 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 texi2html" + + # Define, from required packages, packages being from third + # parties (i.e., packages not included in CentOS [base] + # repository.). + PACKAGES_THIRD_FLAG_FILTER="(inkscape|blender)" + + verify_doPackageCheck + verify_doPackageReport + verify_doPackageInstall + + # At this point we need to recheck installed packages in order to + # be sure the user decided not to continue when there are still + # missing packages to be install. For example this may happen + # when we try to install third party packages and there is no + # third party repository availabe to get those packages from. + verify_doPackages + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_getActions.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_getActions.sh new file mode 100755 index 0000000..d9b8b99 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_getActions.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# verify_getActions.sh -- This function interpretes arguments passed +# to `verify' functionality and calls actions accordingly. +# +# Copyright (C) 2009-2011 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 verify_getActions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="packages,links,environment" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + case "$1" in + + --packages ) + ACTIONNAM="${FUNCNAM}_doPackages" + break + ;; + + --links ) + ACTIONNAM="${FUNCNAM}_doLinks" + break + ;; + + --environment ) + ACTIONNAM="${FUNCNAM}_doEnvironment" + break + ;; + + * ) + break + esac + done + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_pathToCli.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_pathToCli.sh new file mode 100755 index 0000000..7a652f4 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_pathToCli.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# verify_pathToCli.sh -- This function +# +# Copyright (C) 2009-2011 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 verify_pathToCli { + + # Define variables as local to avoid conflicts outside. + local -a REPODIRS + local -a REPOFILES + local -a REPOLINKS + local FILE='' + + # Define directories required by the centos-art.sh script command + # line interface. + REPODIRS[0]=/home/centos + REPODIRS[1]=/home/centos/bin + REPODIRS[2]=${CLI_BASEDIR} + + # Define files required by the centos-art.sh script command line + # interface. + REPOFILES[0]=${REPODIRS[2]}/init.sh + + # Define symbolic links required by the centos-art.sh script + # command line interface. + REPOLINKS[0]=${REPODIRS[1]}/centos-art + + # Check defined directories. + for FILE in "${REPODIRS[@]}";do + cli_checkFiles $FILE 'd' + done + + # Check defined files. + for FILE in "${REPOFILES[@]}";do + cli_checkFiles $FILE 'f' + done + + # Check defined symbolic links. + for FILE in "${REPOLINKS[@]}";do + cli_checkFiles $FILE 'h' + done + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_pathToFonts.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_pathToFonts.sh new file mode 100644 index 0000000..eb40ab3 --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_pathToFonts.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# verify_pathToFonts.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-2011 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 verify_pathToFonts { + + # Define variables as local to avoid conflicts outside. + local -a REPODIRS + local -a REPOFILES + local -a REPOLINKS + local FILE='' + + # Define font related directories. + REPODIRS[0]=${HOME}/.fonts + REPODIRS[1]=$(cli_getRepoTLDir)/Identity/Fonts/Ttf + + # Define font related files. + REPOFILES[0]=${REPODIRS[1]}/denmark.ttf + + # Define font related symbolic links. + REPOLINKS[0]=${REPODIRS[0]}/denmark.ttf + + # Check defined directories. + for FILE in "${REPODIRS[@]}";do + cli_checkFiles $FILE 'd' + done + + # Check defined files. + for FILE in "${REPOFILES[@]}";do + cli_checkFiles $FILE 'f' + done + + # Check defined symbolic links. + for FILE in "${REPOLINKS[@]}";do + cli_checkFiles $FILE 'h' + done + +} diff --git a/Scripts/Bash/Cli/Functions/Prepare/verify_pathToInkscape.sh b/Scripts/Bash/Cli/Functions/Prepare/verify_pathToInkscape.sh new file mode 100755 index 0000000..fa1c57e --- /dev/null +++ b/Scripts/Bash/Cli/Functions/Prepare/verify_pathToInkscape.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# verify_pathToInkscape.sh -- This function prepares user's +# ~/.inkscape configurations directory to use CentOS defaults (e.g., +# palettes, patterns, etc). +# +# Copyright (C) 2009-2011 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 verify_pathToInkscape { + + # Define variables as local to avoid conflicts outside. + local -a REPODIRS + local -a REPOFILES + local -a REPOLINKS + local FILE='' + + # Define directories required by the centos-art.sh script command + # line interface. + REPODIRS[0]=${HOME}/.inkscape/palettes + REPODIRS[1]=$(cli_getRepoTLDir)/Identity/Colors + + # Define files required by the centos-art.sh script command line + # interface. + REPOFILES[0]=${REPODIRS[1]}/CentOS.gpl + + # Define symbolic links required by the centos-art.sh script + # command line interface. + REPOLINKS[0]=${REPODIRS[0]}/CentOS.gpl + + # Check defined directories. + for FILE in "${REPODIRS[@]}";do + cli_checkFiles $FILE 'd' + done + + # Check defined files. + for FILE in "${REPOFILES[@]}";do + cli_checkFiles $FILE 'f' + done + + # Check defined symbolic links. + for FILE in "${REPOLINKS[@]}";do + cli_checkFiles $FILE 'h' + done + +} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify.sh b/Scripts/Bash/Cli/Functions/Verify/verify.sh deleted file mode 100755 index 0265eae..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# -# verify.sh -- This function verifies your workstation for using -# centos-art.sh script. -# -# Copyright (C) 2009-2011 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 verify { - - # Define command-line interface. - verify_getActions - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doEnvironment.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doEnvironment.sh deleted file mode 100755 index 10eddd5..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doEnvironment.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# verify_doEnvironment.sh -- This function outputs a brief description -# of environment variables used by `centos-art.sh' script. -# -# Copyright (C) 2009-2011 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 verify_doEnvironment { - - local -a VARS - local -a INFO - local COUNT=0 - - # Define name of environment variables used by centos-art.sh - # script. - VARS[0]='EDITOR' - VARS[1]='TZ' - VARS[2]='TEXTDOMAIN' - VARS[3]='TEXTDOMAINDIR' - VARS[4]='LANG' - - # Define description of environment variables. - INFO[0]="`gettext "Default text editor"`" - INFO[1]="`gettext "Default time zone representation"`" - INFO[2]="`gettext "Default domain used to retrieve translated messages"`" - INFO[3]="`gettext "Default directory used to retrive translated messages"`" - INFO[4]="`gettext "Default locale information"`" - - until [[ $COUNT -eq ${#VARS[*]} ]];do - - # Let user to reduce output using regular expression as - # reference. - if [[ ${VARS[$COUNT]} =~ $FLAG_FILTER ]];then - - # Output list of environment variables using indirect - # expansion (what a beautiful feature!) to output variable - # value. - cli_printMessage "${INFO[$COUNT]}:" - cli_printMessage "${VARS[$COUNT]}=${!VARS[$COUNT]}" 'AsResponseLine' - - fi - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doLinkCheck.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doLinkCheck.sh deleted file mode 100755 index 32088aa..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doLinkCheck.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/bash -# -# verify_doLinkCheck.sh -- This function receives a list of required -# symbolic links and verifies them. This function enforces relation -# between link names and their targets (previously defined in -# verify_doLinks.sh function). -# -# Copyright (C) 2009-2011 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 verify_doLinkCheck { - - local -a LINKS_TARGET - local LINKS_COUNT=0 - - until [[ $LINKS_COUNT -eq ${#LINKS[*]} ]];do - - if [[ -h ${LINKS[$LINKS_COUNT]} ]]; then - - # At this point the required link does exist but we don't - # know if its target is the one it should be. Get target - # from required link in order to check it later. - LINKS_TARGET[$LINKS_COUNT]=$(stat --format='%N' ${LINKS[$LINKS_COUNT]} \ - | tr '`' ' ' | tr "'" ' ' | tr -s ' ' | cut -d' ' -f4) - - # Check required target from required link in order to - # know if it is indeed the one it should be. Otherwise add - # required link to list of missing links. - if [[ ${LINKS_TARGET[$LINKS_COUNT]} != ${TARGETS[$LINKS_COUNT]} ]] ;then - LINKS_MISSING[$LINKS_COUNT]=${LINKS[$LINKS_COUNT]} - LINKS_MISSING_ID="$LINKS_MISSING_ID $LINKS_COUNT" - fi - - else - - # At this point the required link doesn't exist at all. - # Add required link to list of missing links. - LINKS_MISSING[$LINKS_COUNT]=${LINKS[$LINKS_COUNT]} - LINKS_MISSING_ID="$LINKS_MISSING_ID $LINKS_COUNT" - - fi - - # Increase link counter. - LINKS_COUNT=$(($LINKS_COUNT + 1)) - - done - - # Stript out leading spaces from missing links ids. - LINKS_MISSING_ID=$(echo $LINKS_MISSING_ID | sed 's!^ +!!') - - # If there is no missing link, end script execution with a - # descriptive output. - if [[ ${#LINKS_MISSING[*]} -eq 0 ]];then - cli_printMessage "`gettext "The required links are already installed."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doLinkInstall.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doLinkInstall.sh deleted file mode 100755 index 302a5f5..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doLinkInstall.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -# -# verify_doLinkInstall.sh -- This function receives a list of missing -# links and installs them using `ln'. -# -# Copyright (C) 2009-2011 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 verify_doLinkInstall { - - local ID=0 - local LINKS_PARENT='' - local WARNING='' - - for ID in $LINKS_MISSING_ID;do - - # Verify parent directory of missing link names that have a - # file as target. If the parent directory doesn't exist, - # create it first before creating links inside it. Because - # links are not created yet, we use their related targets as - # reference to determine what type of link we are creating. - if [[ -f ${TARGETS[$ID]} ]];then - LINKS_PARENT=$(dirname "${LINKS[$ID]}") - cli_checkFiles $LINKS_PARENT 'd' - fi - - # Verify missing link that already exists as regular file. If - # a regular file exists with the same name of a required link, - # warn the user about it and continue with the next file in - # the list of missing links that need to be installed. - if [[ -f ${LINKS[$ID]} ]];then - WARNING=" (`gettext "Already exists as regular file."`)" - cli_printMessage "${LINKS[$ID]}${WARNING}" 'AsResponseLine' - continue - fi - - # Create symbolic link. - ln -s ${TARGETS[$ID]} ${LINKS[$ID]} - - done - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doLinkReport.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doLinkReport.sh deleted file mode 100755 index a47255e..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doLinkReport.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# -# verify_doLinkReport.sh -- This function outputs information about -# missing links that need to be installed and a confirmation question -# for users to accept the installation action. -# -# Copyright (C) 2009-2011 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 verify_doLinkReport { - - local LINK='' - local LINKS_MISSING_MAX=0 - - # Define max number of missing links. - LINKS_MISSING_MAX=${#LINKS_MISSING[*]} - - # Output list header. - cli_printMessage "`ngettext "The following link will be installed" \ - "The following links will be installed" "$LINKS_MISSING_MAX"`:" - - # Output list body. - for LINK in ${LINKS_MISSING[@]};do - cli_printMessage "${LINK}" 'AsResponseLine' - done - - # Request confirmation for further link installation. - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doLinks.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doLinks.sh deleted file mode 100755 index dcc5dd3..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doLinks.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# -# verify_doLinks.sh -- This function verifies required links your -# workstation needs in order to run the centos-art command correctly. -# If any required link is missing, the `centos-art.sh' script asks you -# to confirm their installation. When installing links, the -# `centos-art.sh' script uses the `ln' command to achieve the task. -# -# Copyright (C) 2009-2011 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 verify_doLinks { - - local -a LINKS - local -a TARGETS - local -a LINKS_MISSING - local LINKS_MISSING_ID='' - - # Define link names. - LINKS[0]=${HOME}/bin/centos-art - LINKS[1]=${HOME}/.fonts/denmark.ttf - LINKS[2]=${HOME}/.inkscape/palettes/CentOS.gpl - LINKS[3]=${HOME}/.$(rpm -q gimp | cut -d. -f-2)/palettes/CentOS.gpl - LINKS[4]=${HOME}/artwork/branches/Scripts - - # Define link targets. Use array index as reference to know - # relation between link names and targets. Be sure both link names - # and link targets use the same array index value. - TARGETS[0]=${CLI_BASEDIR}/init.sh - TARGETS[1]=$(cli_getRepoTLDir)/Identity/Fonts/Ttf/denmark.ttf - TARGETS[2]=$(cli_getRepoTLDir)/Identity/Colors/CentOS.gpl - TARGETS[3]=${TARGETS[2]} - TARGETS[4]=$(cli_getRepoTLDir)/Scripts/ - - verify_doLinkCheck - verify_doLinkReport - verify_doLinkInstall - - # At this point all required links must be installed. To confirm - # required links installation let's verify them once more. - verify_doLinks - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doPackageCheck.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doPackageCheck.sh deleted file mode 100755 index 1b675e5..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doPackageCheck.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# -# verify_doPackageCheck.sh -- This function receives a list of -# packages and verifies if they are currently installed in your -# system. Third party package verification is also done here. -# -# Copyright (C) 2009-2011 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 verify_doPackageCheck { - - local PACKAGE='' - - # Check package manager command existance. - cli_checkFiles '/bin/rpm' 'x' - - for PACKAGE in $PACKAGES;do - - # Query your system's RPM database. - rpm -q --queryformat "%{NAME}\n" $PACKAGE --quiet - - # Define missing packages. - if [[ $? -ne 0 ]];then - PACKAGES_MISSING[$PACKAGES_COUNT]=$PACKAGE - fi - - # Increase package counter. - PACKAGES_COUNT=$(($PACKAGES_COUNT + 1)) - - done - - # In there is no missing package, end script execution with a - # descriptive output. - if [[ ${#PACKAGES_MISSING[*]} -eq 0 ]];then - cli_printMessage "`gettext "The required packages are already installed."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doPackageInstall.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doPackageInstall.sh deleted file mode 100755 index da0d5e6..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doPackageInstall.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# -# verify_doPackageInstall.sh -- This function receives a list of -# missing packages and installs them using sudo yum. -# -# Copyright (C) 2009-2011 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 verify_doPackageInstall { - - # Verify `yum' command existence. - cli_checkFiles '/usr/bin/yum' 'x' - - # Use sudo to install packages in your system through yum. - sudo yum install ${PACKAGES_MISSING[*]} - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doPackageReport.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doPackageReport.sh deleted file mode 100755 index 95a755a..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doPackageReport.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# verify_doPackageReport.sh -- This function receives one list of -# missing packages and another list of packages from third party -# repository that were marked as missing packages. -# -# Copyright (C) 2009-2011 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 verify_doPackageReport { - - local PACKAGE='' - local WARNING='' - - cli_printMessage "`ngettext "The following package needs to be installed" \ - "The following packages need to be installed" \ - "$PACKAGES_COUNT"`:" - - for PACKAGE in ${PACKAGES_MISSING[@]};do - - # Is this package from third party? - if [[ $PACKAGE =~ $PACKAGES_THIRD_FLAG_FILTER ]];then - WARNING=" (`gettext "requires third party repository!"`)" - fi - - cli_printMessage "${PACKAGE}${WARNING}" 'AsResponseLine' - - done - - cli_printMessage "`gettext "Do you want to continue"`" 'AsYesOrNoRequestLine' - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_doPackages.sh b/Scripts/Bash/Cli/Functions/Verify/verify_doPackages.sh deleted file mode 100644 index 77ab1df..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_doPackages.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -# -# verify_doPackages.sh -- This function verifies required packages -# your workstation needs in order to run the centos-art command -# correctly. If there are missing packages, the `centos-art.sh' script -# asks you to confirm their installation. When installing packages, -# the `centos-art.sh' script uses the yum application in order to -# achieve the task. -# -# Copyright (C) 2009-2011 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 verify_doPackages { - - local PACKAGES='' - local PACKAGES_THIRD_FLAG_FILTER='' - local -a PACKAGES_MISSING - local PACKAGES_COUNT=0 - - # 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 texi2html" - - # Define, from required packages, packages being from third - # parties (i.e., packages not included in CentOS [base] - # repository.). - PACKAGES_THIRD_FLAG_FILTER="(inkscape|blender)" - - verify_doPackageCheck - verify_doPackageReport - verify_doPackageInstall - - # At this point we need to recheck installed packages in order to - # be sure the user decided not to continue when there are still - # missing packages to be install. For example this may happen - # when we try to install third party packages and there is no - # third party repository availabe to get those packages from. - verify_doPackages - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_getActions.sh b/Scripts/Bash/Cli/Functions/Verify/verify_getActions.sh deleted file mode 100755 index d9b8b99..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_getActions.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# -# verify_getActions.sh -- This function interpretes arguments passed -# to `verify' functionality and calls actions accordingly. -# -# Copyright (C) 2009-2011 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 verify_getActions { - - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="packages,links,environment" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Look for options passed through command-line. - while true; do - case "$1" in - - --packages ) - ACTIONNAM="${FUNCNAM}_doPackages" - break - ;; - - --links ) - ACTIONNAM="${FUNCNAM}_doLinks" - break - ;; - - --environment ) - ACTIONNAM="${FUNCNAM}_doEnvironment" - break - ;; - - * ) - break - esac - done - - # Execute action name. - if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then - eval $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_pathToCli.sh b/Scripts/Bash/Cli/Functions/Verify/verify_pathToCli.sh deleted file mode 100755 index 7a652f4..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_pathToCli.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# verify_pathToCli.sh -- This function -# -# Copyright (C) 2009-2011 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 verify_pathToCli { - - # Define variables as local to avoid conflicts outside. - local -a REPODIRS - local -a REPOFILES - local -a REPOLINKS - local FILE='' - - # Define directories required by the centos-art.sh script command - # line interface. - REPODIRS[0]=/home/centos - REPODIRS[1]=/home/centos/bin - REPODIRS[2]=${CLI_BASEDIR} - - # Define files required by the centos-art.sh script command line - # interface. - REPOFILES[0]=${REPODIRS[2]}/init.sh - - # Define symbolic links required by the centos-art.sh script - # command line interface. - REPOLINKS[0]=${REPODIRS[1]}/centos-art - - # Check defined directories. - for FILE in "${REPODIRS[@]}";do - cli_checkFiles $FILE 'd' - done - - # Check defined files. - for FILE in "${REPOFILES[@]}";do - cli_checkFiles $FILE 'f' - done - - # Check defined symbolic links. - for FILE in "${REPOLINKS[@]}";do - cli_checkFiles $FILE 'h' - done - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_pathToFonts.sh b/Scripts/Bash/Cli/Functions/Verify/verify_pathToFonts.sh deleted file mode 100644 index eb40ab3..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_pathToFonts.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -# -# verify_pathToFonts.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-2011 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 verify_pathToFonts { - - # Define variables as local to avoid conflicts outside. - local -a REPODIRS - local -a REPOFILES - local -a REPOLINKS - local FILE='' - - # Define font related directories. - REPODIRS[0]=${HOME}/.fonts - REPODIRS[1]=$(cli_getRepoTLDir)/Identity/Fonts/Ttf - - # Define font related files. - REPOFILES[0]=${REPODIRS[1]}/denmark.ttf - - # Define font related symbolic links. - REPOLINKS[0]=${REPODIRS[0]}/denmark.ttf - - # Check defined directories. - for FILE in "${REPODIRS[@]}";do - cli_checkFiles $FILE 'd' - done - - # Check defined files. - for FILE in "${REPOFILES[@]}";do - cli_checkFiles $FILE 'f' - done - - # Check defined symbolic links. - for FILE in "${REPOLINKS[@]}";do - cli_checkFiles $FILE 'h' - done - -} diff --git a/Scripts/Bash/Cli/Functions/Verify/verify_pathToInkscape.sh b/Scripts/Bash/Cli/Functions/Verify/verify_pathToInkscape.sh deleted file mode 100755 index fa1c57e..0000000 --- a/Scripts/Bash/Cli/Functions/Verify/verify_pathToInkscape.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# -# verify_pathToInkscape.sh -- This function prepares user's -# ~/.inkscape configurations directory to use CentOS defaults (e.g., -# palettes, patterns, etc). -# -# Copyright (C) 2009-2011 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 verify_pathToInkscape { - - # Define variables as local to avoid conflicts outside. - local -a REPODIRS - local -a REPOFILES - local -a REPOLINKS - local FILE='' - - # Define directories required by the centos-art.sh script command - # line interface. - REPODIRS[0]=${HOME}/.inkscape/palettes - REPODIRS[1]=$(cli_getRepoTLDir)/Identity/Colors - - # Define files required by the centos-art.sh script command line - # interface. - REPOFILES[0]=${REPODIRS[1]}/CentOS.gpl - - # Define symbolic links required by the centos-art.sh script - # command line interface. - REPOLINKS[0]=${REPODIRS[0]}/CentOS.gpl - - # Check defined directories. - for FILE in "${REPODIRS[@]}";do - cli_checkFiles $FILE 'd' - done - - # Check defined files. - for FILE in "${REPOFILES[@]}";do - cli_checkFiles $FILE 'f' - done - - # Check defined symbolic links. - for FILE in "${REPOLINKS[@]}";do - cli_checkFiles $FILE 'h' - done - -}