Add option to disable SSL certificate check
Benjamin Renard

Benjamin Renard commited on 2016-04-23 09:11:06
Showing 1 changed files, with 15 additions and 3 deletions.

... ...
@@ -14,6 +14,7 @@ SLEEP_ON_FAILED=10
14 14
 CHECK_URL=http://www.roundcube.net/download
15 15
 DOWNLOAD=0
16 16
 DOWNLOAD_DIR=$RC_HOME/../upstream
17
+DONT_CHECK_SSL_CERT=0
17 18
 
18 19
 ### DO NOT MODIFY AFTER THIS LINE ###
19 20
 
... ...
@@ -28,6 +29,7 @@ function usage() {
28 29
 	echo "Usage : $0 [-v] [-n] [-d] [-u]"
29 30
 	echo "  -v   Verbose mode"
30 31
 	echo "  -n   Nagios mode"
32
+	echo "  -S   Don't check SSL certificate"
31 33
 	echo "  -d   Download new release"
32 34
 	echo "  -u   Upgrade installation"
33 35
 	echo "  -a   Just run after_upgrade function"
... ...
@@ -35,7 +37,7 @@ function usage() {
35 37
 	echo "  -h   Display this help"
36 38
 }
37 39
 
38
-while getopts ":dvnhuaj" opt; do
40
+while getopts ":dvnShuaj" opt; do
39 41
 	case $opt in
40 42
 		v)
41 43
 			DEBUG=1
... ...
@@ -43,6 +45,9 @@ while getopts ":dvnhuaj" opt; do
43 45
 		n)
44 46
 			NAGIOS=1
45 47
 		;;
48
+		S)
49
+			DONT_CHECK_SSL_CERT=1
50
+		;;
46 51
 		d)
47 52
 			DOWNLOAD=1
48 53
 		;;
... ...
@@ -102,10 +107,17 @@ then
102 107
 	exit $?
103 108
 fi
104 109
 
110
+WGET_SSL_OPT=""
111
+if [ "$DONT_CHECK_SSL_CERT" == "1" ]
112
+then
113
+	[ $DEBUG -eq 1 ] && echo "Disable SSL certificate check"
114
+	WGET_SSL_OPT="--no-check-certificate"
115
+fi
116
+
105 117
 for i in `seq 1 $MAX_CHECK`
106 118
 do
107 119
 	tmpfile=`mktemp`
108
-	wget -q $CHECK_URL -O $tmpfile
120
+	wget $WGET_SSL_OPT -q $CHECK_URL -O $tmpfile
109 121
 	newest=`cat $tmpfile|grep 'downloads.sourceforge.net'|grep 'complete.tar.gz'|head -n 1|sed 's|^.*downloads.sourceforge.net/project/roundcubemail/roundcubemail/\([^/]*\)/roundcubemail-.*$|\1|'`
110 122
 	if [ -n "$newest" ]
111 123
 	then
... ...
@@ -176,7 +188,7 @@ then
176 188
 			cd "$DOWNLOAD_DIR"
177 189
 			DOWNLOAD_FILE="$( pwd )/roundcubemail-$newest.tar.gz"
178 190
 			[ $DEBUG -eq 1 ] && echo "Download new release in $DOWNLOAD_FILE"
179
-			wget -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL"
191
+			wget $WGET_SSL_OPT -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL"
180 192
 			if [ $EXTRACT -eq 1 ]
181 193
 			then
182 194
 				[ $DEBUG -eq 1 ] && echo "Extract new release"
183 195