Files
autodeploy/cavemen/nixrunserver.sh
T
2026-03-14 01:11:24 +02:00

24 lines
655 B
Bash
Executable File

#!/usr/bin/env nix-shell
#! nix-shell -i bash --pure
#! nix-shell -p javaPackages.compiler.openjdk17
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/tarball/nixos-25.11
source /home/h3lp/mineserver/minecraft.env
java -Xmx${MEMORY_MAX}M -Xms${MEMORY_MIN}M -jar minecraft_server.jar nogui
read -rp "Pack and publish world? [y/N] " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
set -e
WORLD=/home/h3lp/mineserver/world
OUTPUT=/var/www/hostedfiles/world.tar.xz
TMP=$(mktemp)
tar -cJf "$TMP" -C "$WORLD" .
mv "$TMP" "$OUTPUT"
chmod 644 "$OUTPUT"
echo "Done: $OUTPUT"
set +e
fi
read -rp "Press Enter to continue..."