|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# prepare_updateLinks.sh -- This option creates/updates the symbolic links
|
|
|
878a2b |
# information required in your workstation to connect it with the
|
|
|
878a2b |
# files inside the working copy of The CentOS Artwork Repository. When
|
|
|
878a2b |
# you provide this option, the centos-art.sh put itself into your
|
|
|
878a2b |
# system's execution path and make common brushes, patterns, palettes
|
|
|
878a2b |
# and fonts available inside applications like GIMP, so you can make
|
|
|
878a2b |
# use of them without loosing version control over them.
|
|
|
878a2b |
#
|
|
|
e6bbbf |
# Copyright (C) 2009-2013 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
# it under the terms of the GNU General Public License as published by
|
|
|
878a2b |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
878a2b |
# your option) any later version.
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is distributed in the hope that it will be useful, but
|
|
|
878a2b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
878a2b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
# You should have received a copy of the GNU General Public License
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function prepare_updateLinks {
|
|
|
878a2b |
|
|
|
878a2b |
local -a LINKS_SRC
|
|
|
878a2b |
local -a LINKS_DST
|
|
|
878a2b |
local USERFILES=''
|
|
|
878a2b |
local PALETTE=''
|
|
|
878a2b |
local BRUSH=''
|
|
|
878a2b |
local PATTERN=''
|
|
|
878a2b |
local FONT=''
|
|
|
878a2b |
local FILE=''
|
|
|
878a2b |
local COUNT=0
|
|
|
878a2b |
|
|
|
d4d4d3 |
# Define user's directories. Here is where configuration links are
|
|
|
d4d4d3 |
# created in the local workstation.
|
|
|
878a2b |
local GIMP_DIR=${HOME}/.$(rpm -q gimp | cut -d. -f-2)
|
|
|
878a2b |
local GIMP_DIR_BRUSHES=${GIMP_DIR}/brushes
|
|
|
878a2b |
local GIMP_DIR_PALETTES=${GIMP_DIR}/palettes
|
|
|
878a2b |
local GIMP_DIR_PATTERNS=${GIMP_DIR}/patterns
|
|
|
878a2b |
local INKS_DIR=${HOME}/.inkscape
|
|
|
878a2b |
local INKS_DIR_PALETTES=${INKS_DIR}/palettes
|
|
|
878a2b |
local FONT_DIR=${HOME}/.fonts
|
|
|
878a2b |
local APPS_DIR=${HOME}/bin
|
|
|
878a2b |
|
|
|
d4d4d3 |
# Define the working copy directory structure. Here is where user
|
|
|
d4d4d3 |
# specific configuration links in the workstation will point to.
|
|
|
819c26 |
local WCDIR=${TCAR_WORKDIR}/Identity
|
|
|
878a2b |
local WCDIR_BRUSHES=${WCDIR}/Brushes
|
|
|
878a2b |
local WCDIR_PALETTES=${WCDIR}/Palettes
|
|
|
878a2b |
local WCDIR_PATTERNS=${WCDIR}/Patterns
|
|
|
878a2b |
local WCDIR_FONTS=${WCDIR}/Fonts
|
|
|
878a2b |
local WCDIR_EDITOR=${PREPARE_CONFIG_DIR}
|
|
|
878a2b |
|
|
|
d4d4d3 |
# Verify required working copy directory structure. If these
|
|
|
d4d4d3 |
# directories don't exist, there isn't a target location where
|
|
|
d4d4d3 |
# configuration links can point to. To prevent such an issue
|
|
|
d4d4d3 |
# output an error message and stop the script execution after it.
|
|
|
d4d4d3 |
for DIR in $(echo "Brushes Palettes Patterns Fonts");do
|
|
|
3f2ce5 |
cli_checkFiles ${WCDIR}/${DIR}
|
|
|
d4d4d3 |
done
|
|
|
d4d4d3 |
|
|
|
878a2b |
# Define link relation for cli.
|
|
|
02dc08 |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${APPS_DIR}/${CLI_NAME}
|
|
|
02dc08 |
LINKS_DST[((++${#LINKS_DST[*]}))]=${CLI_BASEDIR}/${CLI_NAME}.sh
|
|
|
02dc08 |
USERFILES="${APPS_DIR}/${CLI_NAME}"
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for fonts.
|
|
|
82bb43 |
for FONT in $(cli_getFilesList "${WCDIR_FONTS}" --pattern='^.+\.ttf$');do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${FONT_DIR}/$(basename $FONT)
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${FONT}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for common palettes.
|
|
|
82bb43 |
for PALETTE in $(cli_getFilesList "${WCDIR_PALETTES}" --pattern="^.+\.gpl$");do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE}
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${INKS_DIR_PALETTES}/$(prepare_getLinkName ${WCDIR_PALETTES} ${PALETTE})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PALETTE}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for common brushes.
|
|
|
82bb43 |
for BRUSH in $(cli_getFilesList "${WCDIR_BRUSHES}" --pattern="^.+\.(gbr|gih)$");do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_BRUSHES}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${BRUSH}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for common patterns.
|
|
|
82bb43 |
for PATTERN in $(cli_getFilesList "${WCDIR_PATTERNS}" --pattern="^.+\.png$");do
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${GIMP_DIR_PATTERNS}/$(prepare_getLinkName ${WCDIR_BRUSHES} ${BRUSH})
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${PATTERN}
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Define link relation for Vim text editor's configuration.
|
|
|
878a2b |
if [[ $EDITOR == '/usr/bin/vim' ]];then
|
|
|
878a2b |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${HOME}/.vimrc
|
|
|
878a2b |
LINKS_DST[((++${#LINKS_DST[*]}))]=${WCDIR_EDITOR}/vim.conf
|
|
|
878a2b |
USERFILES="${USERFILES} ${HOME}/.vimrc"
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
3fc0ea |
# Define link relation for the `reset.css' file. The `reset.css'
|
|
|
3fc0ea |
# file is resets the web browser default style and use ours
|
|
|
3fc0ea |
# instead. The reset.css file is common for all web environments
|
|
|
3fc0ea |
# so there is no need to have duplicated files inside the working
|
|
|
3fc0ea |
# copy. Instead, create a symbolic link to it from different
|
|
|
3fc0ea |
# places using absolute paths and the default style guide as
|
|
|
3fc0ea |
# reference.
|
|
|
819c26 |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Docbook/1.69.1/Css/reset.css
|
|
|
819c26 |
LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Style-guide/0.0.1/Css/reset.css
|
|
|
3fc0ea |
|
|
|
3fc0ea |
# Define link relation for `images' directory used inside the
|
|
|
3fc0ea |
# default web environment style guide. The `images' directory
|
|
|
3fc0ea |
# contains common images used by all web environments. By default
|
|
|
3fc0ea |
# no image is under version control so we point out the output
|
|
|
3fc0ea |
# directory where this images produced, once rendered.
|
|
|
819c26 |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Webenv/Themes/Default/Style-guide/0.0.1/Images
|
|
|
819c26 |
LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv
|
|
|
3fc0ea |
|
|
|
61bb0b |
# Define link relation for `Manuals' images. These images exists
|
|
|
61bb0b |
# to help people describe ideas inside documentation.
|
|
|
819c26 |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv/Manuals
|
|
|
819c26 |
LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Manuals
|
|
|
61bb0b |
|
|
|
3fc0ea |
# Define link for `centos-logo.png', the branding information that
|
|
|
3fc0ea |
# should be used in all web applications on the left-top corner.
|
|
|
819c26 |
LINKS_SRC[((++${#LINKS_SRC[*]}))]=${TCAR_WORKDIR}/Identity/Images/Webenv/logo-centos.png
|
|
|
819c26 |
LINKS_DST[((++${#LINKS_DST[*]}))]=${TCAR_WORKDIR}/Identity/Images/Brands/Logos/White/78/centos.png
|
|
|
3fc0ea |
|
|
|
878a2b |
# Define which files inside the user's configuration directories
|
|
|
878a2b |
# need to be removed in order for centos-art.sh script to make a
|
|
|
878a2b |
# fresh installation of common patterns, common palettes and
|
|
|
878a2b |
# common brushes using symbolic links from the working copy to the
|
|
|
878a2b |
# user's configuration directories inside the workstation.
|
|
|
878a2b |
USERFILES=$(echo "$USERFILES";
|
|
|
82bb43 |
cli_getFilesList ${APPS_DIR} --pattern='^.+\.sh$';
|
|
|
82bb43 |
cli_getFilesList ${FONT_DIR} --pattern='^.+\.ttf$';
|
|
|
82bb43 |
cli_getFilesList ${GIMP_DIR_BRUSHES} --pattern='^.+\.(gbr|gih)$';
|
|
|
82bb43 |
cli_getFilesList ${GIMP_DIR_PATTERNS} --pattern='^.+\.(pat|png|jpg|bmp)$';
|
|
|
82bb43 |
cli_getFilesList ${GIMP_DIR_PALETTES} --pattern='^.+\.gpl$';
|
|
|
82bb43 |
cli_getFilesList ${INKS_DIR_PALETTES} --pattern='^.+\.gpl$';)
|
|
|
878a2b |
|
|
|
878a2b |
# Remove user-specific configuration files from user's home
|
|
|
3fc0ea |
# directory before creating symbolic links from the working copy.
|
|
|
3fc0ea |
# Otherwise, we might end up having links inside the user's home
|
|
|
3fc0ea |
# directory that don't exist inside the working copy.
|
|
|
878a2b |
if [[ "$USERFILES" != '' ]];then
|
|
|
878a2b |
rm -r $USERFILES
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
while [[ $COUNT -lt ${#LINKS_SRC[*]} ]];do
|
|
|
878a2b |
|
|
|
878a2b |
# Print action message.
|
|
|
878a2b |
cli_printMessage "${LINKS_SRC[$COUNT]}" --as-creating-line
|
|
|
878a2b |
|
|
|
878a2b |
# Create symbolic link's parent directory if it doesn't exist.
|
|
|
878a2b |
if [[ ! -d $(dirname ${LINKS_SRC[$COUNT]}) ]];then
|
|
|
878a2b |
mkdir -p $(dirname ${LINKS_SRC[$COUNT]})
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
819c26 |
# Remove symbolic link before creating it to prevent recursive
|
|
|
3fc0ea |
# creation once the first symbolic link be created and it be a
|
|
|
3fc0ea |
# directory.
|
|
|
3fc0ea |
if [[ -a ${LINKS_SRC[$COUNT]} ]];then
|
|
|
3fc0ea |
rm ${LINKS_SRC[$COUNT]}
|
|
|
3fc0ea |
fi
|
|
|
3fc0ea |
|
|
|
878a2b |
# Create symbolic link.
|
|
|
878a2b |
ln ${LINKS_DST[$COUNT]} ${LINKS_SRC[$COUNT]} --symbolic --force
|
|
|
878a2b |
|
|
|
878a2b |
# Increment counter.
|
|
|
878a2b |
COUNT=$(($COUNT + 1))
|
|
|
878a2b |
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
}
|