Compare commits
16 Commits
012cc74576
...
2.2.0
Author | SHA1 | Date | |
---|---|---|---|
ec77f5adce | |||
d8624be9fe | |||
0478070458 | |||
b3e636e36a | |||
57172a3609 | |||
87686bf4f7 | |||
29e00d6002 | |||
21b21ce73c | |||
4a7fbef176 | |||
a1ec0ba829 | |||
6d78af4d3a | |||
85428100c0 | |||
407cfcfb69 | |||
5e03c2c30d | |||
9c1d769ed8 | |||
7989b82c04 |
@@ -55,6 +55,7 @@ jobs:
|
|||||||
- name: Build and push
|
- name: Build and push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
27
Dockerfile
27
Dockerfile
@@ -1,20 +1,23 @@
|
|||||||
FROM node:lts-slim AS base
|
FROM node:lts-slim AS base
|
||||||
|
|
||||||
|
RUN npm install -g holesail@2.2.0
|
||||||
|
|
||||||
|
FROM base AS dev
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY run.sh .
|
COPY run.sh .
|
||||||
COPY fetch-my-mc-connector.js .
|
COPY fetch-my-mc-connector.js .
|
||||||
RUN chmod +x run.sh
|
RUN chmod +x run.sh
|
||||||
|
|
||||||
RUN npm install -g holesail@2.0.3
|
ENV MODE=server
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=8989
|
||||||
|
ENV PUBLIC=true
|
||||||
|
ENV USERNAME=admin
|
||||||
|
ENV PASSWORD=admin
|
||||||
|
ENV ROLE=user
|
||||||
|
ENV KEY=""
|
||||||
|
ENV MY_MC_API_KEY=""
|
||||||
|
#ENV FORCE ""
|
||||||
|
|
||||||
ENV MODE server
|
CMD [ "/usr/bin/bash", "/run.sh" ]
|
||||||
ENV HOST 0.0.0.0
|
|
||||||
ENV PORT 8989
|
|
||||||
ENV PUBLIC true
|
|
||||||
ENV USERNAME admin
|
|
||||||
ENV PASSWORD admin
|
|
||||||
ENV ROLE user
|
|
||||||
ENV CONNECTOR ""
|
|
||||||
ENV FORCE ""
|
|
||||||
|
|
||||||
ENTRYPOINT [ "/run.sh" ]
|
|
||||||
|
12
README.md
12
README.md
@@ -17,7 +17,7 @@ The following environment variables are available:
|
|||||||
- HOST: The hostname or IP address to use for the client or server mode.
|
- HOST: The hostname or IP address to use for the client or server mode.
|
||||||
- PUBLIC: A boolean value indicating whether the server should use a public connetor string. Only applicable in server mode.
|
- PUBLIC: A boolean value indicating whether the server should use a public connetor string. Only applicable in server mode.
|
||||||
- FORCE: A boolean value indicating whether to force a short connector string of less than 32 chars. Only applicable in server and filemanager modes.
|
- FORCE: A boolean value indicating whether to force a short connector string of less than 32 chars. Only applicable in server and filemanager modes.
|
||||||
- CONNECTOR: A connector string used to identify the connection. Can be used in client, server, and filemanager modes.
|
- KEY: A string used to identify the connection. Can be used in client, server, and filemanager modes.
|
||||||
- USERNAME: The username to use for authentication in filemanager mode.
|
- USERNAME: The username to use for authentication in filemanager mode.
|
||||||
- PASSWORD: The password to use for authentication in filemanager mode.
|
- PASSWORD: The password to use for authentication in filemanager mode.
|
||||||
- ROLE: The role to assign to the user in filemanager mode. Can be either admin or user.
|
- ROLE: The role to assign to the user in filemanager mode. Can be either admin or user.
|
||||||
@@ -41,7 +41,7 @@ docker run -d --name holesail \
|
|||||||
-e MODE=server \
|
-e MODE=server \
|
||||||
-e PORT=25565 \
|
-e PORT=25565 \
|
||||||
-e HOST=minecraft \
|
-e HOST=minecraft \
|
||||||
-e CONNECTOR=very-super-secret \
|
-e KEY=very-super-secret \
|
||||||
-e PUBLIC=false \
|
-e PUBLIC=false \
|
||||||
--network holesail \
|
--network holesail \
|
||||||
anaxios/holesail:latest
|
anaxios/holesail:latest
|
||||||
@@ -66,7 +66,7 @@ services:
|
|||||||
PORT: 25565
|
PORT: 25565
|
||||||
HOST: minecraft
|
HOST: minecraft
|
||||||
PUBLIC: false
|
PUBLIC: false
|
||||||
CONNECTOR: very-super-secret
|
KEY: very-super-secret
|
||||||
networks:
|
networks:
|
||||||
- holesail
|
- holesail
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ services:
|
|||||||
PORT: 8989
|
PORT: 8989
|
||||||
HOST: 0.0.0.0
|
HOST: 0.0.0.0
|
||||||
PUBLIC: false
|
PUBLIC: false
|
||||||
CONNECTOR: very-super-secret
|
KEY: very-super-secret
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** Client mode only works on Linux, and is incompatible with Windows and Mac.
|
**Note:** Client mode only works on Linux, and is incompatible with Windows and Mac.
|
||||||
@@ -131,7 +131,7 @@ services:
|
|||||||
ROLE: user
|
ROLE: user
|
||||||
USERNAME: admin
|
USERNAME: admin
|
||||||
PASSWORD: admin
|
PASSWORD: admin
|
||||||
CONNECTOR: very-super-secret
|
KEY: very-super-secret
|
||||||
volumes:
|
volumes:
|
||||||
- <host dir>:/data
|
- <host dir>:/data
|
||||||
```
|
```
|
||||||
@@ -153,7 +153,7 @@ services:
|
|||||||
PORT: 25565
|
PORT: 25565
|
||||||
HOST: minecraft
|
HOST: minecraft
|
||||||
PUBLIC: false
|
PUBLIC: false
|
||||||
CONNECTOR: very-super-secret
|
KEY: very-super-secret
|
||||||
networks:
|
networks:
|
||||||
- holesail
|
- holesail
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
const apiKey = process.env.CONNECTOR;
|
const apiKey = process.env.MY_MC_API_KEY;
|
||||||
|
|
||||||
const result = fetch('https://api.my-mc.link/my-hash',{
|
const result = fetch('https://api.my-mc.link/my-hash',{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@@ -9,5 +9,9 @@ const result = fetch('https://api.my-mc.link/my-hash',{
|
|||||||
const r = await response.json();
|
const r = await response.json();
|
||||||
if (r.success == true) {
|
if (r.success == true) {
|
||||||
console.log(r.message);
|
console.log(r.message);
|
||||||
|
} else {
|
||||||
|
throw new Error("failed to fetch holesail key");
|
||||||
}
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
throw Error(err);
|
||||||
})
|
})
|
||||||
|
46
run.sh
46
run.sh
@@ -25,8 +25,8 @@ success() {
|
|||||||
print "$GREEN" "$1"
|
print "$GREEN" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_connector_my-mc() {
|
get_connector_my_mc() {
|
||||||
printf "$(node /fetch-my-mc-connector.js)"
|
KEY="$(/usr/local/bin/node /fetch-my-mc-connector.js)"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_argument_builder () {
|
cmd_argument_builder () {
|
||||||
@@ -35,14 +35,16 @@ cmd_argument_builder () {
|
|||||||
"client")
|
"client")
|
||||||
[[ "$PORT" ]] && args="$args --port $PORT";
|
[[ "$PORT" ]] && args="$args --port $PORT";
|
||||||
[[ "$HOST" ]] && args="$args --host $HOST";
|
[[ "$HOST" ]] && args="$args --host $HOST";
|
||||||
[[ "$CONNECTOR" ]] && args="$args $CONNECTOR";
|
[[ "$KEY" ]] && args="$args --connect $KEY";
|
||||||
|
[[ "$UDP" = "true" ]] && args="$args --udp";
|
||||||
;;
|
;;
|
||||||
"server")
|
"server")
|
||||||
[[ "$PORT" ]] && args="$args --live $PORT";
|
[[ "$PORT" ]] && args="$args --live $PORT";
|
||||||
[[ "$HOST" ]] && args="$args --host $HOST";
|
[[ "$HOST" ]] && args="$args --host $HOST";
|
||||||
[[ "$PUBLIC" = "true" ]] && args="$args --public";
|
[[ "$PUBLIC" = "true" ]] && args="$args --public";
|
||||||
[[ "$FORCE" = "true" ]] && args="$args --force";
|
[[ "$FORCE" = "true" ]] && args="$args --force";
|
||||||
[[ "$CONNECTOR" ]] && args="$args --connector $CONNECTOR";
|
[[ "$KEY" ]] && args="$args --key $KEY";
|
||||||
|
[[ "$UDP" = "true" ]] && args="$args --udp";
|
||||||
;;
|
;;
|
||||||
"filemanager")
|
"filemanager")
|
||||||
args="--filemanager";
|
args="--filemanager";
|
||||||
@@ -53,29 +55,25 @@ cmd_argument_builder () {
|
|||||||
[[ "$PASSWORD" ]] && args="$args --password $PASSWORD";
|
[[ "$PASSWORD" ]] && args="$args --password $PASSWORD";
|
||||||
[[ "$ROLE" = "admin" ]] && args="$args --role admin";
|
[[ "$ROLE" = "admin" ]] && args="$args --role admin";
|
||||||
[[ "$ROLE" = "user" ]] && args="$args --role user";
|
[[ "$ROLE" = "user" ]] && args="$args --role user";
|
||||||
[[ "$CONNECTOR" ]] && args="$args --connector $CONNECTOR";
|
[[ "$KEY" ]] && args="$args --key $KEY";
|
||||||
|
[[ "$UDP" = "true" ]] && args="$args --udp";
|
||||||
;;
|
;;
|
||||||
"my-mc")
|
"my-mc")
|
||||||
|
if ! get_connector_my_mc; then exit 1; fi
|
||||||
[[ "$PORT" ]] && args="$args --port $PORT";
|
[[ "$PORT" ]] && args="$args --port $PORT";
|
||||||
[[ "$HOST" ]] && args="$args --host $HOST";
|
[[ "$HOST" ]] && args="$args --host $HOST";
|
||||||
[[ "$CONNECTOR" ]] && args="$args $(get_connector_my-mc)";
|
[[ "$KEY" ]] && args="$args --connect $KEY";
|
||||||
|
[[ "$UDP" = "true" ]] && args="$args --udp";
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
printf "%s" "$args";
|
printf "%s" "$args";
|
||||||
}
|
}
|
||||||
|
|
||||||
ARGS="$(cmd_argument_builder)"
|
|
||||||
|
|
||||||
if [[ ! $ARGS ]]; then
|
|
||||||
error "Invalid Mode."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# SIGUSR1-handler
|
# SIGUSR1-handler
|
||||||
# my_handler() {
|
my_handler() {
|
||||||
# echo "my_handler"
|
echo "my_handler"
|
||||||
# }
|
}
|
||||||
|
|
||||||
term_handler() {
|
term_handler() {
|
||||||
if [ $pid -ne 0 ]; then
|
if [ $pid -ne 0 ]; then
|
||||||
@@ -85,17 +83,25 @@ term_handler() {
|
|||||||
exit 143; # 128 + 15 -- SIGTERM
|
exit 143; # 128 + 15 -- SIGTERM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ARGS="$(cmd_argument_builder)"
|
||||||
|
|
||||||
|
if [[ ! $ARGS ]]; then
|
||||||
|
error "Invalid Mode."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# setup handlers
|
# setup handlers
|
||||||
# on callback, kill the last background process, which is `tail -f /dev/null` and execute the specified handler
|
# 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 ${!}; my_handler' SIGUSR1
|
||||||
trap 'kill ${!}; term_handler' SIGTERM
|
trap 'kill ${!}; term_handler' SIGTERM SIGINT
|
||||||
|
|
||||||
# run application
|
# run application
|
||||||
holesail $ARGS &
|
/usr/local/bin/holesail $ARGS &
|
||||||
pid="$!"
|
pid="$!"
|
||||||
|
|
||||||
# wait forever
|
# wait forever
|
||||||
while true
|
while true; do
|
||||||
do
|
|
||||||
tail -f /dev/null & wait ${!}
|
tail -f /dev/null & wait ${!}
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user