]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
xt_geoip_update: Add support for upstream proxy.
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 19 Mar 2015 21:09:24 +0000 (22:09 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 19 Mar 2015 21:09:24 +0000 (22:09 +0100)
src/scripts/xt_geoip_update

index 42e214366f098e222c076e32d8724b846926e869..0ee774470a4f8ec2fe815e624452b1efd9d9cdda 100644 (file)
@@ -32,14 +32,30 @@ CSV_FILE=GeoIPCountryWhois.csv
 
 ARCH=LE
 
+eval $(/usr/local/bin/readhash /var/ipfire/proxy/settings)
+
 function download() {
        echo "Downloading latest GeoIP ruleset..."
 
        # Create temporary directory.
        mkdir -pv $TMP_PATH
 
+       # Proxy settings.
+       # Check if a proxy should be used.
+       if [[ $UPSTREAM_PROXY ]]; then
+               PROXYSETTINGS="-e http_proxy=http://"
+
+               # Check if authentication against the proxy is configured.
+               if [[ $UPSTREAM_USER && $UPSTREAM_PASSWORD ]]; then
+                       PROXYSETTINGS="$PROXYSETTINGS$UPSTREAM_USER:$UPSTREAM_PASSWORD@"
+               fi
+
+               # Add proxy server.
+               PROXYSETTINGS="$PROXYSETTINGS$UPSTREAM_PROXY"
+       fi
+
        # Get the latest GeoIP database from server.
-       wget $DL_URL/$DL_FILE -O $TMP_FILE
+       wget $DL_URL/$DL_FILE $PROXYSETTINGS -O $TMP_FILE
 
        # Extract files.
        unzip $TMP_FILE -d $TMP_PATH