Skip to content

Commit 9597beb

Browse files
committed
Fix proxy handling on snappy install, fix not empty string conditions elsewhere
1 parent 1d6fc0f commit 9597beb

2 files changed

Lines changed: 26 additions & 29 deletions

File tree

scripts/provision.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ else
259259
for M in $(echo "${AV_ALT_MIRRORS}" | xargs) ; do
260260
# if a proxy is set remove the 'http://' and 'https://' from the variables
261261

262-
if [ ! -z "$PROXY_HOST" -a ! -z "$PROXY_PORT" ] ; then
262+
if [ "$PROXY_HOST" -a "$PROXY_PORT" ] ; then
263263
# general proxy, but we must use it ?
264264
if [ "$AV_UPDATES_USE_PROXY" == "yes" -o "$AV_UPDATES_USE_PROXY" == "Yes" ] ; then
265265
# ok, by all means add proxy remove the prefix
@@ -278,15 +278,15 @@ else
278278
fi
279279

280280
### configure proxy if needed
281-
if [ ! -z "$PROXY_HOST" -a ! -z "$PROXY_PORT" ] ; then
281+
if [ "$PROXY_HOST" -a "$PROXY_PORT" ] ; then
282282
# general proxy, but we must use it ?
283283
if [ "$AV_UPDATES_USE_PROXY" == "yes" -o "$AV_UPDATES_USE_PROXY" == "Yes" ] ; then
284284
# ok, by all means add proxy
285285
echo "HTTPProxyServer $PROXY_HOST" >> $FILE
286286
echo "HTTPProxyPort $PROXY_PORT" >> $FILE
287287

288288
# check for auth
289-
if [ ! -z "$PROXY_USER" -a ! -z "$PROXY_PASS" ] ; then
289+
if [ "$PROXY_USER" -a "$PROXY_PASS" ] ; then
290290
echo "HTTPProxyUsername $PROXY_USER" >> $FILE
291291
echo "HTTPProxyPassword $PROXY_PASS" >> $FILE
292292
fi
@@ -349,7 +349,7 @@ if [ "$ENABLE_SPAMD" == "yes" -o "$ENABLE_SPAMD" == "Yes" ] ; then
349349
# configure SMA filtering on amavis if not already active
350350
FILE="/etc/amavis/conf.d/15-content_filter_mode"
351351
ACTIVE=$(grep "^#@bypass_spam_checks_maps.*" $FILE)
352-
if [ ! -z "$ACTIVE" ] ; then
352+
if [ "$ACTIVE" ] ; then
353353
# not active, activating
354354
sed -i s/"#@bypass_spam_checks_maps"/"@bypass_spam_checks_maps"/g $FILE
355355

@@ -392,7 +392,7 @@ else
392392
# disable spamassasin on amavis
393393
FILE="/etc/amavis/conf.d/15-content_filter_mode"
394394
ACTIVE=$(grep "^@bypass_spam_checks_maps.*" $FILE)
395-
if [ ! -z "$ACTIVE" ] ; then
395+
if [ "$ACTIVE" ] ; then
396396
# not active, activating
397397
sed -i s/"@bypass_spam_checks_maps"/"#@bypass_spam_checks_maps"/g $FILE
398398

scripts/snappy.sh

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,6 @@ function fixperms {
3636
chown -R www-data:www-data "$1/"
3737
}
3838

