Bug 11401: QA followup
[koha.git] / misc / cronjobs / printoverdues.sh
1 #!/bin/bash
2
3 print_usage(){
4     echo "$0 : generates PDF files from html files in directorys and prints them";
5     echo "usage :";
6     echo "$0 directory [css [printer_host [printername]]]"
7     echo " - directory      directory to use to apply html2pdf transform";
8     echo " - css            css file to apply to html ";
9     echo " - printer_host   Network Name or IP of the printer (port possibly included) ";
10     echo " - printer_name   printername ";
11     echo "Note that css printerhost and printername are optional parameters ";
12     echo "Note that this script uses xhtml2pdf command ";
13     echo "    xhtml2pdf command comes with pisa (a python library)
14               To install you need setuptools library for python
15               then type easy_install pisa ";
16
17     exit 1;
18 }
19 if [ $# -lt 1 ]
20 then
21     print_usage
22 fi
23 if [[ ! -d $1  ]]
24 then
25     echo "$1 : directory expected";
26     exit 1;
27 fi
28 if [[ -n $2 && -f $2 ]]
29 then
30     optpisa="--css $2";
31 fi
32 if [[ -n $3 ]]
33 then
34     optprinter="-h $3";
35 fi
36 if [[ -n $4 ]]
37 then
38     optprinter="$optprinter -d $4";
39 fi
40 for i in $1/*.html
41 do
42     xhtml2pdf $optpisa  $i;
43 done
44
45 if [[ -n $optprinter ]]
46 then
47     lp $optprinter  $1/*.pdf;
48 fi
49
50 tar cvfzP $1`date "+%Y%m%d"`.tar.gz  $1/*.pdf;