Koha/misc/cronjobs/printoverdues.sh
Sophie Meynieux 04e9022e4f Bug 10127 : Printoverdues.sh should tar only pdf files
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>

From the bug report:
At the end of printoverdues.sh, an archive is generated
containing all files present in  directory given as parameter.
As archives are generated in this given directory, they
contain previously generated tar files, creating oversized files.
Only .pdf files should be archived

All tests and QA script pass.
Worked ok in my tests, only packign PDF in the given directory.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-07-16 15:47:13 +00:00

50 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
print_usage(){
echo "$0 : generates PDF files from html files in directorys and prints them";
echo "usage :";
echo "$0 directory [css [printer_host [printername]]]"
echo " - directory directory to use to apply html2pdf transform";
echo " - css css file to apply to html ";
echo " - printer_host Network Name or IP of the printer (port possibly included) ";
echo " - printer_name printername ";
echo "Note that css printerhost and printername are optional parameters ";
echo "Note that this script uses xhtml2pdf command ";
echo " xhtml2pdf command comes with pisa (a python library)
To install you need setuptools library for python
then type easy_install pisa ";
exit 1;
}
if [ $# -lt 1 ]
then
print_usage
fi
if [[ ! -d $1 ]]
then
echo "$1 : directory expected";
exit 1;
fi
if [[ -n $2 && -f $2 ]]
then
optpisa="--css $2";
fi
if [[ -n $3 ]]
then
optprinter="-h $3";
fi
if [[ -n $4 ]]
then
optprinter="$optprinter -d $4";
fi
for i in $1/*.html
do
xhtml2pdf $optpisa $i;
done
if [[ -n $optprinter ]]
then
lp $optprinter $1/*.pdf;
fi
tar cvfzP $1`date "+%Y%m%d"`.tar.gz $1/*.pdf;