From 946366309c181817ca1e09028444ec9e9593ea46 Mon Sep 17 00:00:00 2001 From: h3lp Date: Wed, 11 Mar 2026 16:31:08 +0200 Subject: [PATCH] Minecraft world download flow --- cavemen/nixrunserver.sh | 6 ++++++ cavemen/packworld.sh | 15 +++++++++++++++ root/etc/nixos/configuration.nix | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100755 cavemen/packworld.sh diff --git a/cavemen/nixrunserver.sh b/cavemen/nixrunserver.sh index 2379a48..29a1c47 100755 --- a/cavemen/nixrunserver.sh +++ b/cavemen/nixrunserver.sh @@ -4,4 +4,10 @@ #! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/tarball/nixos-25.11 java -Xmx8192M -Xms6144M -jar minecraft_server.jar nogui + +read -rp "Pack and publish world? [y/N] " answer +if [[ "$answer" =~ ^[Yy]$ ]]; then + /home/h3lp/mineserver/packworld.sh +fi + read -rp "Press Enter to continue..." diff --git a/cavemen/packworld.sh b/cavemen/packworld.sh new file mode 100755 index 0000000..a6eed05 --- /dev/null +++ b/cavemen/packworld.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash --pure +#! nix-shell -p gnutar xz +#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/tarball/nixos-25.11 + +set -e + +WORLD=/home/h3lp/mineserver/world +OUTPUT=/var/www/hostedfiles/world.tar.xz +TMP=$(mktemp) + +tar -cJf "$TMP" -C "$WORLD" . +mv "$TMP" "$OUTPUT" + +echo "Done: $OUTPUT" diff --git a/root/etc/nixos/configuration.nix b/root/etc/nixos/configuration.nix index b78d2e9..f5bc9a0 100644 --- a/root/etc/nixos/configuration.nix +++ b/root/etc/nixos/configuration.nix @@ -127,6 +127,7 @@ curl unzip xz + nginx ]; # Enable the OpenSSH daemon. @@ -218,4 +219,17 @@ }; }; + services.nginx = { + enable = true; + virtualHosts."_" = { + root = "/var/www/hostedfiles"; + locations."/" = { + extraConfig = "autoindex on;"; + }; + }; + }; + + systemd.tmpfiles.rules = [ + "d /var/www/hostedfiles 0755 h3lp h3lp -" + ]; }