1 | #! /bin/sh |
---|
2 | #+ |
---|
3 | # |
---|
4 | # =============== |
---|
5 | # biblio_check.sh |
---|
6 | # =============== |
---|
7 | # |
---|
8 | # ------------------------ |
---|
9 | # check a biblio directory |
---|
10 | # ------------------------ |
---|
11 | # |
---|
12 | # SYNOPSIS |
---|
13 | # ======== |
---|
14 | # |
---|
15 | # ``biblio_check.sh -i biblio_dir -o dirout`` |
---|
16 | # |
---|
17 | # DESCRIPTION |
---|
18 | # =========== |
---|
19 | # |
---|
20 | # Lauch jabref on each individual file (bibtex convention syntax) of biblio_dir |
---|
21 | # |
---|
22 | # -i input directory |
---|
23 | # -o output directory |
---|
24 | # |
---|
25 | # Each file of the output directory is named after the bibtex file. |
---|
26 | # |
---|
27 | # ++ log file |
---|
28 | # |
---|
29 | # EXAMPLES |
---|
30 | # ======== |
---|
31 | # |
---|
32 | # To check the biblio of LOCEAN:: |
---|
33 | # |
---|
34 | # $ biblio_check.sh -i /tmp/locean_biblio_split/ -o /tmp/locean_biblio_check/ |
---|
35 | # |
---|
36 | # TODO |
---|
37 | # ==== |
---|
38 | # |
---|
39 | # |
---|
40 | # EVOLUTIONS |
---|
41 | # ========== |
---|
42 | # |
---|
43 | # $Id$ |
---|
44 | # |
---|
45 | # - fplod 20110301T100911Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
46 | # |
---|
47 | # * jaberef_dir=f(uname -s) |
---|
48 | # |
---|
49 | # - fplod 20091019T085114Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
50 | # |
---|
51 | # * creation |
---|
52 | # |
---|
53 | #- |
---|
54 | # |
---|
55 | system=$(uname) |
---|
56 | case "${system}" in |
---|
57 | AIX|IRIX64) |
---|
58 | echo " www : no specific posix checking" |
---|
59 | ;; |
---|
60 | *) |
---|
61 | set -o posix |
---|
62 | ;; |
---|
63 | esac |
---|
64 | # |
---|
65 | command=$(basename ${0}) |
---|
66 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
67 | # |
---|
68 | usage=" Usage : ${command} -i biblio_dir -o dirout" |
---|
69 | # |
---|
70 | # default |
---|
71 | jabref_version="2.6" |
---|
72 | jabref_dir="/usr/home/incas/francoise/jabref-${jabref_version}_$(hostname)/" |
---|
73 | case "$(uname -s)" in |
---|
74 | Darwin) |
---|
75 | jabref_dir=${jabref_dir}"JabRef.app/Contents/Resources/Java/" |
---|
76 | ;; |
---|
77 | Linux) |
---|
78 | ;; |
---|
79 | *) |
---|
80 | echo "${command} : eee : unknown system $(uname -s)" |
---|
81 | ;; |
---|
82 | esac |
---|
83 | # |
---|
84 | tmpdir=/tmp/${LOGNAME}/gtbiblio |
---|
85 | mkdir -p /tmp/${LOGNAME}/gtbiblio/ |
---|
86 | # artificial header of jabref file to enforce encoding |
---|
87 | { |
---|
88 | echo "% This file was articifialy created for JabRef ${jabref_version}." |
---|
89 | echo "% Encoding: ISO8859_1" |
---|
90 | echo " " |
---|
91 | } > ${tmpdir}/header_jabref |
---|
92 | # |
---|
93 | minargcount=4 |
---|
94 | if [ ${#} -lt ${minargcount} ] |
---|
95 | then |
---|
96 | echo "eee : ${command} : not enought arguments" |
---|
97 | echo "${usage}" |
---|
98 | exit 1 |
---|
99 | fi |
---|
100 | # |
---|
101 | set +u |
---|
102 | while [ ! -z "${1}" ] |
---|
103 | do |
---|
104 | case ${1} in |
---|
105 | -i) |
---|
106 | biblio_dir=${2} |
---|
107 | shift |
---|
108 | ;; |
---|
109 | -o) |
---|
110 | dirout=${2%/} |
---|
111 | shift |
---|
112 | ;; |
---|
113 | -h) |
---|
114 | echo "${usage}" |
---|
115 | exit 0 |
---|
116 | ;; |
---|
117 | *) |
---|
118 | # anything else |
---|
119 | echo "eee : unknown option ${1}" |
---|
120 | echo "eee : ${usage}" |
---|
121 | exit 1 |
---|
122 | ;; |
---|
123 | esac |
---|
124 | # next flag |
---|
125 | shift |
---|
126 | done |
---|
127 | # |
---|
128 | set -u |
---|
129 | # |
---|
130 | # check for biblio_dir |
---|
131 | if [ ! -d ${biblio_dir} ] |
---|
132 | then |
---|
133 | echo "eee : ${command} : ${biblio_dir} not accessible" |
---|
134 | exit 1 |
---|
135 | fi |
---|
136 | # |
---|
137 | # check for dirout |
---|
138 | # the idea is to prevent unwanted overwrite |
---|
139 | if [ -d ${dirout} ] |
---|
140 | then |
---|
141 | echo "eee : ${command} : ${dirout} already exist" |
---|
142 | exit 1 |
---|
143 | else |
---|
144 | mkdir -p ${dirout} |
---|
145 | if [ ${?} -ne 0 ] |
---|
146 | then |
---|
147 | echo "eee : ${command} : cannot create ${dirout}" |
---|
148 | exit 1 |
---|
149 | fi |
---|
150 | fi |
---|
151 | # |
---|
152 | # loop on each file of ${biblio_dir} ie files to be checkted |
---|
153 | format=locean_listrefs |
---|
154 | for bibtex_file in ${biblio_dir}/*.bib |
---|
155 | do |
---|
156 | echo "bibtex_file = ${bibtex_file}" |
---|
157 | filein=${tmpdir}/$(basename ${bibtex_file}) |
---|
158 | cat ${tmpdir}/header_jabref ${bibtex_file} > ${filein} |
---|
159 | output_file=${dirout}/$(basename ${bibtex_file} .bib).html |
---|
160 | java -jar ${jabref_dir}/JabRef-${jabref_version}.jar -n true \ |
---|
161 | -p ./jabref.preferences.xml \ |
---|
162 | --output ${output_file},${format} \ |
---|
163 | ${filein} |
---|
164 | jabref_status=${?} |
---|
165 | if [ ${jabref_status} -ne 0 ] |
---|
166 | then |
---|
167 | echo "eee : ${command} : pb with jabref export ${bibtex_file}" |
---|
168 | exit 1 |
---|
169 | fi |
---|
170 | done |
---|
171 | # |
---|
172 | echo "iii : ${biblio_dir} is checked in ${dirout}" |
---|
173 | # |
---|
174 | # clean |
---|
175 | #++rm -rf ${tmpdir} |
---|
176 | # end |
---|
177 | exit 0 |
---|