diff --git a/.github/workflows/graalvm.yml b/.github/workflows/graalvm.yml new file mode 100644 index 0000000..b900b8b --- /dev/null +++ b/.github/workflows/graalvm.yml @@ -0,0 +1,45 @@ +name: build graalvm +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * 1" + push: + branches: + - master + paths: + - graalvm/** +jobs: + push: + name: "yolks:graalvm_${{ matrix.tag }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + tag: + - 11 + - 17 + - 19 + - 17-JDK + - 20-JDK + - 21-JDK + - 11-EE + - 17-EE + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v2 + with: + buildkitd-flags: --debug + - uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/build-push-action@v4 + with: + context: ./graalvm + file: ./graalvm/${{ matrix.tag }}/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/darksaid98/yolks:graalvm_${{ matrix.tag }} diff --git a/graalvm/11-EE/Dockerfile b/graalvm/11-EE/Dockerfile new file mode 100644 index 0000000..a9a201b --- /dev/null +++ b/graalvm/11-EE/Dockerfile @@ -0,0 +1,65 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=22.3.2 +ARG JAVA_VERSION=11 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=linux-amd64 ;; \ + "linux/arm64") ARCH=linux-aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://oca.opensource.oracle.com/gds/GRAALVM_EE_JAVA11_22_3_2/graalvm-ee-java11-${ARCH}-22.3.2.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] diff --git a/graalvm/11/Dockerfile b/graalvm/11/Dockerfile new file mode 100644 index 0000000..41dcc65 --- /dev/null +++ b/graalvm/11/Dockerfile @@ -0,0 +1,65 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=22.3.3 +ARG JAVA_VERSION=11 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=amd64 ;; \ + "linux/arm64") ARCH=aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-java${JAVA_VERSION}-linux-${ARCH}-${GRAAL_VERSION}.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] diff --git a/graalvm/17-EE/Dockerfile b/graalvm/17-EE/Dockerfile new file mode 100644 index 0000000..805dedd --- /dev/null +++ b/graalvm/17-EE/Dockerfile @@ -0,0 +1,65 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=22.3.2 +ARG JAVA_VERSION=17 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=linux-amd64 ;; \ + "linux/arm64") ARCH=linux-aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://oca.opensource.oracle.com/gds/GRAALVM_EE_JAVA17_22_3_2/graalvm-ee-java17-${ARCH}-22.3.2.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] diff --git a/graalvm/17-JDK/Dockerfile b/graalvm/17-JDK/Dockerfile new file mode 100644 index 0000000..71f52e4 --- /dev/null +++ b/graalvm/17-JDK/Dockerfile @@ -0,0 +1,65 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=17.0.8 +ARG JAVA_VERSION=17 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=x64 ;; \ + "linux/arm64") ARCH=aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${GRAAL_VERSION}/graalvm-community-jdk-${GRAAL_VERSION}_linux-${ARCH}_bin.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] diff --git a/graalvm/17/Dockerfile b/graalvm/17/Dockerfile new file mode 100644 index 0000000..24ec5a0 --- /dev/null +++ b/graalvm/17/Dockerfile @@ -0,0 +1,65 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=22.3.3 +ARG JAVA_VERSION=17 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=amd64 ;; \ + "linux/arm64") ARCH=aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-java${JAVA_VERSION}-linux-${ARCH}-${GRAAL_VERSION}.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] diff --git a/graalvm/19/Dockerfile b/graalvm/19/Dockerfile new file mode 100644 index 0000000..fbc5122 --- /dev/null +++ b/graalvm/19/Dockerfile @@ -0,0 +1,65 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=22.3.1 +ARG JAVA_VERSION=19 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=amd64 ;; \ + "linux/arm64") ARCH=aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VERSION}/graalvm-ce-java${JAVA_VERSION}-linux-${ARCH}-${GRAAL_VERSION}.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] diff --git a/graalvm/20-JDK/Dockerfile b/graalvm/20-JDK/Dockerfile new file mode 100644 index 0000000..b9ce0c5 --- /dev/null +++ b/graalvm/20-JDK/Dockerfile @@ -0,0 +1,65 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=20.0.2 +ARG JAVA_VERSION=20 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=x64 ;; \ + "linux/arm64") ARCH=aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${GRAAL_VERSION}/graalvm-community-jdk-${GRAAL_VERSION}_linux-${ARCH}_bin.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] diff --git a/graalvm/21-JDK/Dockerfile b/graalvm/21-JDK/Dockerfile new file mode 100644 index 0000000..0cec68d --- /dev/null +++ b/graalvm/21-JDK/Dockerfile @@ -0,0 +1,66 @@ +# ---------------------------------- +# Pterodactyl Core Dockerfile +# Environment: Java +# Minimum Panel Version: 1.7.0 +# ---------------------------------- +FROM ubuntu:22.04 + +ARG TARGETPLATFORM +ARG GRAAL_VERSION=21.0.0 +ARG JAVA_VERSION=21 + +LABEL author="darksaid98" maintainer="kontakt@riko.dev" + +LABEL org.opencontainers.image.source="https://github.com/pterodactyl/yolks" + +ENV DEBIAN_FRONTEND=noninteractive + +# Default to UTF-8 file.encoding +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt update -y \ + && apt-get install -y \ + curl \ + lsof \ + ca-certificates \ + openssl \ + git \ + git-lfs \ + tar \ + sqlite3 \ + fontconfig \ + tzdata \ + locales \ + iproute2 \ + libfreetype6 \ + tini \ + && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && case ${TARGETPLATFORM} in \ + "linux/amd64") ARCH=x64 ;; \ + "linux/arm64") ARCH=aarch64 ;; \ + esac \ + && curl --retry 3 -Lfso /tmp/graalvm.tar.gz https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${GRAAL_VERSION}/graalvm-community-jdk-${GRAAL_VERSION}_linux-${ARCH}_bin.tar.gz \ + && mkdir -p /opt/java/graalvm \ + && cd /opt/java/graalvm \ + && tar -xf /tmp/graalvm.tar.gz --strip-components=1 \ + && export PATH="/opt/java/graalvm/bin:$PATH" \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /tmp/graalvm.tar.gz + +ENV JAVA_HOME=/opt/java/graalvm \ + PATH="/opt/java/graalvm/bin:$PATH" + +## Setup user and working directory +RUN useradd -m -d /home/container -s /bin/bash container +USER container +ENV USER=container HOME=/home/container +WORKDIR /home/container + +STOPSIGNAL SIGINT + +COPY --chown=container:container ./../entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/usr/bin/tini", "-g", "--"] +CMD ["/entrypoint.sh"] + diff --git a/graalvm/entrypoint.sh b/graalvm/entrypoint.sh new file mode 100644 index 0000000..4f7e04f --- /dev/null +++ b/graalvm/entrypoint.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +# +# Copyright (c) 2021 Matthew Penner +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +# Default the TZ environment variable to UTC. +TZ=${TZ:-UTC} +export TZ + +# Set environment variable that holds the Internal Docker IP +INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}') +export INTERNAL_IP + +# Switch to the container's working directory +cd /home/container || exit 1 + +# Update repo from git +if [ "${GIT_ENABLED}" == "false" ] || [ "${GIT_ENABLED}" == "0" ]; then + echo -e "Git enabled." + + ## add git ending if it's not on the address + if [[ ${GIT_ADDRESS} != *.git ]]; then + GIT_ADDRESS=${GIT_ADDRESS}.git + fi + + if [ -z "${GIT_USERNAME}" ] && [ -z "${GIT_ACCESS_TOKEN}" ]; then + echo -e "Git Username or Git Token was not specified. Proceeding anonymously." + else + GIT_ADDRESS="https://${GIT_USERNAME}:${GIT_ACCESS_TOKEN}@$(echo -e ${GIT_ADDRESS} | cut -d/ -f3-)" + fi + + + if [ "$(ls -A /home/container)" ]; then + echo -e "/home/container directory is not empty." + + # Get git origin from /home/container/.git/config + if [ -d .git ]; then + echo -e ".git directory exists" + if [ -f .git/config ]; then + echo -e "loading info from git config" + ORIGIN=$(git config --get remote.origin.url) + else + echo -e "files found with no git config" + echo -e "closing out without touching things to not break anything" + exit 10 + fi + fi + + # If git origin matches the repo specified by user then pull + if [ "${ORIGIN}" == "${GIT_ADDRESS}" ]; then + echo "pulling latest from github" + git pull && echo "Finished pulling /home/container from Git." || echo "Failed pulling /home/container from Git." + fi + else + # No files exist in resources folder, clone + echo -e "/home/container is empty.\ncloning files into repo" + if [ -z ${GIT_BRANCH} ]; then + echo -e "Cloning default branch into /home/container." + git clone ${GIT_ADDRESS} . + else + echo -e "Cloning ${GIT_BRANCH} branch into /home/container." + git clone --single-branch --branch ${GIT_BRANCH} ${GIT_ADDRESS} . && echo "Finished cloning into /home/container from Git." || echo "Failed cloning into /home/container from Git." + fi + fi +else + echo -e "Git disabled." +fi + +# Print Java version +printf "\033[1m\033[33mcontainer@pterodactyl~ \033[0mjava -version\n" +java -version + +# Convert all of the "{{VARIABLE}}" parts of the command into the expected shell +# variable format of "${VARIABLE}" before evaluating the string and automatically +# replacing the values. +PARSED=$(echo "${STARTUP}" | sed -e 's/{{/${/g' -e 's/}}/}/g' | eval echo "$(cat -)") + +# Display the command we're running in the output, and then execute it with the env +# from the container itself. +printf "\033[1m\033[33mcontainer@pterodactyl~ \033[0m%s\n" "$PARSED" +# shellcheck disable=SC2086 +eval ${PARSED}