-
Notifications
You must be signed in to change notification settings - Fork 9
/
_updatePublisher.sh
executable file
·103 lines (89 loc) · 2.62 KB
/
_updatePublisher.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
#!/bin/bash
pubsource=https://github.com/HL7/fhir-ig-publisher/releases/latest/download/
publisher_jar=publisher.jar
dlurl=$pubsource$publisher_jar
input_cache_path=$PWD/input-cache/
scriptdlroot=https://raw.githubusercontent.com/HL7/ig-publisher-scripts/main
update_bat_url=$scriptdlroot/_updatePublisher.bat
gen_bat_url=$scriptdlroot/_genonce.bat
gencont_bat_url=$scriptdlroot/_gencontinuous.bat
gencont_sh_url=$scriptdlroot/_gencontinuous.sh
gen_sh_url=$scriptdlroot/_genonce.sh
update_sh_url=$scriptdlroot/_updatePublisher.sh
skipPrompts=false
FORCE=false
if ! type "curl" > /dev/null; then
echo "ERROR: Script needs curl to download latest IG Publisher. Please install curl."
exit 1
fi
while [ "$#" -gt 0 ]; do
case $1 in
-f|--force) FORCE=true ;;
-y|--yes) skipPrompts=true ; FORCE=true ;;
-s|--skip) skipPrompts=true ;;
*) echo "Unknown parameter passed: $1. Exiting"; exit 1 ;;
esac
shift
done
echo "Checking internet connection"
case "$OSTYPE" in
linux-gnu* ) ping tx.fhir.org -4 -c 1 -w 1000 >/dev/null ;;
darwin* ) ping tx.fhir.org -c 1 >/dev/null ;;
*) echo "unknown: $OSTYPE"; exit 1 ;;
esac
if [ $? -ne 0 ] ; then
echo "Offline (or the terminology server is down), unable to update. Exiting"
exit 1
fi
if [ ! -d "$input_cache_path" ] ; then
if [ $skipPrompts != true ]; then
echo "$input_cache_path does not exist"
message="create it?"
read -r -p "$message" response
else
response=y
fi
fi
if [[ $response =~ ^[yY].*$ ]] ; then
mkdir ./input-cache
fi
publisher="$input_cache_path$publisher_jar"
if test -f "$publisher" ; then
echo "IG Publisher FOUND in input-cache"
jarlocation="$publisher"
jarlocationname="Input Cache"
upgrade=true
else
publisher="../$publisher_jar"
upgrade=true
if test -f "$publisher"; then
echo "IG Publisher FOUND in parent folder"
jarlocation="$publisher"
jarlocationname="Parent Folder"
upgrade=true
else
echo "IG Publisher NOT FOUND in input-cache or parent folder"
jarlocation=$input_cache_path$publisher_jar
jarlocationname="Input Cache"
upgrade=false
fi
fi
if [[ $skipPrompts == false ]]; then
if [[ $upgrade == true ]]; then
message="Overwrite $jarlocation? (Y/N) "
else
echo Will place publisher jar here: "$jarlocation"
message="Ok (enter 'y' or 'Y' to continue, any other key to cancel)?"
fi
read -r -p "$message" response
else
if [[ $FORCE == true ]]; then
response=y
fi
fi
if [[ $response =~ ^[yY].*$ ]]; then
echo "Downloading most recent publisher to $jarlocationname - it's ~100 MB, so this may take a bit"
curl -L $dlurl -o "$jarlocation" --create-dirs
else
echo cancelled publisher update
fi