| 1 |
#! /usr/bin/env bash |
| 2 |
|
| 3 |
# $Header: /u/gcmpack/mitgcm.org/scripts/daily_tarfile,v 1.6 2016/12/08 14:35:27 jmc Exp $ |
| 4 |
|
| 5 |
# download the source code and make a tar file |
| 6 |
|
| 7 |
#export CVSROOT=/u/gcmpack |
| 8 |
#- to allow users to use cvs update/diff on their untar version of the code, |
| 9 |
# switch to pserver method (stored everywhere in the tree in dirs CVS/Root) |
| 10 |
export CVSROOT=':pserver:cvsanon@mitgcm.org:/u/gcmpack' |
| 11 |
|
| 12 |
umask 0002 |
| 13 |
|
| 14 |
echo 'Changing dir. to /u/u0/httpd/html/download/daily_snapshot' |
| 15 |
cd /u/u0/httpd/html/download/daily_snapshot |
| 16 |
outp=$? |
| 17 |
if test $outp != 0 ; then |
| 18 |
echo " Error in cd : $outp" |
| 19 |
exit 1 |
| 20 |
fi |
| 21 |
test -e MITgcm && rm -rf MITgcm |
| 22 |
|
| 23 |
echo -n 'Checking out MITgcm ... ' |
| 24 |
cvs -q co -P MITgcm > /dev/null |
| 25 |
outp=$? |
| 26 |
if test $outp = 0 ; then |
| 27 |
echo 'Done!' |
| 28 |
else |
| 29 |
echo " Error in cvs checkout: $outp" |
| 30 |
exit 2 |
| 31 |
fi |
| 32 |
#chgrp gcmpack MITgcm |
| 33 |
#chmod 775 MITgcm |
| 34 |
|
| 35 |
rm -f MITgcm_ss_* |
| 36 |
tname='MITgcm_ss_'`date +%Y%m%d`'.tar.gz' |
| 37 |
|
| 38 |
echo -n 'Creating the tar file ... ' |
| 39 |
tar -czf $tname ./MITgcm |
| 40 |
#- should check if successful, it not -> exit 3 |
| 41 |
echo 'Done!' |
| 42 |
|
| 43 |
#chmod 664 $tname |
| 44 |
ls -l $tname |
| 45 |
|
| 46 |
#-- test for new checkpoint |
| 47 |
cd .. |
| 48 |
version_file="daily_snapshot/MITgcm/doc/tag-index" |
| 49 |
backupDir="other_checkpoints" |
| 50 |
if test -f $version_file ; then |
| 51 |
thischkpt=`awk '/^checkpoint/{print $1; exit}' $version_file` |
| 52 |
short=`echo $thischkpt | sed 's/checkpoint/c/'` |
| 53 |
chkptar="MITgcm_$short" |
| 54 |
if test -f $chkptar.tar.gz ; then |
| 55 |
echo "tar file ($chkptar) exist for current tag: $thischkpt" |
| 56 |
else |
| 57 |
echo -n "Checking out $thischkpt ..." |
| 58 |
rm -f checkout.out checkout.err |
| 59 |
cvs -q co -P -d $chkptar -r $thischkpt MITgcm 1> checkout.out 2> checkout.err |
| 60 |
outp=$? |
| 61 |
if test $outp != 0 ; then |
| 62 |
echo " Error in cvs checkout: $outp" |
| 63 |
cat checkout.err |
| 64 |
exit 4 |
| 65 |
fi |
| 66 |
echo -n " ; making tar file ... " |
| 67 |
rm -f checkout.out checkout.err |
| 68 |
tar -cf $chkptar.tar $chkptar |
| 69 |
outp=$? |
| 70 |
if test $outp != 0 ; then |
| 71 |
echo " Error in tar command: $outp" |
| 72 |
exit 5 |
| 73 |
else |
| 74 |
echo " Done" |
| 75 |
rm -r -f $chkptar |
| 76 |
fi |
| 77 |
gzip $chkptar.tar |
| 78 |
ls -l $chkptar.tar* |
| 79 |
#-- move previous tar file to backupDir |
| 80 |
listTar=`ls MITgcm_c*.tar.gz` |
| 81 |
if test -d $backupDir ; then |
| 82 |
for xx in $listTar ; do |
| 83 |
if test $xx != $chkptar.tar.gz ; then |
| 84 |
if test -f other_checkpoints/$xx ; then |
| 85 |
echo "error: $backupDir/$xx already exist" |
| 86 |
else |
| 87 |
echo " mv $xx $backupDir" |
| 88 |
mv $xx $backupDir |
| 89 |
fi |
| 90 |
fi |
| 91 |
done |
| 92 |
else |
| 93 |
echo " no dir: $backupDir" |
| 94 |
exit 6 |
| 95 |
fi |
| 96 |
fi |
| 97 |
fi |