-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes it work on non-x86 architectures. Also, enhance it a bit to stop gracefully on signal (when not being in foreground, a shell script is not leader of its process group and the TERM signal does not kill the commands running in it).
- Loading branch information
1 parent
deb149d
commit 7c4f68a
Showing
4 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk add --no-cache curl | ||
|
||
WORKDIR /data | ||
VOLUME /data | ||
|
||
COPY --chmod=555 ipinfo-geoipupdate.sh /usr/local/bin/ipinfo-geoipupdate.sh | ||
|
||
CMD ["/usr/local/bin/ipinfo-geoipupdate.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
trap exit TERM | ||
|
||
while true; do | ||
for DATABASE in ${IPINFO_DATABASES}; do | ||
RESPONSE=$(curl \ | ||
-s -w '%{http_code}' -L -o "${DATABASE}.mmdb.new" \ | ||
"https://ipinfo.io/data/free/${DATABASE}.mmdb?token=${IPINFO_TOKEN}") | ||
if [ "$RESPONSE" != "200" ]; then | ||
echo "$RESPONSE Failed to download ${DATABASE}.mmdb database." | ||
rm "${DATABASE}.mmdb.new" 2> /dev/null | ||
else | ||
echo "${DATABASE}.mmdb database downloaded in /data volume." | ||
mv "${DATABASE}.mmdb.new" "${DATABASE}.mmdb" | ||
fi | ||
done | ||
|
||
sleep "$UPDATE_FREQUENCY" & | ||
wait $! | ||
done |