-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfiji-archive-status.sh
More file actions
executable file
·67 lines (54 loc) · 1.72 KB
/
Copy pathfiji-archive-status.sh
File metadata and controls
executable file
·67 lines (54 loc) · 1.72 KB
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
#!/bin/bash
# Emits 'up-to-date' if a Fiji app bundle has been created since
# the most recent update to the core ImageJ/Fiji update sites,
# and 'update-needed' otherwise.
. "${0%/*}/common.include"
case "$track" in
latest) sites='sites.imagej.net/Fiji' ;;
stable) sites='update.imagej.net update.fiji.sc sites.imagej.net/Java-8' ;;
esac
DATE=date
if [ "$(uname)" = 'Darwin' ]
then
which gdate >/dev/null || {
echo 'This script requires GNU date, but macOS uses BSD date.'
echo "Please install GNU date via 'brew install coreutils'."
exit 1
}
DATE=gdate
fi
# -- helper methods --
# convert timestamp strings to numeric values for easier comparison
convert_time () {
datenum=$($DATE --date="$1" '+%s')
echo "$datenum"
}
# get the last modified date of a given url as seconds sinch the epoch
get_modified_date () {
result=$(curl -Ifs "$1" | grep '^Last-Modified:')
datestamp=${result#*, }
dateval=$(convert_time "$datestamp")
echo "$dateval"
}
# get the most recent modification date from among the core ImageJ/Fiji update sites
update_site_modified () {
update_site_times=()
for repo in $sites; do
dateval=$(get_modified_date "https://$repo/db.xml.gz")
update_site_times+=("$dateval")
done
# Just use the most recent modified date from among the update sites
sorted=($(printf "%s\n" ${update_site_times[@]} | sort -r))
echo "${sorted[0]}"
}
# get the most recent modification date of a selected fiji bundle
fiji_bundle_modified () {
dateval=$(get_modified_date "https://downloads.imagej.net/fiji/$track/$fiji_nojava.zip")
echo "$dateval"
}
# -- program entry point --
if [ "$(update_site_modified)" -gt "$(fiji_bundle_modified)" ]; then
echo 'update-needed'
else
echo 'up-to-date'
fi