Skip to content

Commit

Permalink
first cut
Browse files Browse the repository at this point in the history
  • Loading branch information
parisholley committed Sep 14, 2014
1 parent 1d0478b commit 36b465d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Heroku Environment Variables
* MAXMIND_KEY = The license key they provided which allows you to download files
* MAXMIND_PATH = The path relative to the build directory where you want the file stored, ie: "GeoIP2-ISP.mmdb" or "path/to/folder/GeoIP2-ISP.mmdb"
39 changes: 39 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

BUILD_DIR = $1
CACHE_DIR = $2
ENV_DIR = $3

if [ ! -f "$ENV_DIR/MAXMIND_KEY" ]
echo "-----> You must define the environment variable MAXMIND_KEY with your license key."

exit 1
fi

if [ ! -f "$ENV_DIR/MAXMIND_PATH" ]
echo "-----> You must define the environment variable MAXMIND_PATH with the path relative to the build directory where you would like to store the file."

exit 1
fi

DB = "$CACHE_DIR/GeoIP2-ISP.mmdb"

if [ ! -f $DB ]
echo "-----> Database does not exist in cache, downloading."

TAR = "$CACHE_DIR/isp.tar.gz"

curl -o $TAR -L "https://download.maxmind.com/app/geoip_download?edition_id=GeoIP2-ISP&suffix=tar.gz&license_key=$MAXMIND"

echo "-----> Extracting $TAR"

tar -zxvf $TAR --wildcards --no-anchored --strip=1 '*GeoIP2-ISP.mmdb'
rm $TAR
fi

MAXMIND_PATH = `cat $ENV_DIR/MAXMIND_PATH`
SAVE = "$BUILD_DIR/$SAVE"

echo "-----> Copying $DB to $SAVE"

cp $DB $SAVE
3 changes: 3 additions & 0 deletions bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

exit 0 # should always run

0 comments on commit 36b465d

Please sign in to comment.