fork 0k-charms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

66 lines
1.5 KiB

# -*- mode: shell-script -*-
MINECRAFT_PATH="$SERVICE_CONFIGSTORE/opt/apps/minecraft"
MINECRAFT_DATA="/var/lib/minecraft"
minecraft:init-binary() {
local version="$1"
MINECRAFT_BINARY="${MINECRAFT_PATH}/minecraft_server.${version}.jar"
if ! [ -f "$MINECRAFT_BINARY" ]; then
mkdir -p "${MINECRAFT_PATH}"
wget "https://docker.0k.io/downloads/minecraft_server.${version}.jar" \
-O "$MINECRAFT_BINARY"
fi
init-config-add "
$SERVICE_NAME:
volumes:
- \"${MINECRAFT_BINARY}:${MINECRAFT_DATA}/server.jar\"
"
}
minecraft:init-command() {
local threads="${1:-4}" mem="${2:-2048M}"
init-config-add "
$SERVICE_NAME:
command:
- java
- -Xmx${mem}
- -Xms${mem}
- -XX:ParallelGCThreads=${threads}
- -jar
- server.jar
- nogui
"
echo "eula=TRUE" > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/eula.txt"
}
minecraft:make-whitelist() {
local whitelist="$1"
{
e "$whitelist" |
yq -o=json \
'to_entries | map({"uuid": .key, "name": .value})'
} > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/whitelist.json"
}
minecraft:make-ops() {
local ops="$1"
{
e "$ops" |
yq -o=json \
'to_entries | map({
"uuid": .value.uuid,
"name": .key,
"level": .value.level,
"bypassesPlayerLimit": .value.bypassesPlayerLimit
})'
} > "$SERVICE_DATASTORE/${MINECRAFT_DATA}/ops.json"
}