Add possibility to use curl instead of wget
Benjamin Renard

Benjamin Renard commited on 2017-04-24 12:51:36
Showing 1 changed files, with 22 additions and 5 deletions.

... ...
@@ -15,29 +15,33 @@ CHECK_URL=https://roundcube.net/download/
15 15
 DOWNLOAD=0
16 16
 DOWNLOAD_DIR=$RC_HOME/../upstream
17 17
 DONT_CHECK_SSL_CERT=0
18
+WGET_OPTS=""
19
+CURL_OPTS=""
18 20
 
19 21
 ### DO NOT MODIFY AFTER THIS LINE ###
20 22
 
21 23
 DEBUG=0
22 24
 NAGIOS=0
23 25
 UPGRADE=0
26
+CURL=0
24 27
 EXTRACT=0
25 28
 JUST_DISP=0
26 29
 JUST_AFTER_UPGRADE=0
27 30
 
28 31
 function usage() {
29
-	echo "Usage : $0 [-v] [-n] [-d] [-u]"
32
+	echo "Usage : $0 [-v] [-n] [-d] [-u] [-c]"
30 33
 	echo "  -v   Verbose mode"
31 34
 	echo "  -n   Nagios mode"
32
-	echo "  -S   Don't check SSL certificate"
35
+	echo "  -S   Don't check SSL certificate (Wget only)"
33 36
 	echo "  -d   Download new release"
34 37
 	echo "  -u   Upgrade installation"
38
+	echo "  -c   Use curl instead of wget"
35 39
 	echo "  -a   Just run after_upgrade function"
36 40
 	echo "  -j   Just display current stable version"
37 41
 	echo "  -h   Display this help"
38 42
 }
39 43
 
40
-while getopts ":dvnShuaj" opt; do
44
+while getopts ":dvnShucaj" opt; do
41 45
 	case $opt in
42 46
 		v)
43 47
 			DEBUG=1
... ...
@@ -57,6 +61,9 @@ while getopts ":dvnShuaj" opt; do
57 61
 			DEBUG=1
58 62
 			EXTRACT=1
59 63
 		;;
64
+		c)
65
+			CURL=1
66
+		;;
60 67
 		a)
61 68
 			JUST_AFTER_UPGRADE=1
62 69
 		;;
... ...
@@ -117,7 +124,12 @@ fi
117 124
 for i in `seq 1 $MAX_CHECK`
118 125
 do
119 126
 	tmpfile=`mktemp`
120
-	wget $WGET_SSL_OPT -q $CHECK_URL -O $tmpfile
127
+	if [ $CURL -eq 1 ]
128
+	then
129
+		curl $CURL_OPTS --silent --output $tmpfile $CHECK_URL
130
+	else
131
+		wget $WGET_OPTS $WGET_SSL_OPT -q $CHECK_URL -O $tmpfile
132
+	fi
121 133
 	newest=`cat $tmpfile|grep 'github.com'|grep 'complete.tar.gz'|head -n 1|sed 's|^.*github.com/roundcube/roundcubemail/releases/download/\([^/]*\)/roundcubemail-.*$|\1|'`
122 134
 	if [ -n "$newest" ]
123 135
 	then
... ...
@@ -188,7 +200,12 @@ then
188 200
 			cd "$DOWNLOAD_DIR"
189 201
 			DOWNLOAD_FILE="$( pwd )/roundcubemail-$newest.tar.gz"
190 202
 			[ $DEBUG -eq 1 ] && echo "Download new release in $DOWNLOAD_FILE"
191
-			wget $WGET_SSL_OPT -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL"
203
+			if [ $CURL -eq 1 ]
204
+			then
205
+				curl $CURL_OPTS --silent --output $DOWNLOAD_FILE $DOWNLOAD_URL
206
+			else
207
+				wget $WGET_OPTS $WGET_SSL_OPT -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL"
208
+			fi
192 209
 			if [ $EXTRACT -eq 1 ]
193 210
 			then
194 211
 				[ $DEBUG -eq 1 ] && echo "Extract new release"
195 212