diff --git a/Dockerfile b/Dockerfile index 7d31180..2aebbd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM node:lts-slim AS base WORKDIR / COPY run.sh . +COPY fetch-my-mc-connector.js . RUN chmod +x run.sh RUN npm install -g holesail@2.0.3 @@ -16,6 +17,4 @@ ENV ROLE user ENV CONNECTOR "" ENV FORCE "" -WORKDIR /data - ENTRYPOINT [ "/run.sh" ] diff --git a/fetch-my-mc-connector.js b/fetch-my-mc-connector.js new file mode 100644 index 0000000..c23446e --- /dev/null +++ b/fetch-my-mc-connector.js @@ -0,0 +1,13 @@ +const apiKey = process.env.CONNECTOR; + +const result = fetch('https://api.my-mc.link/my-hash',{ + method: "GET", + headers: { + 'Accept': 'application/json', 'Content-Type': 'application/json', 'x-my-mc-auth': apiKey} + }) + .then(async response => { + const r = await response.json(); + if (r.success == true) { + console.log(r.message); + } + }) diff --git a/run.sh b/run.sh index c450389..60458f3 100644 --- a/run.sh +++ b/run.sh @@ -25,6 +25,10 @@ success() { print "$GREEN" "$1" } +get_connector_my-mc() { + printf "$(node /fetch-my-mc-connector.js)" +} + cmd_argument_builder () { local args=""; case "$MODE" in @@ -51,6 +55,11 @@ cmd_argument_builder () { [[ "$ROLE" = "user" ]] && args="$args --role user"; [[ "$CONNECTOR" ]] && args="$args --connector $CONNECTOR"; ;; + "my-mc") + [[ "$PORT" ]] && args="$args --port $PORT"; + [[ "$HOST" ]] && args="$args --host $HOST"; + [[ "$CONNECTOR" ]] && args="$args $(get_connector_my-mc)"; + ;; esac printf "%s" "$args";