1 |
ccflib |
1.1 |
#!/usr/local/bin/bash |
2 |
|
|
# |
3 |
|
|
# Giuseppe Vacanti, January 2000 |
4 |
|
|
# |
5 |
|
|
# + fetch CCF deliveries from the ftp site |
6 |
|
|
# + perform basic checks on the packages |
7 |
|
|
# + move them to accept/reject directory |
8 |
|
|
# |
9 |
|
|
# Exit codes (<0 informational) |
10 |
|
|
# -1 (255): no new CCF deliveries |
11 |
|
|
# |
12 |
|
|
# $Id: getdeliveries,v 1.4 2000/08/28 12:27:27 ccflib Exp $ |
13 |
|
|
|
14 |
|
|
|
15 |
|
|
cleanup () { |
16 |
|
|
cd ~ |
17 |
|
|
/bin/rm -fr $tmpdir |
18 |
|
|
} |
19 |
|
|
|
20 |
|
|
me=`basename $0` |
21 |
|
|
##echo $me running at `date` |
22 |
|
|
|
23 |
|
|
server=astro |
24 |
|
|
uploaddir=/usr4/users/ftp/pub/ccflib/private/incoming |
25 |
|
|
pkgdir=~/deliveries/packages |
26 |
|
|
builtdir=~/deliveries/built |
27 |
|
|
rejdir=~/deliveries/rejected |
28 |
|
|
tmpdir=~/tmp/tmp$$ |
29 |
|
|
logfile=~/deliveries/DELIVERY_LOG |
30 |
|
|
|
31 |
|
|
trap cleanup EXIT |
32 |
|
|
|
33 |
|
|
mkdir -p $tmpdir $pkgdir $rejdir |
34 |
|
|
cd $pkgdir |
35 |
|
|
DATE=`date '+%Y%m%d'` |
36 |
|
|
|
37 |
|
|
rcp -r gvacanti@$server:$uploaddir/* $tmpdir/ 2> /dev/null |
38 |
|
|
|
39 |
|
|
cd $tmpdir |
40 |
|
|
|
41 |
|
|
flist=`ls *.tgz 2> /dev/null` |
42 |
|
|
if [ -z "$flist" ] ; then |
43 |
|
|
## echo No new CCF deliveries. |
44 |
|
|
exit -1 |
45 |
|
|
fi |
46 |
|
|
|
47 |
|
|
for p in *.tgz |
48 |
|
|
do |
49 |
|
|
echo New CCF delivery $p |
50 |
|
|
|
51 |
|
|
trouble=0 |
52 |
|
|
discard=1 |
53 |
|
|
|
54 |
|
|
pack_name=`basename $p | sed -e 's/-[^-]*\.tgz//'` |
55 |
|
|
pack_vers=`basename $p | sed -e 's/^.*-//' -e 's/\.tgz//'` |
56 |
|
|
pack_md5=`md5sum $p | awk '{print $1}'` |
57 |
|
|
|
58 |
|
|
if [ -e $pkgdir/$p -o -e $builtdir/$p ] ; then |
59 |
|
|
echo ERROR: $p - already delivered |
60 |
|
|
trouble=1 |
61 |
|
|
else |
62 |
|
|
|
63 |
|
|
tar xzf $p |
64 |
|
|
if [ $? -ne 0 ] ; then |
65 |
|
|
echo ERROR: $p ignored - may still be uploading |
66 |
|
|
discard=0 |
67 |
|
|
else |
68 |
|
|
echo Package $pack_name $pack_vers |
69 |
|
|
|
70 |
|
|
cd $pack_name |
71 |
|
|
|
72 |
|
|
version=`cat VERSION` || discard=1 |
73 |
|
|
cd .. |
74 |
|
|
rm -fr $pack_name |
75 |
|
|
fi |
76 |
|
|
fi |
77 |
|
|
|
78 |
|
|
if [ $trouble -ne 0 ] ; then |
79 |
|
|
echo ERROR: $p is rejected |
80 |
|
|
mv -f $p $rejdir |
81 |
|
|
echo $pack_md5 $DATE $p " - REJECTED" >> $logfile |
82 |
|
|
else |
83 |
|
|
echo $p is accepted |
84 |
|
|
mv -f $p $pkgdir |
85 |
|
|
echo $pack_md5 $DATE $p >> $logfile |
86 |
|
|
fi |
87 |
|
|
|
88 |
|
|
if [ $discard -eq 1 ] ; then |
89 |
|
|
echo $p removed from upload area |
90 |
|
|
rsh -l gvacanti $server "/bin/rm -f $uploaddir/$p" |
91 |
|
|
fi |
92 |
|
|
|
93 |
|
|
done |