|
|
c979f9 |
#!/bin/bash
|
|
|
c979f9 |
#
|
|
|
56c262 |
# render_doPostActions.sh -- This function standardizes the way
|
|
|
56c262 |
# last-rendition actions are applied to base-rendition and
|
|
|
56c262 |
# post-rendition outputs.
|
|
|
c979f9 |
#
|
|
|
2d3646 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c979f9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c979f9 |
# General Public License for more details.
|
|
|
c979f9 |
#
|
|
|
c979f9 |
# You should have received a copy of the GNU General Public License
|
|
|
c979f9 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
c979f9 |
# ----------------------------------------------------------------------
|
|
|
c979f9 |
# $Id$
|
|
|
c979f9 |
# ----------------------------------------------------------------------
|
|
|
c979f9 |
|
|
|
ab1d67 |
function render_doLastActions {
|
|
|
c979f9 |
|
|
|
56c262 |
# Define the file extensions. This value is a regular expression
|
|
|
56c262 |
# pattern which must match the file extensions that last-rendition
|
|
|
56c262 |
# actions will be applied to.
|
|
|
2a9294 |
local EXTENSION=$(render_getConfigOption "$ACTION" '2')
|
|
|
c979f9 |
|
|
|
56c262 |
# Define the command string that will be evaluated as
|
|
|
56c262 |
# last-rendition action. Only commands that perform in-place
|
|
|
56c262 |
# modifications can be passed here.
|
|
|
2a9294 |
local COMMAND=$(render_getConfigOption "$ACTION" '3-')
|
|
|
c979f9 |
|
|
|
56c262 |
# Define the list of files to process. This value contain all the
|
|
|
56c262 |
# files in the output directory which extension match the
|
|
|
56c262 |
# extension pattern previously defined.
|
|
|
2a9294 |
local FILE=''
|
|
|
2a9294 |
local FILES=$(cli_getFilesList $OUTPUT --pattern=".+\.${EXTENSION}")
|
|
|
2a9294 |
|
|
|
2a9294 |
for FILE in $FILES;do
|
|
|
2a9294 |
|
|
|
2a9294 |
# Identify file before processing it. Only formats recognized
|
|
|
2a9294 |
# by ImageMagick are supported. In case the file isn't
|
|
|
2a9294 |
# supported by ImageMagick, continue with the next file in the
|
|
|
2a9294 |
# list.
|
|
|
2a9294 |
identify -quiet ${FILE} > /dev/null
|
|
|
2a9294 |
if [[ $? -ne 0 ]];then
|
|
|
2a9294 |
continue
|
|
|
2a9294 |
fi
|
|
|
2a9294 |
|
|
|
2a9294 |
# Print action message.
|
|
|
2a9294 |
cli_printMessage "${FILE}" --as-updating-line
|
|
|
2a9294 |
|
|
|
2a9294 |
# Execute mogrify action on all files inside the same
|
|
|
2a9294 |
# directory structure.
|
|
|
2a9294 |
eval ${COMMAND} ${FILE}
|
|
|
2a9294 |
|
|
|
2a9294 |
# Be sure the command was executed correctly. Otherwise stop
|
|
|
2a9294 |
# script execution.
|
|
|
2a9294 |
if [[ $? -ne 0 ]];then
|
|
|
2a9294 |
exit
|
|
|
2a9294 |
fi
|
|
|
2a9294 |
|
|
|
2a9294 |
done
|
|
|
c979f9 |
|
|
|
c979f9 |
}
|