Minecraft server config
This commit is contained in:
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash --pure
|
||||
#! nix-shell -p javaPackages.compiler.openjdk19
|
||||
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/tarball/nixos-25.11
|
||||
|
||||
java -Xmx8192M -Xms6144M -jar minecraft_server.jar nogui
|
||||
read -rp "Press Enter to continue..."
|
||||
@@ -0,0 +1,59 @@
|
||||
#Minecraft server properties
|
||||
#Tue Mar 10 21:38:12 EET 2026
|
||||
allow-flight=true
|
||||
allow-nether=false
|
||||
broadcast-console-to-ops=true
|
||||
broadcast-rcon-to-ops=true
|
||||
difficulty=hard
|
||||
enable-command-block=false
|
||||
enable-jmx-monitoring=false
|
||||
enable-query=false
|
||||
enable-rcon=false
|
||||
enable-status=true
|
||||
enforce-secure-profile=false
|
||||
enforce-whitelist=false
|
||||
entity-broadcast-range-percentage=100
|
||||
force-gamemode=false
|
||||
function-permission-level=2
|
||||
gamemode=survival
|
||||
generate-structures=true
|
||||
generator-settings={}
|
||||
hardcore=false
|
||||
hide-online-players=false
|
||||
initial-disabled-packs=
|
||||
initial-enabled-packs=vanilla
|
||||
level-name=world
|
||||
level-seed=
|
||||
level-type=tfc\:overworld
|
||||
max-chained-neighbor-updates=1000000
|
||||
max-players=64
|
||||
max-tick-time=600000
|
||||
max-world-size=29999984
|
||||
motd=[TerraFirmaGreg-Modern] Server 0.11.21
|
||||
network-compression-threshold=256
|
||||
online-mode=false
|
||||
op-permission-level=4
|
||||
player-idle-timeout=0
|
||||
prevent-proxy-connections=false
|
||||
pvp=true
|
||||
query.port=25565
|
||||
rate-limit=0
|
||||
rcon.ip=0.0.0.0
|
||||
rcon.password=
|
||||
rcon.port=25575
|
||||
require-resource-pack=false
|
||||
resource-pack=
|
||||
resource-pack-prompt=
|
||||
resource-pack-sha1=
|
||||
server-ip=0.0.0.0
|
||||
server-port=25565
|
||||
simulation-distance=8
|
||||
spawn-animals=true
|
||||
spawn-monsters=true
|
||||
spawn-npcs=true
|
||||
spawn-protection=16
|
||||
sync-chunk-writes=true
|
||||
text-filtering-config=
|
||||
use-native-transport=true
|
||||
view-distance=8
|
||||
white-list=false
|
||||
Regular → Executable
+5
-1
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
# ---- Clone the config repo ----
|
||||
cd /root
|
||||
@@ -22,3 +22,7 @@ cp root/etc/nixos/configuration.nix /mnt/etc/nixos/configuration.nix
|
||||
# ---- User configuration ----
|
||||
mkdir --parents /mnt/home/h3lp
|
||||
cp root/home/h3lp/shell.nix /mnt/home/h3lp/shell.nix
|
||||
|
||||
|
||||
# ---- Install NixOS ----
|
||||
nixos-install --no-root-passwd
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
SERVERPACK=https://20111511.xyz/serverpack.tar.xz
|
||||
WORLD=https://20111511.xyz/world.tar.xz
|
||||
@@ -0,0 +1,11 @@
|
||||
1) Fetch https://gitea.20111511.xyz/h3lp/autodeploy.git and checkout cavemen branch
|
||||
2) minecraft.env will contain the following urls:
|
||||
SERVERPACK=https://20111511.xyz/TerraFirmaGreg-Modern-0.11.21-serverpack.zip
|
||||
WORLD=https://20111511.xyz/world.tar.xz
|
||||
and a cavemen folder with following structure
|
||||
.
|
||||
├── nixrunserver.sh
|
||||
└── server.properties
|
||||
3) Download and extract SERVERPACK to /home/h3lp/mineserver
|
||||
4) Download and extract WORLD to /home/h3lp/mineserver/world
|
||||
5) Move and overwrite all files from cloned git repository cavemen/* to /home/h3lp/mineserver/
|
||||
@@ -123,6 +123,9 @@
|
||||
neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
|
||||
wget
|
||||
tmux
|
||||
git
|
||||
curl
|
||||
unzip
|
||||
];
|
||||
|
||||
# Enable the OpenSSH daemon.
|
||||
@@ -147,17 +150,68 @@
|
||||
|
||||
networking.firewall.enable = false;
|
||||
|
||||
systemd.user.services.tmux = {
|
||||
description = "Tmux session manager";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "default.target" ];
|
||||
systemd.services.minecraft-setup = {
|
||||
description = "Minecraft Server Initial Setup";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" "minecraft-setup.service" ]; # wait for setup
|
||||
requires = [ "minecraft-setup.service" ]; # and fail if setup fails
|
||||
|
||||
# Only run if setup hasn't been completed yet
|
||||
unitConfig.ConditionPathExists = "!/home/h3lp/mineserver/.setup-done";
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.tmux}/bin/tmux new -A -s main";
|
||||
Restart = "always";
|
||||
RestartSec = 5;
|
||||
Type = "oneshot";
|
||||
User = "h3lp";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
|
||||
script = ''
|
||||
set -e
|
||||
|
||||
MINESERVER=/home/h3lp/mineserver
|
||||
TMPDIR=$(mktemp -d)
|
||||
|
||||
# 1) Clone repo and checkout cavemen branch
|
||||
${pkgs.git}/bin/git clone --branch cavemen \
|
||||
https://gitea.20111511.xyz/h3lp/autodeploy.git "$TMPDIR/autodeploy"
|
||||
|
||||
# 2) Read env vars from minecraft.env
|
||||
source "$TMPDIR/autodeploy/minecraft.env"
|
||||
|
||||
# 3) Download and extract server pack to /home/h3lp/mineserver
|
||||
mkdir -p "$MINESERVER"
|
||||
${pkgs.curl}/bin/curl -L "$SERVERPACK" -o "$TMPDIR/serverpack.tar.xz"
|
||||
${pkgs.gnutar}/bin/tar -xJf "$TMPDIR/serverpack.tar.xz" -C "$MINESERVER"
|
||||
|
||||
# 4) Download and extract world to /home/h3lp/mineserver/world
|
||||
mkdir -p "$MINESERVER/world"
|
||||
${pkgs.curl}/bin/curl -L "$WORLD" -o "$TMPDIR/world.tar.xz"
|
||||
# world.tar.xz contains world folder, otherwise use "$MINESERVER/world"
|
||||
${pkgs.gnutar}/bin/tar -xJf "$TMPDIR/world.tar.xz" -C "$MINESERVER"
|
||||
|
||||
# 5) Copy cavemen/* files over, overwriting existing
|
||||
cp -rf "$TMPDIR/autodeploy/cavemen/." "$MINESERVER/"
|
||||
chmod +x "$MINESERVER/nixrunserver.sh"
|
||||
|
||||
# Cleanup and mark setup as done
|
||||
rm -rf "$TMPDIR"
|
||||
touch "$MINESERVER/.setup-done"
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.services.minecraft = {
|
||||
description = "Minecraft Server";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "forking";
|
||||
User = "h3lp";
|
||||
WorkingDirectory = "/home/h3lp/mineserver";
|
||||
ExecStart = "${pkgs.tmux}/bin/tmux new-session -d -s minecraft /home/h3lp/mineserver/nixrunserver.sh";
|
||||
ExecStop = "${pkgs.tmux}/bin/tmux send-keys -t minecraft 'stop' Enter";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user