forked from elastic/logstash-forwarder
-
Notifications
You must be signed in to change notification settings - Fork 5
/
fetch.sh
executable file
·41 lines (35 loc) · 844 Bytes
/
fetch.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
#!/bin/sh
echo "$@"
set -- `getopt o: "$@"`
echo "$@"
while [ $# -gt 0 ] ; do
case "$1" in
-o)
OUTPUT=$2
shift
;;
--)
shift
break
;;
esac
shift
done
URL="$1"
echo "URL: $URL"
# If you need to pass any specific flags to any specific fetcher, set
# WGET_FLAGS, CURL_FLAGS, or GET_FLAGS in your environment accordingly.
if which wget > /dev/null 2>&1 ; then
# Check if wget is a shitty version
if ! wget -O /dev/null -q https://github.com/ ; then
WGET_FLAGS="${WGET_FLAGS} --no-check-certificate"
fi
exec wget $WGET_FLAGS -O "$OUTPUT" "$URL"
elif which curl > /dev/null 2>&1 ; then
exec curl $CURL_FLAGS -s -o "$OUTPUT" "$URL"
elif which GET > /dev/null 2>&1 ; then
exec GET $GET_FLAGS "$URL" > "$OUTPUT"
else
echo "no http download tool found. cannot fetch."
exit 1
fi