701768bcda2591a6dd08dfa6de688322a276fc29
[releng.git] / jjb / genesis / build-docu.sh
1 #!/bin/bash
2 project="genesis"
3 export PATH=$PATH:/usr/local/bin/
4
5 files=()
6 while read -r -d ''; do
7       files+=("$REPLY")
8 done < <(find . -type f -iname '*.rst' -print0)
9
10 for file in "${{files[@]}}"; do
11
12   file_cut="${{file%.*}}"
13   gs_cp_folder="$(echo "$file"| cut -d "/" -f2,3)"
14
15   html_file=$file_cut".html"
16
17     echo "rst2html $file"
18     rst2html $file | gsutil cp -L gsoutput.txt - \
19     gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$html_file")
20     gsutil setmeta -h "Content-Type:text/html" \
21                    -h "Cache-Control:private, max-age=0, no-transform" \
22                    gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$html_file")
23     cat gsoutput.txt
24     rm -f gsoutput.txt
25
26   pdf_file="$file_cut"".pdf"
27
28     echo "rst2pdf $file"
29     rst2pdf "$file" -o - | gsutil cp -L gsoutput.txt - \
30     gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$pdf_file")
31     gsutil setmeta -h "Content-Type:application/pdf" \
32                    -h "Cache-Control:private, max-age=0, no-transform" \
33                    gs://artifacts.opnfv.org/"$project"/"$gs_cp_folder"/$(basename "$pdf_file")
34     cat gsoutput.txt
35     rm -f gsoutput.txt
36
37 done
38
39 images=()
40 while read -r -d ''; do
41         images+=("$REPLY")
42 done < <(find * -type f \( -iname \*.jpg -o -iname \*.png \) -print0)
43
44 for img in "${{images[@]}}"; do
45
46         # uploading found images
47         echo "uploading $img"
48         cat "$img" | gsutil cp -L gsoutput.txt - \
49         gs://artifacts.opnfv.org/"$project"/"$img"
50         gsutil setmeta -h "Content-Type:image/jpeg" \
51                         -h "Cache-Control:private, max-age=0, no-transform" \
52                         gs://artifacts.opnfv.org/"$project"/"$img"
53         cat gsoutput.txt
54         rm -f gsoutput.txt
55
56 done
57