-
Notifications
You must be signed in to change notification settings - Fork 0
/
cftools.sh
executable file
·74 lines (63 loc) · 1.38 KB
/
cftools.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# $Id: cftools.sh 666 2009-01-26 15:32:17Z rybach $
if [ ${CFQ_INCLUDED:-0} -ne 1 ]; then # prevent multiple inclusion
# cache-manager directory
CFQ_BASEDIR=/u/rybach/apps/cache-manager
# cache manager client
CFQ_CMCLIENT=${CFQ_BASEDIR}/cf
# set prepare mode off
CFQ_PREPARE=0
CFQ_INCLUDED=1
function cf()
{
if [ $CFQ_PREPARE -eq 1 ]; then
cfq_add_file $*
else
$CFQ_CMCLIENT $*
fi
}
function cf_exec()
{
if [ $CFQ_PREPARE -eq 1 ]; then
cfq_log "prepare mode: ignoring $*"
else
$*
fi
}
function cfq_log()
{
echo "CFQ LOG: $*" > /dev/stderr
}
function cfq_error()
{
echo "CFQ ERROR: $*" > /dev/stderr
exit 1
}
function cfq_add_file()
{
local opt
local cfopt
[ -n $CFQ_FILES ] || cfq_error "CFQ_FILES not set"
[ -n $CFQ_CACHE ] || cfq_error "CFQ_CACHE not set"
grep -e "^${!#}\$" $CFQ_CACHE
if [ $? -eq 0 ]; then
echo ${!#}
return
fi
cfq_log "checking $*"
for opt in $*; do
if [ $opt = -cp ]; then
cfq_log "cm-client copy action. -> ignored"
return
fi
done
expr match "${!#}" "\(.*${CFQ_DETECT_ID}.*\)" > /dev/null
if [ $? -eq 0 ]; then
cfq_log dependency on SGE_TASK_ID detected
echo 1 > $CFQ_NEEDTASKID
return
fi
$CFQ_CMCLIENT -l $* >> $CFQ_FILES
echo ${!#} >> $CFQ_CACHE
echo ${!#}
}
fi # EOF