Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
[kivitendo-erp.git] / scripts / build_doc.sh
1 #!/bin/bash
2
3 # Usage:
4 #   cd /path/to/lx-office
5 #   ./scripts/build_doc.sh
6
7 set -e
8
9 if [[ ! -d doc ]]; then
10   echo "Please run this from the installation directory."
11   exit 1
12 fi
13
14 html=1
15 pdf=1
16
17 if [[ ! -z $1 ]] ; then
18   html=0
19   pdf=0
20   while [[ ! -z $1 ]] ; do
21     case $1 in
22       html) html=1 ;;
23       pdf)  pdf=1  ;;
24       *)
25         echo "Unknown parameter $1"
26         exit 1
27         ;;
28     esac
29
30     shift
31   done
32 fi
33
34 dobudish=$(ls -d doc/build/dobudish* 2> /dev/null)
35
36 if [[ -z $dobudish ]] || [[ ! -d ${dobudish} ]]; then
37   echo "There's no dobudish directory inside doc/build."
38   exit 1
39 fi
40
41 cd ${dobudish}
42
43 base=documents/dokumentation
44 if [[ ! -d $base ]]; then
45   ./generator.sh dokumentation create book
46 fi
47
48 input=${base}/input
49 output=${base}/output
50 custom=${base}/custom-cfg
51
52 rm -rf ${input} ${custom}
53 mkdir ${input} ${input}/copy_to_output ${custom}
54
55 cp ../../dokumentation.xml ${input}/
56 cp -R ../../images ${input}/copy_to_output/
57 cp -R ../custom-cfg/* ${custom}/
58
59 if [[ $pdf = 1 ]] ; then
60   ./generator.sh dokumentation pdf
61   cp ${output}/pdf/dokumentation.pdf ../../
62 fi
63
64 if [[ $html = 1 ]]; then
65   ./generator.sh dokumentation html
66   rm -rf ../../html
67   mkdir ../../html
68   cp -R ${output}/html ../../
69 fi