feature: add support for custom port with connect command.

This commit is contained in:
2025-07-22 20:36:04 -07:00
parent cfe8767cf8
commit b5face6cb7

5
mc
View File

@@ -43,7 +43,7 @@ declare -rA commands=(
[search]='search POST {"mod":"%s"} Search for mods by name or id.'
[mod-list]='mod-list GET {} Get list of mods installed on ther server.'
[backup]='backup FUNC {} EXPERIMENTAL! Make a local copy of server files over sftp.'
[connect]='connect FUNC {} Open a connection to server using docker-holesail on port 25565.'
[connect]='connect FUNC {port} Open a connection to server using docker. Leave arg blank for default 25565.'
[check-update]='check_update FUNC {game_version} Check installed mods have available version.'
[version]='version FUNC {} Check the version of Minecraft the server is running.'
)
@@ -83,10 +83,11 @@ function check_update() {
}
function connect() {
local port="${1:-25565}"
if [[ ! $(which docker) ]]; then echo "docker is required"; exit 1; fi
docker run --rm \
-e MODE=my-mc \
-e PORT=25565 \
-e PORT=$port \
-e HOST=0.0.0.0 \
-e PUBLIC=false \
-e MY_MC_API_KEY=$MY_MC_API_KEY \