-
Notifications
You must be signed in to change notification settings - Fork 12
/
prePublish.csh
executable file
·94 lines (80 loc) · 2.53 KB
/
prePublish.csh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/csh -f
# It's a cronjob that check if a repo has changed, and compile the PDF in case
#
# possible util: set gcheck = `git whatchanged -n 1 | grep "\t$d\/"`
#
# Crontab command for every 10 minutes compilation:
# #*/10 * * * * /opt/projects/clas12Nim/prePublish.csh >& ~/error.log
#
set path = (/usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/TeX/texbin /opt/X11/bin /Library/Frameworks/Mono.framework/Versions/Current/Commands /Users/ungaro/myenv)
set currentDir = /opt/projects/clas12Nim
cd $currentDir
set detectors = (`ls | grep -v \.csh | grep -v \.sty | grep -v \.md | grep -v \.txt | grep -v \.log | grep -v template `)
echo
echo All detectors: $detectors
set newLog = pull.log
# keeping all pulls log.
set nlogs = 0
if ( -f pull_1.log) then
set nlogs = `ls pull_*.log | wc | awk '{print $1}'`
@ nlogs += 1
endif
# uncomment to activate history
# set newLog = pull_$nlogs".log"
rm -f $newLog
git pull > $newLog
# chacking which detector was changed
rm -f detectorChanged.txt ; touch detectorChanged.txt
foreach d ($detectors)
set gcheck = `cat $newLog | grep " $d\/"`
if(`echo $gcheck` != "" || $1 == "all") then
echo $d >> detectorChanged.txt
endif
end
set detChanged = `cat detectorChanged.txt`
if($1 != "" && $1 != "all") then
set detChanged = $1
endif
echo
echo "List of detector to publish: "$detChanged
echo
foreach d ($detChanged)
cd $currentDir
cd $d
rm -f compile.log
echo > compile.log
echo Detector: $d >> compile.log
echo >> compile.log
set toPublish = $d".pdf"
if ($d != "magnets") then
# make sure the style files are common
cp ../*.sty .
echo Compiling with `which scons` >> compile.log
echo >> compile.log
scons
echo To Publish: $toPublish >> compile.log
ls -lrt >> compile.log
echo >> compile.log
endif
if ($d == "dc") then
set toPublish = dc12_nim.pdf
else if ($d == "beamline") then
set toPublish = beamline_nim.pdf
else if ($d == "ftof") then
set toPublish = ftof-nim.pdf
else if ($d == "ctof") then
set toPublish = ctof-nim.pdf
else if ($d == "rich") then
set toPublish = rich-nim.pdf
else if ($d == "reconstruction") then
set toPublish = recon-nim.pdf
endif
scp $toPublish ftp.jlab.org:/group/clas/www/clasweb/html/12gev/nims
echo $d published >> compile.log
echo >> compile.log
echo "Done. Check ~/error.log for cronjob errors." >> compile.log
echo >> compile.log
if ($d != "magnets") then
scons -c
endif
end