my-mc-mode #1
60
.gitea/workflows/publish-image.yaml
Normal file
60
.gitea/workflows/publish-image.yaml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
name: Docker Image CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
# schedule:
|
||||||
|
# - cron: "0 10 * * *"
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "**"
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
# list of Docker images to use as base name for tags
|
||||||
|
images: |
|
||||||
|
anaxios/holesail
|
||||||
|
# generate Docker tags based on the following events/attributes
|
||||||
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=sha
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
# - name: Login to GHCR
|
||||||
|
# if: github.event_name != 'pull_request'
|
||||||
|
# uses: docker/login-action@v3
|
||||||
|
# with:
|
||||||
|
# registry: ghcr.io
|
||||||
|
# username: ${{ github.repository_owner }}
|
||||||
|
# password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
11
Dockerfile
11
Dockerfile
@@ -1,10 +1,11 @@
|
|||||||
FROM node:lts-slim AS base
|
FROM node:lts-slim AS base
|
||||||
|
|
||||||
WORKDIR /temp
|
WORKDIR /
|
||||||
COPY run.sh .
|
COPY run.sh .
|
||||||
|
COPY fetch-my-mc-connector.js .
|
||||||
RUN chmod +x run.sh
|
RUN chmod +x run.sh
|
||||||
|
|
||||||
RUN npm install -g holesail@1.10.1
|
RUN npm install -g holesail@2.0.3
|
||||||
|
|
||||||
ENV MODE server
|
ENV MODE server
|
||||||
ENV HOST 0.0.0.0
|
ENV HOST 0.0.0.0
|
||||||
@@ -16,8 +17,4 @@ ENV ROLE user
|
|||||||
ENV CONNECTOR ""
|
ENV CONNECTOR ""
|
||||||
ENV FORCE ""
|
ENV FORCE ""
|
||||||
|
|
||||||
#EXPOSE 8989
|
ENTRYPOINT [ "/run.sh" ]
|
||||||
|
|
||||||
WORKDIR /data
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/temp/run.sh" ]
|
|
||||||
|
13
fetch-my-mc-connector.js
Normal file
13
fetch-my-mc-connector.js
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
})
|
41
run.sh
41
run.sh
@@ -1,5 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
pid=0
|
||||||
|
|
||||||
CYAN="\033[1;96m"
|
CYAN="\033[1;96m"
|
||||||
RED="\033[0;91m"
|
RED="\033[0;91m"
|
||||||
GREEN="\033[0;92m"
|
GREEN="\033[0;92m"
|
||||||
@@ -21,6 +25,10 @@ success() {
|
|||||||
print "$GREEN" "$1"
|
print "$GREEN" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_connector_my-mc() {
|
||||||
|
printf "$(node /fetch-my-mc-connector.js)"
|
||||||
|
}
|
||||||
|
|
||||||
cmd_argument_builder () {
|
cmd_argument_builder () {
|
||||||
local args="";
|
local args="";
|
||||||
case "$MODE" in
|
case "$MODE" in
|
||||||
@@ -47,12 +55,16 @@ cmd_argument_builder () {
|
|||||||
[[ "$ROLE" = "user" ]] && args="$args --role user";
|
[[ "$ROLE" = "user" ]] && args="$args --role user";
|
||||||
[[ "$CONNECTOR" ]] && args="$args --connector $CONNECTOR";
|
[[ "$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
|
esac
|
||||||
|
|
||||||
printf "%s" "$args";
|
printf "%s" "$args";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ARGS="$(cmd_argument_builder)"
|
ARGS="$(cmd_argument_builder)"
|
||||||
|
|
||||||
if [[ ! $ARGS ]]; then
|
if [[ ! $ARGS ]]; then
|
||||||
@@ -60,5 +72,30 @@ if [[ ! $ARGS ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
holesail $ARGS
|
# SIGUSR1-handler
|
||||||
|
# my_handler() {
|
||||||
|
# echo "my_handler"
|
||||||
|
# }
|
||||||
|
|
||||||
|
term_handler() {
|
||||||
|
if [ $pid -ne 0 ]; then
|
||||||
|
kill -SIGTERM "$pid"
|
||||||
|
wait "$pid"
|
||||||
|
fi
|
||||||
|
exit 143; # 128 + 15 -- SIGTERM
|
||||||
|
}
|
||||||
|
|
||||||
|
# setup handlers
|
||||||
|
# on callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler
|
||||||
|
#trap 'kill ${!}; my_handler' SIGUSR1
|
||||||
|
trap 'kill ${!}; term_handler' SIGTERM
|
||||||
|
|
||||||
|
# run application
|
||||||
|
holesail $ARGS &
|
||||||
|
pid="$!"
|
||||||
|
|
||||||
|
# wait forever
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
tail -f /dev/null & wait ${!}
|
||||||
|
done
|
||||||
|
Reference in New Issue
Block a user