39-
# Handle http proxy if set - comprehensive proxy support matching provision.sh
40-
function setup_proxy_environment {
41-
# Set both HTTP and HTTPS proxy environment variables
42-
export HTTP_PROXY="http://$PROXY_HOST:$PROXY_PORT"
43-
export HTTPS_PROXY="http://$PROXY_HOST:$PROXY_PORT"
44-
echo "===> Proxy configured: $PROXY_HOST:$PROXY_PORT"
45-
46-
# check for auth
47-
if [ ! -z "$PROXY_USER" -a ! -z "$PROXY_PASS" ] ; then
48-
export HTTP_PROXY="http://$PROXY_USER:$PROXY_PASS@$PROXY_HOST:$PROXY_PORT"
49-
export HTTPS_PROXY="http://$PROXY_USER:$PROXY_PASS@$PROXY_HOST:$PROXY_PORT"
50-
echo "===> Proxy authentication enabled for user: $PROXY_USER"
51-
fi
52-
}
53-
5439
# install php dependencies:
5540
apt-get install ${APT_OPTS} $SNAPPY_PKGS
5641

@@ -73,16 +58,28 @@ R=0
7358
if [ -f "./$SNAPPY_FILE" -a "$DOMAIN" == "mailad.cu" ]; then
7459
cp "./$SNAPPY_FILE" "/tmp/$SNAPPY_FILE"
7560
else
76-
# Add proxy options to wget for package download if proxy is configured
77-
WGET_OPTS="--no-clobber"
78-
if [ "$PROXY_HOST" -a "$PROXY_PORT" ] ; then
79-
echo "===> Using proxy for SnappyMail package download: $PROXY_HOST:$PROXY_PORT" | tee -a $FILE
80-
WGET_OPTS="${WGET_OPTS} --proxy=on --http-proxy=\"$HTTP_PROXY\" --https-proxy=\"$HTTPS_PROXY\""
61+
# Setup proxy if needed
62+
if [ "$PROXY_HOST" -a "$PROXY_PORT"] ; then
63+
# Set both HTTP and HTTPS proxy environment variables
64+
export HTTP_PROXY="http://$PROXY_HOST:$PROXY_PORT"
65+
export HTTPS_PROXY="http://$PROXY_HOST:$PROXY_PORT"
66+
echo "===> Proxy configured: $HTTP_PROXY"
67+
68+
# check for auth tyo add auth
69+
if [ "$PROXY_USER" -a "$PROXY_PASS" ] ; then
70+
export HTTP_PROXY="http://$PROXY_USER:$PROXY_PASS@$PROXY_HOST:$PROXY_PORT"
71+
export HTTPS_PROXY="http://$PROXY_USER:$PROXY_PASS@$PROXY_HOST:$PROXY_PORT"
72+
echo "===> Proxy authentication enabled for user: $PROXY_USER"
73+
fi
8174
fi
82-
75+
8376
echo "===> Downloading SnappyMail package from: $SNAPPY_URL" | tee -a $FILE
84-
wget -q ${WGET_OPTS} "$SNAPPY_URL" -O "/tmp/$SNAPPY_FILE"
77+
wget -q -c "$SNAPPY_URL" -O "/tmp/$SNAPPY_FILE"
8578
R=$?
79+
80+
# Unset proxy variables to avoid get them used locally
81+
unset HTTP_PROXY
82+
unset HTTPS_PROXY
8683
fi
8784

8885
# check if download fails
@@ -93,9 +90,9 @@ if [ $R -ne 0 -a $R -ne 1 ]; then
9390
echo " Return code: $R" | tee -a $FILE
9491

9592
# Provide specific proxy-related error messages
96-
if [ ! -z "$PROXY_HOST" -a ! -z "$PROXY_PORT" ] ; then
93+
if [ "$PROXY_HOST" -a "$PROXY_PORT" ] ; then
9794
echo " Proxy configured: $PROXY_HOST:$PROXY_PORT" | tee -a $FILE
98-
if [ ! -z "$PROXY_USER" -a ! -z "$PROXY_PASS" ] ; then
95+
if [ "$PROXY_USER" -a "$PROXY_PASS" ] ; then
9996
echo " Proxy authentication: enabled for user $PROXY_USER" | tee -a $FILE
10097
fi
10198
echo " This could be a proxy authentication or connectivity issue." | tee -a $FILE

0 commit comments

Comments
 (0)