-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshim_copy_flatten.sh
executable file
·143 lines (115 loc) · 2.78 KB
/
shim_copy_flatten.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
VERSION=`head -1 debian/changelog| sed 's/.*(//' | sed 's/).*//'`
MAJOR_VERSION=`echo \"${VERSION}\" | sed 's+\..*++g'`
# job step 0 - setup...
if [ ! -d ~/test ]; then
mkdir ~/test
fi
echo "ignore rm errors.. cleaning before start"
rm -rf shim_dirA/ shim_dirB/
for d in shim_dirA shim_dirB shim_dirC; do
if [ -d $d ]; then
echo "ignore rm -rf $d"
rm -rf $d
fi
mkdir $d
done
# symlink between directories out of tree.
ln -s ../shim_dirA/dirthree shim_dirC/thedir
mkdir -p ~/.config/sr3/subscribe
mkdir -p ~/.config/sr3/cpost
#cp local_copy.conf ~/.config/sr3/subscribe
if [ ! "${BROKER}" ]; then
BROKER=amqp://tfeed@localhost
fi
if [ ! "${EXCHANGE}" ]; then
EXCHANGE=xs_feed
fi
cat >~/.config/sr3/subscribe/local_copy.conf <<EOT
broker ${BROKER}
exchange ${EXCHANGE}
messageDebugDump on
topicPrefix v03.post
subtopic #
logReject on
logLevel debug
debug True
expire 10m
nodupe_ttl 0
logMessageDump on
callback log
batch 1
mirror True
flatten _
directory `pwd`/shim_dirB
accept .*`realpath .`/.*
accept .*`realpath ${HOME}/test`/.*
reject .*
#accept .*
EOT
#cp local_post.conf ~/.config/sr3/cpost
cat >~/.config/sr3/cpost/local_post.conf <<EOT
post_broker ${BROKER}
post_exchange ${EXCHANGE}
vip 127.0.0.1
realpath off
logReject on
logLevel debug
debug True
exchangeDeclare True
#integrity none
shim_post_minterval 10
#shim_skip_parent_open_files
#shim_post_once
#shim_defer_posting_to_exit
realpathFilter on
realpathPost on
realpathAdjust -1
expire 1d
nodupe_ttl 0
header toto=pig
events modify,link,delete,mkdir,rmdir
post_baseUrl file:`pwd`/shim_dirA
post_topicPrefix v03.post
accept `realpath .`/.*
accept `realpath ${HOME}/test`/.*
reject .*
EOT
sr3 declare cpost/local_post
sr3 declare subscribe/local_copy
sr3 start subscribe/local_copy.conf
export SR_POST_CONFIG=local_post.conf
if [ "${SYSTEM_SHIM_TEST}" ]; then
export LD_PRELOAD=libsr3shim.so.${VERSION}
else
export LD_PRELOAD=`pwd`/libsr3shim.so.${VERSION}
export LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH}
fi
export SR_SHIMDEBUG=99
if [ "${KNOWN_REDIRECTION_BUG}" ]; then
bash ./shim_copy_post.sh &
else
./shim_copy_post.sh &
fi
unset SR_POST_CONFIG
unset SR_SHIMDEBUG
unset LD_PRELOAD
wait
# job step 2... copy.
sleepytime=15
echo "waiting ${sleepytime} seconds for copies to complete"
sleep ${sleepytime}
sr3 remove cpost/local_post.conf
sr3 stop subscribe/local_copy.conf
sr3 remove subscribe/local_copy.conf
echo "#test 0 comment comparing trees"
cd shim_dirA
find -H . -type f | xargs md5sum >../dirA.sums
cd ../shim_dirB
find -H . -type f | xargs md5sum >../dirB.sums
cd ..
diffs="`diff dirA.sums dirB.sums| wc -l`"
if [ "${diffs}" -eq 0 ]; then
echo "RESULT: Good! trees the same"
else
echo "RESULT: BAD trees have $diffs differences"
fi