Add possibility to use curl instead of wget

This commit is contained in:
Benjamin Renard 2017-04-24 14:51:36 +02:00
parent 8bd37ab8f2
commit 91ad601bc0

View file

@ -15,29 +15,33 @@ CHECK_URL=https://roundcube.net/download/
DOWNLOAD=0 DOWNLOAD=0
DOWNLOAD_DIR=$RC_HOME/../upstream DOWNLOAD_DIR=$RC_HOME/../upstream
DONT_CHECK_SSL_CERT=0 DONT_CHECK_SSL_CERT=0
WGET_OPTS=""
CURL_OPTS=""
### DO NOT MODIFY AFTER THIS LINE ### ### DO NOT MODIFY AFTER THIS LINE ###
DEBUG=0 DEBUG=0
NAGIOS=0 NAGIOS=0
UPGRADE=0 UPGRADE=0
CURL=0
EXTRACT=0 EXTRACT=0
JUST_DISP=0 JUST_DISP=0
JUST_AFTER_UPGRADE=0 JUST_AFTER_UPGRADE=0
function usage() { function usage() {
echo "Usage : $0 [-v] [-n] [-d] [-u]" echo "Usage : $0 [-v] [-n] [-d] [-u] [-c]"
echo " -v Verbose mode" echo " -v Verbose mode"
echo " -n Nagios mode" echo " -n Nagios mode"
echo " -S Don't check SSL certificate" echo " -S Don't check SSL certificate (Wget only)"
echo " -d Download new release" echo " -d Download new release"
echo " -u Upgrade installation" echo " -u Upgrade installation"
echo " -c Use curl instead of wget"
echo " -a Just run after_upgrade function" echo " -a Just run after_upgrade function"
echo " -j Just display current stable version" echo " -j Just display current stable version"
echo " -h Display this help" echo " -h Display this help"
} }
while getopts ":dvnShuaj" opt; do while getopts ":dvnShucaj" opt; do
case $opt in case $opt in
v) v)
DEBUG=1 DEBUG=1
@ -57,6 +61,9 @@ while getopts ":dvnShuaj" opt; do
DEBUG=1 DEBUG=1
EXTRACT=1 EXTRACT=1
;; ;;
c)
CURL=1
;;
a) a)
JUST_AFTER_UPGRADE=1 JUST_AFTER_UPGRADE=1
;; ;;
@ -117,7 +124,12 @@ fi
for i in `seq 1 $MAX_CHECK` for i in `seq 1 $MAX_CHECK`
do do
tmpfile=`mktemp` tmpfile=`mktemp`
wget $WGET_SSL_OPT -q $CHECK_URL -O $tmpfile if [ $CURL -eq 1 ]
then
curl $CURL_OPTS --silent --output $tmpfile $CHECK_URL
else
wget $WGET_OPTS $WGET_SSL_OPT -q $CHECK_URL -O $tmpfile
fi
newest=`cat $tmpfile|grep 'github.com'|grep 'complete.tar.gz'|head -n 1|sed 's|^.*github.com/roundcube/roundcubemail/releases/download/\([^/]*\)/roundcubemail-.*$|\1|'` newest=`cat $tmpfile|grep 'github.com'|grep 'complete.tar.gz'|head -n 1|sed 's|^.*github.com/roundcube/roundcubemail/releases/download/\([^/]*\)/roundcubemail-.*$|\1|'`
if [ -n "$newest" ] if [ -n "$newest" ]
then then
@ -188,7 +200,12 @@ then
cd "$DOWNLOAD_DIR" cd "$DOWNLOAD_DIR"
DOWNLOAD_FILE="$( pwd )/roundcubemail-$newest.tar.gz" DOWNLOAD_FILE="$( pwd )/roundcubemail-$newest.tar.gz"
[ $DEBUG -eq 1 ] && echo "Download new release in $DOWNLOAD_FILE" [ $DEBUG -eq 1 ] && echo "Download new release in $DOWNLOAD_FILE"
wget $WGET_SSL_OPT -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL" if [ $CURL -eq 1 ]
then
curl $CURL_OPTS --silent --output $DOWNLOAD_FILE $DOWNLOAD_URL
else
wget $WGET_OPTS $WGET_SSL_OPT -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL"
fi
if [ $EXTRACT -eq 1 ] if [ $EXTRACT -eq 1 ]
then then
[ $DEBUG -eq 1 ] && echo "Extract new release" [ $DEBUG -eq 1 ] && echo "Extract new release"