diff --git a/entrypoint.sh b/entrypoint.sh index 81e66ee..42b938a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,6 +3,20 @@ toUpperCase() { echo "$*" | tr '[:lower:]' '[:upper:]'; } + +DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL:-"registry.format.hu"} +GLOBAL_VERSION=${GLOBAL_VERSION:-latest} +version_update() { + for JSON in $(ls /etc/user/config/services/*.json); do + IMAGE_NAMES=$(cat $JSON |grep IMAGE |grep $DOCKER_REGISTRY_URL| cut -d '/' -f2 | cut -d '"' -f1 | uniq) + for IMAGE_NAME in $(echo $IMAGE_NAMES); + do IMAGE_NAME=$(echo $IMAGE_NAME | cut -d ':' -f1); + echo $IMAGE_NAME; + sed -i "/$DOCKER_REGISTRY_URL/s/$IMAGE_NAME.*$/$IMAGE_NAME:$GLOBAL_VERSION\",/g" $JSON ; + done + done +} + GIT_REPO=$GIT_REPO if [ "$GIT_REPO" == "" ]; then GIT_REPO=git.format.hu @@ -29,6 +43,14 @@ if [ "$HOST" == "" ]; then HOST=git.format.hu fi +if [ ! -f /root/.ssh/id_rsa ]; then + if [ -f /etc/user/data/installer ]; then + ln -s /etc/user/data/installer /root/.ssh/id_rsa; + fi +else + echo "id_rsa exists" +fi + sed -i "s/GIT_REPO/$GIT_REPO/g" /root/.ssh/config; sed -i "s/HOST/$HOST/g" /root/.ssh/config; sed -i "s/PORT/$PORT/g" /root/.ssh/config; @@ -55,6 +77,7 @@ else # default install fi sh /deploy.sh + version_update; echo "Successfully deployed $PROXY_TYPE" fi