"Fossies" - the Fresh Open Source Software Archive

Member "geoipupdate-4.3.0/docker/entry.sh" (16 Apr 2020, 1418 Bytes) of package /linux/misc/geoipupdate-4.3.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 set -e
    4 
    5 conf_file=/etc/GeoIP.conf
    6 database_dir=/usr/share/GeoIP
    7 flags=
    8 frequency=$((GEOIPUPDATE_FREQUENCY * 60 * 60))
    9 if [ -z "$GEOIPUPDATE_ACCOUNT_ID" ] || [ -z  "$GEOIPUPDATE_LICENSE_KEY" ] || [ -z "$GEOIPUPDATE_EDITION_IDS" ]; then
   10     echo "ERROR: You must set the environment variables GEOIPUPDATE_ACCOUNT_ID, GEOIPUPDATE_LICENSE_KEY, and GEOIPUPDATE_EDITION_IDS!"
   11     exit 1
   12 fi
   13 
   14 # Create configuration file
   15 echo "# STATE: Creating configuration file at $conf_file"
   16 cat <<EOF > "$conf_file"
   17 AccountID $GEOIPUPDATE_ACCOUNT_ID
   18 LicenseKey $GEOIPUPDATE_LICENSE_KEY
   19 EditionIDs $GEOIPUPDATE_EDITION_IDS
   20 EOF
   21 
   22 if [ ! -z "$GEOIPUPDATE_HOST" ]; then
   23     echo "Host $GEOIPUPDATE_HOST" >> "$conf_file"
   24 fi
   25 
   26 if [ ! -z "$GEOIPUPDATE_PROXY" ]; then
   27     echo "Proxy $GEOIPUPDATE_PROXY" >> "$conf_file"
   28 fi
   29 
   30 if [ ! -z "$GEOIPUPDATE_PROXY_USER_PASSWORD" ]; then
   31     echo "ProxyUserPassword $GEOIPUPDATE_PROXY_USER_PASSWORD" >> "$conf_file"
   32 fi
   33 
   34 if [ ! -z "$GEOIPUPDATE_PRESERVE_FILE_TIMES" ]; then
   35     echo "PreserveFileTimes $GEOIPUPDATE_PRESERVE_FILE_TIMES" >> "$conf_file"
   36 fi
   37 
   38 if [ "$GEOIPUPDATE_VERBOSE" ]; then
   39     flags="-v"
   40 fi
   41 
   42 cat "$conf_file"
   43 
   44 while true; do
   45     echo "# STATE: Running geoipupdate"
   46     /usr/bin/geoipupdate -d "$database_dir" -f "$conf_file" $flags
   47     if [ "$frequency" -eq 0 ]; then
   48         break
   49     fi
   50 
   51     echo "# STATE: Sleeping for $GEOIPUPDATE_FREQUENCY hours"
   52     sleep "$frequency"
   53 done