-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwatch_csl-orig.sh
executable file
·55 lines (39 loc) · 1.65 KB
/
watch_csl-orig.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#$1 abs_path_to csl-orig (e.g. '/opt/cdsd/csl-orig/v02/')
#$2 abs_path_to csl-pywork bash files (in csl-pywork e.g. '/opt/cdsd/csl-pywork/v02/'
#$3 abs_path_to csl-pywork_output e.g. '/opt/cdsd/csl-generated-pywork/'
#$4 abs_path_to_generated_kosh_files e.g. '/opt/cdsd/csl-generated-kosh/'
#$5 abs_path to conda.sh e.g. '/home/me/miniconda3/etc/profile.d/conda.sh'
#$6 abs_path_to_logfile e.g. '/opt/cdsd/csl-logs/logs.txt'
source $5
conda activate csl-kosh
inotifywait -m -r ${1} -e close_write|
while read path action file; do
dict_id=`basename "$path"`
echo "$dict_id has been modified"
cd ${2}
echo "current dir $PWD"
# generate_orig.py
python generate.py "${dict_id}" inventory_orig.txt _ "${1}${dict_id}" ${3}${dict_id}
echo "${3}${dict_id} has been generated"
# generate_pywork.py
python generate.py "${dict_id}" inventory.txt makotemplates distinctfiles/${dict_id} ${3}${dict_id}
# go to the generated local instance
cd ${3}${dict_id}/pywork
echo "regenerate ${dict_id} headwords"
sh redo_hw.sh
echo "regenerate ${dict_id}.xml files"
sh redo_xml.sh
# mkdir if not available
mkdir -p ${4}${dict_id}
# copy xml file fo csl-kosh_generated
cp ${dict_id}.xml ${4}${dict_id}/${dict_id}.xml
d_hour=$(date +"%T")
d_date=$(date +"%F")
echo "${d_date} ${d_hour} ${dict_id}.xml copied to ${4}${dict_id}"
log_file=$6
if [ ! -f "$6" ]; then
mkdir -p "`dirname \"$6\"`" 2>/dev/null
fi
echo "${d_date} ${d_hour} ${dict_id}.xml" >> ${log_file}
done