-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdocker-entrypoint.sh
executable file
·72 lines (53 loc) · 1.86 KB
/
docker-entrypoint.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
#!/bin/bash
VPF_DATA_URL='https://bioinfo.uib.es/~recerca/VPF-Class/vpf-class-data.tar.gz'
VPF_DATA_PATH='/opt/vpf-tools/vpf-data'
download_vpf_class_data() {
mkdir -p "$VPF_DATA_PATH"
(
cd "$VPF_DATA_PATH";
curl "$VPF_DATA_URL" | tar --overwrite --no-same-owner --strip-components=1 -xzf -;
)
if [ $? != 0 ]
then
echo "Error downloading VPF data files."
else
[ "$VPF_TOOLS_CHMOD" == 0 ] || chmod -R a+rwX "$VPF_DATA_PATH"/*
touch "$VPF_DATA_PATH/last-update"
echo "Successfully updated VPF data files."
fi
}
check_and_update_vpf_class_data() {
if [ -n "$VPF_DATA_AUTOUPDATE" ] && [ "$VPF_DATA_AUTOUPDATE" == 0 ]
then
echo "VPF-Class data autoupdate is disabled."
elif [ ! -f "$VPF_DATA_PATH/last-update" ]
then
echo "VPF-Class data files not found, downloading"
download_vpf_class_data
else
local local_date
local_date="$(stat -c %Y "$VPF_DATA_PATH/last-update")"
if [ $? != 0 ]
then
echo "Error: Could not stat $VPF_DATA_PATH/index.yaml, but it is present. Do you have correct permissions?"
return 1
fi
local remote_date
remote_date="$(curl -s -v -X HEAD "$VPF_DATA_URL" 2>&1 | grep '^< Last-Modified: ')"
remote_date="${remote_date##< Last-Modified: }"
if [ $? != 0 ]
then
echo "Warning: Failed to test remote modification date from $VPF_DATA_URL. Overwriting"
download_vpf_class_data
elif [ "$(date -d "$remote_date" +%s)" -gt "$local_date" ]
then
echo "VPF-Class data files are outdated, updating"
download_vpf_class_data
else
echo "VPF-Class data files are up-to-date."
fi
fi
}
[ "$VPF_TOOLS_CHMOD" == 0 ] || umask 0000
check_and_update_vpf_class_data
"$@"