Add ENABLE_DBIP to ``psql-app`` container to auto import DB-IP geo data

This commit is contained in:
Tim Evens 2022-06-08 14:53:55 -07:00
parent a50c553f66
commit 237345b476
3 changed files with 29 additions and 3 deletions

View File

@ -162,6 +162,7 @@ services:
- RPKI_USER=None - RPKI_USER=None
- ENABLE_RPKI=1 # 1 enables, 0 disables RPKI sync - ENABLE_RPKI=1 # 1 enables, 0 disables RPKI sync
- ENABLE_IRR=1 # 1 enables, 0 disables IRR sync - ENABLE_IRR=1 # 1 enables, 0 disables IRR sync
- ENABLE_DBIP=1 # 1 enables, 0 disables DBIP import
- POSTGRES_REPORT_WINDOW='8 minute' # default POSTGRESS window to select when building - POSTGRES_REPORT_WINDOW='8 minute' # default POSTGRESS window to select when building
# summary tables. For deployments that absorb large # summary tables. For deployments that absorb large
# bursts increase the value, ex 60 minute # bursts increase the value, ex 60 minute

View File

@ -53,6 +53,7 @@ COPY --chmod=755 --from=build /ws/cron_scripts/gen-whois/*.py /usr/local/openbm
COPY --chmod=755 --from=build /ws/cron_scripts/peeringdb/*.py /usr/local/openbmp/ COPY --chmod=755 --from=build /ws/cron_scripts/peeringdb/*.py /usr/local/openbmp/
COPY --chmod=755 --from=build /ws/cron_scripts/rpki/*.py /usr/local/openbmp/ COPY --chmod=755 --from=build /ws/cron_scripts/rpki/*.py /usr/local/openbmp/
COPY --chmod=755 --from=build /ws/scripts/geo-csv-to-psql.py /usr/local/openbmp/ COPY --chmod=755 --from=build /ws/scripts/geo-csv-to-psql.py /usr/local/openbmp/
COPY --chmod=755 --from=build /ws/scripts/db-ip-import.sh /usr/local/openbmp/
# Add files # Add files
ADD --chmod=755 obmp-docker/psql-app/scripts/run /usr/sbin/ ADD --chmod=755 obmp-docker/psql-app/scripts/run /usr/sbin/
@ -86,7 +87,7 @@ RUN apt-get update \
RUN cd /tmp && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ RUN cd /tmp && curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& python3 get-pip.py && python3 get-pip.py
RUN pip install ipaddr pykafka click RUN pip install ipaddr pykafka click netaddr
RUN pip3 install urllib3 requests RUN pip3 install urllib3 requests

View File

@ -116,6 +116,25 @@ SETVAR
} }
# -----------------------------------------------
# Enable DB-IP import
# -----------------------------------------------
enable_dbip() {
echo "===> Enabling DB-IP Import"
cat > /etc/cron.d/openbmp-dbip <<SETVAR
MAILTO=""
$(( $RANDOM % 59 + 1 )) $(( $RANDOM % 23 + 1 )) 1 * * root /usr/local/openbmp/db-ip-import.sh > /var/log/cron-dbip-import.log
SETVAR
# Load DB-IP on start
echo "Running DB-IP Import"
/usr/local/openbmp/db-ip-import.sh > /var/log/cron-dbip-import.log &
}
# ----------------------------------------------- # -----------------------------------------------
# Enable IRR # Enable IRR
# ----------------------------------------------- # -----------------------------------------------
@ -256,15 +275,20 @@ source /usr/local/openbmp/pg_profile
config_cron config_cron
rm -f /etc/cron.d/openbmp-rpki rm -f /etc/cron.d/openbmp-rpki
if [[ ${ENABLE_RPKI:-""} != "" ]]; then if [[ ${ENABLE_RPKI:-""} != "" && $ENABLE_RPKI == 1 ]]; then
enable_rpki enable_rpki
fi fi
rm -f /etc/cron.d/openbmp-irr rm -f /etc/cron.d/openbmp-irr
if [[ ${ENABLE_IRR:-""} != "" ]]; then if [[ ${ENABLE_IRR:-""} != "" && $ENABLE_IRR == 1 ]]; then
enable_irr enable_irr
fi fi
rm -f /etc/cron.d/openbmp-dbip
if [[ ${ENABLE_DBIP:-""} != "" && $ENABLE_DBIP == 1 ]]; then
enable_dbip
fi
initdb_postgres initdb_postgres