diff --git a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh index 0fcdf77..beb183e 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh @@ -335,7 +335,7 @@ function render_getIdentityDefs { FILE=$IMG/$FILE # Define instance name. - INSTANCE=/tmp/$(basename $TEMPLATE) + INSTANCE=$(cli_getTemporalFile $TEMPLATE) # Remove template instance if it is already present. if [[ -a $INSTANCE ]];then diff --git a/Scripts/Bash/Functions/Shell/shell_updateTopComment.sh b/Scripts/Bash/Functions/Shell/shell_updateTopComment.sh index 76d34f7..5e55008 100755 --- a/Scripts/Bash/Functions/Shell/shell_updateTopComment.sh +++ b/Scripts/Bash/Functions/Shell/shell_updateTopComment.sh @@ -58,7 +58,7 @@ function shell_updateTopComment { cli_checkFiles $TEMPLATE 'f' # Define template instance name. - INSTANCE=${TMPFILE}-$(basename $TEMPLATE) + INSTANCE=$(cli_getTemporalFile $TEMPLATE) # Define the last year to use in the copyright note. As last year # we understand the last year in which the files were modified, or diff --git a/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh b/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh index f2c09ea..35b8084 100755 --- a/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh +++ b/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh @@ -64,7 +64,7 @@ function svg_updateMetadata { cli_checkFiles $TEMPLATE 'f' # Define metadata template instance. - INSTANCE=${TMPFILE}-$(basename $TEMPLATE) + INSTANCE=$(cli_getTemporalFile $TEMPLATE) # Define svg document date. DATE=$(date +%Y-%m-%d) diff --git a/Scripts/Bash/Functions/cli_getTemporalFile.sh b/Scripts/Bash/Functions/cli_getTemporalFile.sh new file mode 100755 index 0000000..80cfc8d --- /dev/null +++ b/Scripts/Bash/Functions/cli_getTemporalFile.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# +# cli_getTemporalFile.sh -- This function returns absolute path to +# temporal file. Use this function whenever you need to create +# temporal files inside centos-art.sh script. +# +# 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 cli_getTemporalFile { + + # Check amount arguments passed to this function. + if [[ $# -ne 1 ]];then + cli_printMessage "cli_getTemporalFile: `gettext "First argument is required."`" + cli_printMessage "$(caller)" 'ToKnowMoreLine' + fi + + # Define default basename for temporal file. This is required when + # svg instances are created previous to be parsed by inkscape in + # order to be exported as png. In such cases .svg file exention is + # required in order to avoid inkscape complains. + local NAME="$1" + if [[ "$NAME" == '' ]];then + cli_printMessage "cli_getTemporalFile: `gettext "First argument cannot be empty."`" + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + else + NAME="-$(basename $1)" + fi + + # Define default source location where temporal files will be stored. + local TMPDIR='/tmp' + + # Define default prefix for temporal file. + local PREFIX='centos-art.sh-' + + # Define unique identifier for temporal file. + local UUID=$(cat /proc/sys/kernel/random/uuid) + + # Join default source location and filename to build final + # temporal file absolute path. + local TMPFILE=$(echo -n "${TMPDIR}/${PREFIX}${UUID}${NAME}") + + # Output absolute path to final temporal file. + echo $TMPFILE + +}