-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadassDownloadDirs.sh
executable file
·121 lines (106 loc) · 3.39 KB
/
adassDownloadDirs.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
#!/bin/bash
download_dir () {
SRC_DIR="vault:adass2022/uploads/$1"
DEST_DIR="$HOME/work/git/ADASSProceedings2022/papers_temp/$1"
echo $DEST_DIR
if [ ! -d "$DEST_DIR" ]
then
mkdir $DEST_DIR
else
rm -rf $DEST_DIR/*
fi
# Handle special cases of bundle files mixed in with single files when date ordered.
if [ $1 == "P28" ] ; then
echo " copy bundle P28_v4.tar"
vcp $SRC_DIR/P28_v4.tar $DEST_DIR
NO_FILES=false
elif [ $1 = "P10" ] ; then
echo " copy bundle P10_v2.tar.gz"
vcp $SRC_DIR/P10_v2.tar.gz $DEST_DIR
NO_FILES=false
elif [ $1 == "P04" ] ; then
echo " copy bundle P04.tar.gz"
vcp $SRC_DIR/P04.tar.gz $DEST_DIR
NO_FILES=false
elif [ $1 == "P03" ] ; then
echo " copy bundle P03.tar.gz"
vcp $SRC_DIR/P03.tar.gz $DEST_DIR
NO_FILES=false
elif [ $1 == "C21" ] ; then
echo " copy bundle C21.tar.gz"
vcp $SRC_DIR/C21.tar.gz $DEST_DIR
NO_FILES=false
else
#
# Copy date-ordered files. Do not copy files created by the ADASS account
# adass2022_b57 and any Powerpoint, PDF, MP4 or AVI files that may have
# been uploaded.
#
NO_FILES=true
FIRST_FILE=true
BUNDLE_COPIED=false
TIME_ORDERED_FILE_LIST=$(vls -lt $SRC_DIR \
| grep -v " adass2022_b57" \
| grep -v '.pptx' \
| grep -v '.mp4' \
| grep -v '.avi' \
| grep -iv 'slides' \
| grep -iv 'sliides' \
| grep -iv 'poster' \
| grep -iv 'lightning' \
| grep -v "$1.pdf" \
| grep -v 'ri-carbon-footprint-adass2022.pdf' \
| grep -v 'copyrightform_I08_OMullane.pdf' \
| awk '{print $NF}' )
for FILE in $TIME_ORDERED_FILE_LIST
do
#
# If the first/most recent file is a tar, zip, rar or 7z file, download only it and not any others.
#
if ( [[ "$FILE" == *".tar.gz" ]] || [[ "$FILE" == *".tar" ]] || [[ "$FILE" == *".zip" ]] || [[ "$FILE" == *".rar" ]] || [[ "$FILE" == *".7z" ]] ); then
BUNDLE_FILE=true
else
BUNDLE_FILE=false
fi
if ( [ "$BUNDLE_FILE" = true ] ) ; then
if ( [ "$FIRST_FILE" = true ] ) ; then
echo " copy bundle $FILE"
vcp $SRC_DIR/$FILE $DEST_DIR/$FILE
NO_FILES=false
BUNDLE_COPIED=true
elif [ "$BUNDLE_COPIED" = true ] ; then
echo " warning: not copying older bundle $FILE"
else
echo " warning: bundle $FILE has no corresponding newer bundle"
fi
elif $BUNDLE_COPIED ; then
echo " warning: not copying older file $FILE"
else
echo " copy $FILE"
vcp $SRC_DIR/$FILE $DEST_DIR/$FILE
NO_FILES=false
fi
FIRST_FILE=false
done
#
# If no files have been copied, delete the destination directory
#
if [ "$NO_FILES" = true ]
then
echo " Removing empty $DEST_DIR"
rmdir $DEST_DIR
fi
fi
}
DATE=`date "+%Y-%m-%dT%H:%M:%S"`
cadc-get-cert -n
if [ $# -eq 0 ]
then
DIRS=$(vls vault:adass2022/uploads)
else
DIRS="$@"
fi
for DIR in $DIRS
do
download_dir $DIR
done