From 2129197bcf6a84acff6a9873387056300a0ae92a Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 7 Jul 2024 12:13:47 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Committing=20everything?= =?UTF-8?q?=20that=20changed=20=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dockerfile rootfs/tmp/ rootfs/usr/local/etc/docker/init.d/zz-ifconfig.sh --- Dockerfile | 3 +- rootfs/tmp/init.sh | 44 +++++++++++++++++++ .../local/etc/docker/init.d/zz-ifconfig.sh | 18 ++++---- 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 rootfs/tmp/init.sh diff --git a/Dockerfile b/Dockerfile index 780a0c7..0c5bd57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,7 +98,8 @@ RUN set -ex ; \ RUN set -ex ; \ ln -sf /opt/echoip/echoip /usr/local/bin/echoip ; \ ln -sf /opt/echoip/echoip /usr/local/bin/ifconfig ; \ - sed -i "s|REPLACE_MODIFIED|$(date +'%Y-%m-%d at %H:%M')|g" /opt/echoip/html/index.html + sed -i "s|REPLACE_MODIFIED|$(date +'%Y-%m-%d at %H:%M')|g" /opt/echoip/html/index.html; \ + bash -c "/tmp/init.sh" RUN set -ex ; \ echo 'Running cleanup' ; \ diff --git a/rootfs/tmp/init.sh b/rootfs/tmp/init.sh new file mode 100644 index 0000000..dd94c06 --- /dev/null +++ b/rootfs/tmp/init.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# shellcheck shell=bash +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +##@Version : 202407071207-git +# @@Author : Jason Hempstead +# @@Contact : git-admin@casjaysdev.pro +# @@License : LICENSE.md +# @@ReadME : init.sh --help +# @@Copyright : Copyright: (c) 2024 Jason Hempstead, Casjays Developments +# @@Created : Sunday, Jul 07, 2024 12:07 EDT +# @@File : init.sh +# @@Description : Update GeoIP databases +# @@Changelog : newScript +# @@TODO : Refactor code +# @@Other : +# @@Resource : +# @@Terminal App : no +# @@sudo/root : no +# @@Template : bash/system +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# shell check options +# shellcheck disable=SC2317 +# shellcheck disable=SC2120 +# shellcheck disable=SC2155 +# shellcheck disable=SC2199 +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +APPNAME="$(basename "$0")" +VERSION="202407071207-git" +HOME="${USER_HOME:-$HOME}" +USER="${SUDO_USER:-$USER}" +RUN_USER="${SUDO_USER:-$USER}" +SRC_DIR="${BASH_SOURCE%/*}" +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Set bash options +trap 'exitCode=${exitCode:-$?};[ -n "$INIT_SH_TEMP_FILE" ] && [ -f "$INIT_SH_TEMP_FILE" ] && rm -Rf "$INIT_SH_TEMP_FILE" &>/dev/null' EXIT +#if [ ! -t 0 ] && { [[ "$1" = --term ]] || [ $# = 0 ]; }; then shift 1 && TERMINAL_APP="TRUE" myterminal -e "$APPNAME $*" && exit || exit 1; fi +[ "$1" = "--debug" ] && set -xo pipefail && export SCRIPT_OPTS="--debug" && export _DEBUG="on" +[ "$1" = "--raw" ] && export SHOW_RAW="true" +set -o pipefail +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +for f in GeoLite2-ASN GeoLite2-City GeoLite2-Country; do + curl -q -LSsf "https://github.com/P3TERX/GeoLite.mmdb/raw/download/$f.mmdb" -O /opt/echoip/geoip/$f.mmdb + [ -f "rootfs/opt/echoip/geoip/$f.mmdb" ] && echo "Installed $f.mmdb to /opt/echoip/geoip" || exit 10 +done diff --git a/rootfs/usr/local/etc/docker/init.d/zz-ifconfig.sh b/rootfs/usr/local/etc/docker/init.d/zz-ifconfig.sh index 971a207..db41065 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-ifconfig.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-ifconfig.sh @@ -120,14 +120,16 @@ SERVICE_GID="0" # set the group id # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # execute command variables - keep single quotes variables will be expanded later EXEC_CMD_BIN='ifconfig' # command to execute -EXEC_CMD_ARGS='-r -s -p ' # command arguments -EXEC_CMD_ARGS+='-l :$SERVICE_PORT ' # command arguments -EXEC_CMD_ARGS+='-H X-Real-IP ' # command arguments -EXEC_CMD_ARGS+='-H x-forwarded-for ' # command arguments -EXEC_CMD_ARGS+='-a /opt/echoip/geoip/GeoLite2-ASN.mmdb ' # command arguments -EXEC_CMD_ARGS+='-c /opt/echoip/geoip/GeoLite2-City.mmdb ' # command arguments -EXEC_CMD_ARGS+='-f /opt/echoip/geoip/GeoLite2-Country.mmdb ' # command arguments -EXEC_CMD_ARGS+='-t /opt/echoip/html ' # command arguments +EXEC_CMD_ARGS="-r " # command arguments +EXEC_CMD_ARGS+="-s " # command arguments +EXEC_CMD_ARGS+="-p " # command arguments +EXEC_CMD_ARGS+="-l :$SERVICE_PORT " # command arguments +EXEC_CMD_ARGS+="-H X-Real-IP " # command arguments +EXEC_CMD_ARGS+="-H x-forwarded-for " # command arguments +EXEC_CMD_ARGS+="-a /opt/echoip/geoip/GeoLite2-ASN.mmdb " # command arguments +EXEC_CMD_ARGS+="-c /opt/echoip/geoip/GeoLite2-City.mmdb " # command arguments +EXEC_CMD_ARGS+="-f /opt/echoip/geoip/GeoLite2-Country.mmdb " # command arguments +EXEC_CMD_ARGS+="-t /opt/echoip/html " # command arguments EXEC_PRE_SCRIPT='' # execute script before # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Is this service a web server