docker update

This commit is contained in:
Michael S2pac 2025-11-27 13:47:41 +03:00
parent 67d4142c3a
commit c4c5aee9ac
3 changed files with 20 additions and 16 deletions

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
# shared volume
geodata/
# Ignore editor and IDE settings # Ignore editor and IDE settings
.idea/ .idea/
.vscode/ .vscode/

View file

@ -42,11 +42,12 @@ services:
depends_on: depends_on:
- docker-proxy - docker-proxy
environment: environment:
ENABLE_CRON_UPDATE: "true"
TZ: "UTC" TZ: "UTC"
DOCKER_PROXY_URL: "http://docker-proxy:2375" DOCKER_PROXY_URL: "http://docker-proxy:2375"
TARGET_CONTAINER_NAME: "3xui_app" TARGET_CONTAINER_NAME: "3xui_app"
# CRON_SCHEDULE: "*/5 * * * *" CRON_SCHEDULE: "*/1 * * * *"
CRON_SCHEDULE: "0 */6 * * *" # CRON_SCHEDULE: "0 */6 * * *"
SHARED_VOLUME_PATH: "/app/bin" SHARED_VOLUME_PATH: "/app/bin"
volumes: volumes:
- $PWD/geodata/:/app/bin/ - $PWD/geodata/:/app/bin/

View file

@ -2,8 +2,8 @@
update_all_geofiles() { update_all_geofiles() {
update_main_geofiles update_main_geofiles
update_ir_geofiles # update_ir_geofiles
update_ru_geofiles # update_ru_geofiles
} }
update_main_geofiles() { update_main_geofiles() {
@ -22,16 +22,16 @@ update_ru_geofiles() {
} }
update_geodata_in_docker() { update_geodata_in_docker() {
WORKDIR="$1" XRAYDIR="$1"
OLD_DIR=$(pwd) OLD_DIR=$(pwd)
trap 'cd "$OLD_DIR"' EXIT trap 'cd "$OLD_DIR"' EXIT
echo "[$(date)] Running update_geodata" echo "[$(date)] Running update_geodata"
if [ ! -d "$WORKDIR" ]; then if [ ! -d "$XRAYDIR" ]; then
mkdir -p "$WORKDIR" mkdir -p "$XRAYDIR"
fi fi
cd "$WORKDIR" cd "$XRAYDIR"
update_all_geofiles update_all_geofiles
echo "[$(date)] All geo files have been updated successfully!" echo "[$(date)] All geo files have been updated successfully!"
@ -40,7 +40,7 @@ update_geodata_in_docker() {
install_xray_core() { install_xray_core() {
TARGETARCH="$1" TARGETARCH="$1"
WORKDIR="$2" XRAYDIR="$2"
XRAY_VERSION="$3" XRAY_VERSION="$3"
OLD_DIR=$(pwd) OLD_DIR=$(pwd)
@ -75,10 +75,10 @@ install_xray_core() {
;; ;;
esac esac
if [ ! -d "$WORKDIR" ]; then if [ ! -d "$XRAYDIR" ]; then
mkdir -p "$WORKDIR" mkdir -p "$XRAYDIR"
fi fi
cd "$WORKDIR" cd "$XRAYDIR"
wget -q "https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-linux-${ARCH}.zip" wget -q "https://github.com/XTLS/Xray-core/releases/download/${XRAY_VERSION}/Xray-linux-${ARCH}.zip"
unzip "Xray-linux-${ARCH}.zip" -d ./xray-unzip unzip "Xray-linux-${ARCH}.zip" -d ./xray-unzip
@ -95,17 +95,17 @@ if [ "${0##*/}" = "xray-tools.sh" ]; then
case "$cmd" in case "$cmd" in
install_xray_core) install_xray_core)
# args: TARGETARCH WORKDIR XRAY_VERSION # args: TARGETARCH XRAYDIR XRAY_VERSION
install_xray_core "$@" install_xray_core "$@"
;; ;;
update_geodata_in_docker) update_geodata_in_docker)
# args: WORKDIR # args: XRAYDIR
update_geodata_in_docker "$@" update_geodata_in_docker "$@"
;; ;;
""|help|-h|--help) ""|help|-h|--help)
echo "Usage:" echo "Usage:"
echo " $0 install_xray_core TARGETARCH WORKDIR XRAY_VERSION" echo " $0 install_xray_core TARGETARCH XRAYDIR XRAY_VERSION"
echo " $0 update_geodata_in_docker WORKDIR" echo " $0 update_geodata_in_docker XRAYDIR"
exit 1 exit 1
;; ;;
*) *)