Skip to content

Commit

Permalink
Merge pull request #11 from AusDTO/geolite2
Browse files Browse the repository at this point in the history
Add geoipdate job
  • Loading branch information
gordcorp authored Nov 20, 2017
2 parents acb1353 + 5ee2f3c commit 93b4d90
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/blobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ elasticsearch/elasticsearch-2.4.4.tar.gz:
size: 27343272
object_id: 06f85038-ba22-46f7-a7c7-058d0d6aa7c2
sha: cdb5068d1baa07388e522c3bc04cca38aa8f3048
geoipupdate/geoipupdate-2.5.0.tar.gz:
size: 371882
object_id: a00f4ce6-ea45-4301-7569-c92b4042ec93
sha: 79c5c9ba0f7a89d921b640f140ce0f5dc95bc8eb
graylog/graylog-2.2.2.tgz:
size: 99956086
object_id: dee996d9-8ed8-453e-85cb-27ea5362ff0c
Expand Down
Empty file added jobs/geoipupdate/monit
Empty file.
13 changes: 13 additions & 0 deletions jobs/geoipupdate/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: geoipupdate

templates:
bin/geoipupdate.sh: bin/geoipupdate.sh
bin/geoipupdate-cron: bin/geoipupdate-cron
bin/pre-start: bin/pre-start
etc/GeoIP.conf: etc/GeoIP.conf

packages:
- geoipupdate

properties: {}
1 change: 1 addition & 0 deletions jobs/geoipupdate/templates/bin/geoipupdate-cron
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0 9 * * Wed root /var/vcap/jobs/geoipupdate/bin/geoipupdate.sh
31 changes: 31 additions & 0 deletions jobs/geoipupdate/templates/bin/geoipupdate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -eux

JOB_NAME=geoipupdate
JOB_DIR=/var/vcap/jobs/$JOB_NAME
LOG_DIR=/var/vcap/sys/log/$JOB_NAME
STORE_DIR=/var/vcap/store/$JOB_NAME

mkdir -p $LOG_DIR
chown vcap:vcap $LOG_DIR

{
echo "$(date) running geoipupdate"

# graylog looks for the geoip database at
# /etc/graylog/server/GeoLite2-City.mmdb, so we download the db
# to the bosh standard location and add a symlink for graylog

mkdir -p $STORE_DIR
mkdir -p /etc/graylog
ln -sf $STORE_DIR /etc/graylog/server | true

chown vcap -R $STORE_DIR

chpst -u vcap:vcap /var/vcap/packages/geoipupdate/bin/geoipupdate \
-v \
-f $JOB_DIR/etc/GeoIP.conf \
-d $STORE_DIR
} >>$LOG_DIR/$JOB_NAME.stdout.log \
2>>$LOG_DIR/$JOB_NAME.stderr.log
7 changes: 7 additions & 0 deletions jobs/geoipupdate/templates/bin/pre-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# run it immediately
/var/vcap/jobs/geoipupdate/bin/geoipupdate.sh

# schedule the job with cron
cp /var/vcap/jobs/geoipupdate/bin/geoipupdate-cron /etc/cron.d
13 changes: 13 additions & 0 deletions jobs/geoipupdate/templates/etc/GeoIP.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# suggested config for GeoLite2 databases
# from https://dev.maxmind.com/geoip/geoipupdate/

# The following AccountID and LicenseKey are required placeholders.
# For geoipupdate versions earlier than 2.5.0, use UserId here instead of AccountID.
AccountID 0
LicenseKey 000000000000

# Include one or more of the following edition IDs:
# * GeoLite2-City - GeoLite 2 City
# * GeoLite2-Country - GeoLite2 Country
# For geoipupdate versions earlier than 2.5.0, use ProductIds here instead of EditionIDs.
EditionIDs GeoLite2-City GeoLite2-Country
3 changes: 3 additions & 0 deletions manifests/graylog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ instance_groups:
root_username: admin
# default root_password = admin ; below is sha2 hash of it.
root_password_sha2: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
- name: geoipupdate
release: graylog
properties: {}

variables:
- name: password-secret
Expand Down
19 changes: 19 additions & 0 deletions packages/geoipupdate/packaging
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

# Available variables
# $BOSH_COMPILE_TARGET - where this package & spec'd source files are available
# $BOSH_INSTALL_TARGET - where you copy/install files to be included in package

VERSION=2.5.0

tar xzfv geoipupdate/geoipupdate-${VERSION}.tar.gz

cd geoipupdate-${VERSION}

./configure --prefix $BOSH_INSTALL_TARGET

make

make install
7 changes: 7 additions & 0 deletions packages/geoipupdate/spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: geoipupdate

dependencies: []

files:
- geoipupdate/geoipupdate-2.5.0.tar.gz # from https://github.com/maxmind/geoipupdate/releases/download/v2.5.0/geoipupdate-2.5.0.tar.gz

0 comments on commit 93b4d90

Please sign in to comment.