Added a background process for updating the DB
This commit is contained in:
@@ -8,7 +8,7 @@ WORKDIR /netflowParser
|
||||
|
||||
# Copy over IP2Loc, INFLUXDB, proto and wahtDomain
|
||||
|
||||
COPY ../Code/* /netflowParser/
|
||||
COPY ./Code/* /netflowParser/
|
||||
COPY ./entrypoint.sh /entrypoint.sh
|
||||
COPY ./updateIP2Lbin.sh /netflowParser/
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Default to 1600 if not provided
|
||||
PUID="${PUID:-1600}"
|
||||
PGID="${PGID:-1600}"
|
||||
USER="${USER:-apiusr}"
|
||||
GROUP="${USER:-apiusr}"
|
||||
CHOWNPATH="/netflowParser"
|
||||
|
||||
# Create group if missing
|
||||
if ! getent group "$GROUP" >/dev/null 2>&1; then
|
||||
addgroup -g "$PGID" "$GROUP"
|
||||
fi
|
||||
|
||||
# Create user if missing
|
||||
if ! id -u "$USER" >/dev/null 2>&1; then
|
||||
adduser -D -u "$PUID" -G "$GROUP" "$USER"
|
||||
fi
|
||||
|
||||
# Download IP2Location database
|
||||
if [[ -n "$IP2LOC_TOKEN" ]]; then
|
||||
wget -O "$CHOWNPATH"/IP2LOCATION-LITE-DB9.BIN "https://www.ip2location.com/download/?token="$IP2LOC_TOKEN"&file=DB9LITEBIN"
|
||||
fi
|
||||
|
||||
# Fix permissions (only do this on /app/API)
|
||||
chown -R "$PUID:$PGID" "$CHOWNPATH"
|
||||
|
||||
# Drop privileges & run command
|
||||
exec su-exec "$PUID:$PGID" "$@"
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -----------------------------
|
||||
# IP2Location DB1 Updater
|
||||
# -----------------------------
|
||||
|
||||
# Change this URL to your personal download link if needed
|
||||
DOWNLOAD_URL="https://www.ip2location.com/download/?token="$IP2LOC_TOKEN"&file=DB9LITEBIN"
|
||||
|
||||
# Define filenames
|
||||
ZIP_FILE="IP2LOCATION-LITE-DB9.BIN.ZIP"
|
||||
BIN_FILE="IP2LOCATION-LITE-DB9.BIN"
|
||||
|
||||
echo "Downloading latest IP2Location DB1..."
|
||||
wget -O "$CHOWNPATH"/"$BIN_FILE"
|
||||
|
||||
echo "Unzipping BIN file..."
|
||||
unzip -o "$ZIP_FILE"
|
||||
|
||||
if [ ! -f "$BIN_FILE" ]; then
|
||||
echo "Unzip failed or $BIN_FILE not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Cleaning up ZIP..."
|
||||
rm "$ZIP_FILE"
|
||||
|
||||
echo "Update complete. BIN file ready: $BIN_FILE"
|
||||
|
||||
Reference in New Issue
Block a user