Skip to content

Commit

Permalink
docker-run.sh: sync w/ docker-glftpd repo
Browse files Browse the repository at this point in the history
  • Loading branch information
silv3rr committed Aug 22, 2024
1 parent 96bf365 commit 43544de
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ WEBUI_ARGS+="$*"
REMOVE_CT=1
SCRIPTDIR="$(dirname "$0")"

LOCAL_GLFTPD_IMAGE=$(
docker image ls --format='{{.Repository}}' --filter reference="$DOCKER_IMAGE_GLFTPD"
)
LOCAL_FULL_GLFTPD_IMAGE=$(
docker image ls --format='{{.Repository}}' --filter reference="${DOCKER_IMAGE_GLFTPD/%:latest/:full}"
)

# check if we already have 'full' tagged image and keep using it if we do
if [ -n "$LOCAL_FULL_GLFTPD_IMAGE" ]; then
DOCKER_IMAGE_GLFTPD="${DOCKER_IMAGE_GLFTPD}:full"
else
REGISTRY_FULL_GLFTPD_IMAGE=$(
docker image ls --format='{{.Repository}}' --filter reference="${DOCKER_REGISTRY}/${DOCKER_IMAGE_GLFTPD/%:latest/:full}"
)
if [ -n "$REGISTRY_FULL_GLFTPD_IMAGE" ] || [ "${USE_FULL:-0}" -eq 1 ]; then
DOCKER_IMAGE_GLFTPD="${REGISTRY_FULL_GLFTPD_IMAGE}:full"
fi
fi

# get external/public ip
if [ -z "$IP_ADDR" ]; then
GET_IP="$( ip route get "$(ip route show 0.0.0.0/0 | grep -oP 'via \K\S+')" | grep -oP 'src \K\S+' )"
Expand Down Expand Up @@ -182,8 +201,6 @@ fi

# remove existing container(s) which use local and/or registry images

#set -x

REGEX_GLFTPD="(glftpd| ${DOCKER_IMAGE_GLFTPD:-'docker-glftpd'}|${DOCKER_REGISTRY}/docker-glftpd)$"
REGEX_WEBUI="(glftpd-web| ${DOCKER_IMAGE_WEBUI:-'docker-glftpd-web'})$"

Expand Down Expand Up @@ -215,27 +232,12 @@ fi

# shellcheck disable=SC2086
if [ "${GLFTPD:-1}" -eq 1 ]; then
LOCAL_GLFTPD_IMAGE=$(
docker image ls --format='{{.Repository}}' --filter reference="$DOCKER_IMAGE_GLFTPD"
)
LOCAL_FULL_GLFTPD_IMAGE=$(
docker image ls --format='{{.Repository}}' --filter reference="${DOCKER_IMAGE_GLFTPD/%:latest/:full}"
)
if [ -n "$LOCAL_GLFTPD_IMAGE" ] && [ "${USE_FULL:-0}" -eq 0 ]; then
echo "* Found local image 'docker-glftpd'"
elif [ -n "$LOCAL_FULL_GLFTPD_IMAGE" ]; then
DOCKER_IMAGE_GLFTPD="${DOCKER_IMAGE_GLFTPD/%:latest/:full}"
echo "* Using full docker image ${LOCAL_FULL_GLFTPD_IMAGE:-""})"
else
# check if we already have 'full' tagged image, then keep using it
REGISTRY_FULL_GLFTPD_IMAGE=$(
docker image ls --format='{{.Repository}}' --filter reference="${DOCKER_REGISTRY}/${DOCKER_IMAGE_GLFTPD/%:latest/:full}"
)
if [ -n "$REGISTRY_FULL_GLFTPD_IMAGE" ] || [ "${USE_FULL:-0}" -eq 1 ]; then
DOCKER_IMAGE_GLFTPD="${DOCKER_IMAGE_GLFTPD/%:latest/:full}"
fi
echo "* Pulling image '${DOCKER_IMAGE_GLFTPD}' from registry '$DOCKER_REGISTRY'"
DOCKER_IMAGE_GLFTPD="${DOCKER_REGISTRY}/$DOCKER_IMAGE_GLFTPD"
echo "* Pulling image from registry '${DOCKER_IMAGE_GLFTPD}'"
docker pull "$DOCKER_IMAGE_GLFTPD"
fi
if [ -n "$DOCKER_IMAGE_GLFTPD" ]; then
Expand All @@ -248,7 +250,10 @@ if [ "${GLFTPD:-1}" -eq 1 ]; then
--network "${NETWORK:-bridge}" \
--workdir /glftpd \
$DOCKER_IMAGE_GLFTPD
echo "* For logs run 'docker logs glftpd'"
echo "* For logs run 'docker logs glftpd'"
else
echo "! Docker image not found"
exit 1
fi
fi

Expand All @@ -274,8 +279,9 @@ if [ "${WEBUI:-1}" -eq 1 ]; then
--name glftpd-web \
--network "${NETWORK:-bridge}" \
$DOCKER_IMAGE_WEBUI
echo "* For logs run 'docker logs glftpd-web'"
else
echo "! Docker image not found"
exit 1
fi
echo "* For logs run 'docker logs glftpd-web'"
fi

echo "* All done."

0 comments on commit 43544de

Please sign in to comment.