From 2791df71ca9afa5deec80be45ad2a8f00c33c0e0 Mon Sep 17 00:00:00 2001 From: set Date: Mon, 30 Jun 2025 21:14:33 +0200 Subject: [PATCH 1/3] migrate installation-only files to under installer dir --- installer/bootstrap | 96 +++++++++++++----- .../proxy/plugins/vane-velocity/config.toml | 0 .../default_config/proxy/velocity.toml | 0 .../default_config/server}/.gitignore | 0 .../default_config/server}/backup.sh | 0 .../default_config/server/commands.yml | 0 .../server/config/paper-global.yml | 0 .../server/config/paper-world-defaults.yml | 0 .../server/plugins/BlueMap/core.conf | 0 .../default_config/server}/server-icon.png | Bin .../default_config/server/server.properties | 0 .../default_config/server/spigot.yml | 0 .../default_config/server}/start.sh | 0 .../default_config/server}/update.sh | 0 {contrib => installer}/minecraft-attach | 0 {contrib => installer/systemd}/install.sh | 10 +- .../systemd/minecraft-proxy.service | 0 .../systemd/minecraft-server.service | 0 18 files changed, 75 insertions(+), 31 deletions(-) rename {contrib => installer}/default_config/proxy/plugins/vane-velocity/config.toml (100%) rename {contrib => installer}/default_config/proxy/velocity.toml (100%) rename {server => installer/default_config/server}/.gitignore (100%) rename {server => installer/default_config/server}/backup.sh (100%) rename {contrib => installer}/default_config/server/commands.yml (100%) rename {contrib => installer}/default_config/server/config/paper-global.yml (100%) rename {contrib => installer}/default_config/server/config/paper-world-defaults.yml (100%) rename {contrib => installer}/default_config/server/plugins/BlueMap/core.conf (100%) rename {server => installer/default_config/server}/server-icon.png (100%) rename {contrib => installer}/default_config/server/server.properties (100%) rename {contrib => installer}/default_config/server/spigot.yml (100%) rename {server => installer/default_config/server}/start.sh (100%) rename {server => installer/default_config/server}/update.sh (100%) rename {contrib => installer}/minecraft-attach (100%) rename {contrib => installer/systemd}/install.sh (81%) rename {contrib => installer}/systemd/minecraft-proxy.service (100%) rename {contrib => installer}/systemd/minecraft-server.service (100%) diff --git a/installer/bootstrap b/installer/bootstrap index e1b85b4..40400d0 100755 --- a/installer/bootstrap +++ b/installer/bootstrap @@ -5,6 +5,9 @@ set -uo pipefail umask 077 TTY="/dev/$(ps -p $$ -o tty=)" +INSTALL_DIR='/var/lib/minecraft' +DEPLOY_DIR='deploy' + ################################################################ # Helper functions @@ -31,6 +34,43 @@ function install_file() { chmod "$4" "$2" || die "Could not chmod '$2'" } +# $1: Variable to store result array into +# $2: Prompt (string) +function ask_array() { + # Indirectly reference result array + declare -n ref=$1 + ref=() + + # Prompt the user for their choice(s) + flush_stdin + read -r -p "$2" ref < $TTY || die "Error in read" + + # Check if input is empty (user selected none) + if [ -z "$ref" ]; then + ask_array $1 $2 + fi +} + +# $1: Directory FROM +# $2: Directory TO (NO END SLASH) +function install_folder() { + mkdir -p -m700 "$2" || die "Could not create directory '$2'" + chown minecraft: "$2" || die "Could not chown directory '$2'" + for d in $(find "$1" -type d -printf '%P\n'); do + mkdir -p -m700 "$2/$d" || die "Could not create directory '$d'" + chown minecraft: "$2/$d" || die "Could not chown directory '$d'" + done + + for f in $(find "$1" -type f -printf '%P\n'); do + # If the file ends in .sh, make it executable + if [[ "$f" == *.sh ]]; then + install_file "$1/$f" "$2/$f" minecraft: 700 + else + install_file "$1/$f" "$2/$f" minecraft: 600 + fi + done +} + ################################################################ # Ensure that all required tools are installed @@ -80,53 +120,50 @@ ask "Do you agree to the EULA?" \ if ! getent passwd minecraft &>/dev/null; then status "Creating minecraft user" - useradd --system --home-dir /var/lib/minecraft --no-create-home minecraft \ + useradd --system --home-dir "$INSTALL_DIR" --no-create-home minecraft \ || die "Could not create user 'minecraft'" fi -mkdir -p /var/lib/minecraft -chmod 700 /var/lib/minecraft -chown minecraft: /var/lib/minecraft +mkdir -p "$INSTALL_DIR" +chmod 700 "$INSTALL_DIR" +chown minecraft: "$INSTALL_DIR" ################################################################ # Setup repository -if [[ -e /var/lib/minecraft/deploy ]]; then - echo "The deploy directory /var/lib/minecraft/deploy already exists." - echo "You can still run the installer again, but it may overwrite some" - echo "configuration files if you edited them in the meantime." +if [[ -e "$INSTALL_DIR/$DEPLOY_DIR" ]]; then + echo "The deploy directory $INSTALL_DIR/$DEPLOY_DIR already exists." + echo "You can still run the installer again, but it will overwrite your" + echo "plugin update scripts and some configuration files if you edited" + echo "them in the meantime." ask "Are you sure you want to continue?" \ || die "Installation aborted." fi -cd /var/lib/minecraft \ - || die "Could not change into /var/lib/minecraft" +cd $INSTALL_DIR \ + || die "Could not change into $INSTALL_DIR" -if [[ -e deploy ]]; then +if [[ -e "$DEPLOY_DIR" ]]; then status "Updating deploy repository" - runuser -u minecraft -- git -C deploy pull \ + runuser -u minecraft -- git -C "$DEPLOY_DIR" pull \ || die "Could not pull repository" else status "Cloning deploy repository" - runuser -u minecraft -- git clone "https://github.com/oddlama/minecraft-server" deploy \ + runuser -u minecraft -- git clone "https://github.com/oddlama/minecraft-server" "$DEPLOY_DIR" \ || die "Could not clone repository" fi -cd deploy \ +cd "$DEPLOY_DIR" \ || die "Could not change into deploy directory" +##################################################### status "Configuring server" -install_file <(echo "eula=true") server/eula.txt minecraft: 600 +##################################################### -for d in $(find contrib/default_config -type d -printf '%P\n'); do - mkdir -p -m700 "$d" || die "Could not create directory '$d'" - chown minecraft: "$d" || die "Could not chown directory '$d'" -done +install_folder installer/default_config/server "$INSTALL_DIR/$DEPLOY_DIR/server" -for f in $(find contrib/default_config -type f -printf '%P\n'); do - install_file contrib/default_config/"$f" "$f" minecraft: 600 -done +install_file <(echo "eula=true") server/eula.txt minecraft: 600 VELOCITYSECRET=$(openssl rand -base64 16) \ || die "Could not generate velocity secret" @@ -177,15 +214,18 @@ if ask "Increase view-distance to 15 chunks?"; then fi echo -runuser -u minecraft -- ./update.sh < "$TTY" \ - || die "Could not update server files" + +if ask "Download all initial server files through update.sh?"; then + runuser -u minecraft -- ./update.sh < "$TTY" \ + || echo "Could not update server files, you need to manually do that later" +fi ################################################################ # Install systemd services status "Installing service files" -./contrib/install.sh < "$TTY" \ +./installer/systemd/install.sh < "$TTY" \ || die "Error while installing service files" @@ -211,6 +251,12 @@ following command when you are ready to start the server: " fi +################################################################ +# Install minecraft-attach tool + +install_file "installer/minecraft-attach" \ + "/usr/bin/minecraft-attach" \ + root: 755 ################################################################ # Success message diff --git a/contrib/default_config/proxy/plugins/vane-velocity/config.toml b/installer/default_config/proxy/plugins/vane-velocity/config.toml similarity index 100% rename from contrib/default_config/proxy/plugins/vane-velocity/config.toml rename to installer/default_config/proxy/plugins/vane-velocity/config.toml diff --git a/contrib/default_config/proxy/velocity.toml b/installer/default_config/proxy/velocity.toml similarity index 100% rename from contrib/default_config/proxy/velocity.toml rename to installer/default_config/proxy/velocity.toml diff --git a/server/.gitignore b/installer/default_config/server/.gitignore similarity index 100% rename from server/.gitignore rename to installer/default_config/server/.gitignore diff --git a/server/backup.sh b/installer/default_config/server/backup.sh similarity index 100% rename from server/backup.sh rename to installer/default_config/server/backup.sh diff --git a/contrib/default_config/server/commands.yml b/installer/default_config/server/commands.yml similarity index 100% rename from contrib/default_config/server/commands.yml rename to installer/default_config/server/commands.yml diff --git a/contrib/default_config/server/config/paper-global.yml b/installer/default_config/server/config/paper-global.yml similarity index 100% rename from contrib/default_config/server/config/paper-global.yml rename to installer/default_config/server/config/paper-global.yml diff --git a/contrib/default_config/server/config/paper-world-defaults.yml b/installer/default_config/server/config/paper-world-defaults.yml similarity index 100% rename from contrib/default_config/server/config/paper-world-defaults.yml rename to installer/default_config/server/config/paper-world-defaults.yml diff --git a/contrib/default_config/server/plugins/BlueMap/core.conf b/installer/default_config/server/plugins/BlueMap/core.conf similarity index 100% rename from contrib/default_config/server/plugins/BlueMap/core.conf rename to installer/default_config/server/plugins/BlueMap/core.conf diff --git a/server/server-icon.png b/installer/default_config/server/server-icon.png similarity index 100% rename from server/server-icon.png rename to installer/default_config/server/server-icon.png diff --git a/contrib/default_config/server/server.properties b/installer/default_config/server/server.properties similarity index 100% rename from contrib/default_config/server/server.properties rename to installer/default_config/server/server.properties diff --git a/contrib/default_config/server/spigot.yml b/installer/default_config/server/spigot.yml similarity index 100% rename from contrib/default_config/server/spigot.yml rename to installer/default_config/server/spigot.yml diff --git a/server/start.sh b/installer/default_config/server/start.sh similarity index 100% rename from server/start.sh rename to installer/default_config/server/start.sh diff --git a/server/update.sh b/installer/default_config/server/update.sh similarity index 100% rename from server/update.sh rename to installer/default_config/server/update.sh diff --git a/contrib/minecraft-attach b/installer/minecraft-attach similarity index 100% rename from contrib/minecraft-attach rename to installer/minecraft-attach diff --git a/contrib/install.sh b/installer/systemd/install.sh similarity index 81% rename from contrib/install.sh rename to installer/systemd/install.sh index fa9dbef..e3fbdc0 100755 --- a/contrib/install.sh +++ b/installer/systemd/install.sh @@ -3,7 +3,9 @@ set -uo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null \ || exit 1 -source "utils.sh" || exit 1 + +function print_error() { echo "error: $*" >&2; } +function die() { print_error "$@"; exit 1; } [[ $EUID == 0 ]] || die "Must be root for system-wide installation." @@ -20,14 +22,10 @@ function install_file() { } for name in server proxy; do - install_file "systemd/minecraft-$name.service" \ + install_file "./minecraft-$name.service" \ "/lib/systemd/system/minecraft-$name.service" \ root: 644 done -install_file "minecraft-attach" \ - "/usr/bin/minecraft-attach" \ - root: 755 - echo "Reloading service files..." systemctl daemon-reload diff --git a/contrib/systemd/minecraft-proxy.service b/installer/systemd/minecraft-proxy.service similarity index 100% rename from contrib/systemd/minecraft-proxy.service rename to installer/systemd/minecraft-proxy.service diff --git a/contrib/systemd/minecraft-server.service b/installer/systemd/minecraft-server.service similarity index 100% rename from contrib/systemd/minecraft-server.service rename to installer/systemd/minecraft-server.service From 87ea3c2d65a8444b82ac35fcebf0150e79e304ee Mon Sep 17 00:00:00 2001 From: set Date: Tue, 1 Jul 2025 14:39:18 +0200 Subject: [PATCH 2/3] implement multiserver support --- README.md | 28 ++-- installer/bootstrap | 124 +++++++++++------- .../proxy/plugins/vane-velocity/config.toml | 14 +- installer/default_config/proxy/velocity.toml | 4 +- installer/default_config/server/backup.sh | 2 +- installer/default_config/server/start.sh | 2 +- installer/default_config/server/update.sh | 2 +- installer/systemd/install.sh | 2 +- ...rver.service => minecraft-server@.service} | 10 +- update.sh | 9 +- 10 files changed, 118 insertions(+), 79 deletions(-) rename installer/systemd/{minecraft-server.service => minecraft-server@.service} (61%) diff --git a/README.md b/README.md index 595dedc..60568cc 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ In summary, the script will perform the following steps: - Check whether all required tools are installed - Create a new `minecraft` user for the server (if not existing) -- Update the server jars and download all plugins +- Update the server jars and download all plugins (if requested) - Install, enable and start the systemd services ## ⚙️ Server configuration @@ -79,7 +79,7 @@ or be assigned to the user group with `perm add player_name user`, or any higher To enable the graylist, set the following option: ```yaml -# server/plugins/vane-admin/config.yml +# servers/backend/plugins/vane-admin/config.yml world_protection: enabled: true ``` @@ -95,7 +95,7 @@ The text and icon in your server list now controlled by the proxy instead of you Edit `proxy/plugins/vane-velocity/config.toml` to change the text to your liking. You can also set different texts based on whether the server is currently started or not. -To set a server icon, simply drop a file name `server-icon.png` in your `server/` directory, +To set a server icon, simply drop a file name `server-icon.png` in your `servers/backend/` directory, next to where the `paper.jar` is. ## 🚀 Usage @@ -110,7 +110,7 @@ console in the background at all times, so you can access them from any terminal on your server (also remotely via ssh!). ```bash -sudo minecraft-attach server # Open the server console +sudo minecraft-attach server-backend # Open the server console sudo minecraft-attach proxy # Open the proxy console ``` @@ -156,10 +156,10 @@ run the updater and then start them again. To do this, execute the following commands as root: ```bash -systemctl stop minecraft-proxy minecraft-server # Stop services +systemctl stop minecraft-proxy minecraft-server@backend # Stop services cd /var/lib/minecraft/deploy # Change into deploy directory ./update.sh # Run update script -systemctl start minecraft-proxy minecraft-server # Start services again +systemctl start minecraft-proxy minecraft-server@backend # Start services again ``` ### 🔄 Updating the deploy script @@ -172,11 +172,11 @@ Other updates to this repository will most likely be minor changes. To update, execute the following commands as root: ```bash -systemctl stop minecraft-proxy minecraft-server # Stop services +systemctl stop minecraft-proxy minecraft-server@backend # Stop services cd /var/lib/minecraft/deploy # Change into deploy directory git pull # Get updates from upstream ./contrib/install.sh # Re-install the service files -systemctl start minecraft-proxy minecraft-server # Start services again +systemctl start minecraft-proxy minecraft-server@backend # Start services again ``` ### 🔌 Installing and removing plugins @@ -185,7 +185,7 @@ Plugins are installed and updated by the `update.sh` scripts. To add a new plugin, find a download link that always points to the latest version and add an entry at the end of the respective script, similar to those that are already present. -For example to add worldguard, you add the following at the end of `server/update.sh`: +For example to add worldguard, you add the following at the end of `servers/backup/update.sh`: ```bash download_file "https://dev.bukkit.org/projects/worldguard/files/latest" plugins/worldguard.jar ``` @@ -206,7 +206,7 @@ Your server will automatically create an incremental backup of all three worlds You can view all the backups that have been created until now by executing the following commands as root: ```bash -cd deploy/server +cd deploy/servers/backend rdiff-backup -l backups/world ``` @@ -214,7 +214,7 @@ Now if anything happens on your server and you want to revert to an older versio you can do so by simply executing the following commands as root: ```bash -cd deploy/server +cd deploy/servers/backend rm -rf world # First delete what you want to restore rdiff-backup -r 1B backups/world world # Restore state from the last backup. # Repeat analogously for any other folders that you want to restore: @@ -231,7 +231,7 @@ Visit [their website](http://rdiff-backup.nongnu.org/examples.html) for more inf ### 💾 Changing or disabling backups -To create backups, the service calls the `server/backup.sh` file automatically each time the server stops. +To create backups, the service calls the `servers/backend/backup.sh` file automatically each time the server stops. Feel free to adjust this script to your liking. To completely disable backups, replace the script's content with: ```bash @@ -305,9 +305,9 @@ If you want to uninstall this server, simply execute the following commands: ```bash # Disable & stop services -systemctl disable --now minecraft-{proxy,server} +systemctl disable --now minecraft-{proxy,server@backend} # Remove service files and attach script -rm /lib/systemd/system/minecraft-{proxy,server}.service /usr/bin/minecraft-attach +rm /lib/systemd/system/minecraft-{proxy,server@}.service /usr/bin/minecraft-attach # Remove user and delete files in /var/lib/minecraft userdel -r minecraft ``` diff --git a/installer/bootstrap b/installer/bootstrap index 40400d0..e9d5b50 100755 --- a/installer/bootstrap +++ b/installer/bootstrap @@ -7,12 +7,14 @@ TTY="/dev/$(ps -p $$ -o tty=)" INSTALL_DIR='/var/lib/minecraft' DEPLOY_DIR='deploy' +declare -i SERVER_PORT_OFFSET=25500 ################################################################ # Helper functions function die() { echo "error: $*" >&2; exit 1; } function status() { echo "${had_status+$'\n'}$*"; had_status=1; } +function substatus() { echo "$*"; } function flush_stdin() { while read -r -t 0.01 empty_stdin < "$TTY"; do true; done; } function ask() { local response @@ -157,61 +159,89 @@ fi cd "$DEPLOY_DIR" \ || die "Could not change into deploy directory" -##################################################### -status "Configuring server" -##################################################### -install_folder installer/default_config/server "$INSTALL_DIR/$DEPLOY_DIR/server" - -install_file <(echo "eula=true") server/eula.txt minecraft: 600 +################################################################ +# Setup Velocity Proxy Server +status "Setting up Velocity proxy server" +# generate and deploy velocity secret VELOCITYSECRET=$(openssl rand -base64 16) \ || die "Could not generate velocity secret" install_file <(echo -n "$VELOCITYSECRET") proxy/forwarding.secret minecraft: 600 -sed -i 's|{{VELOCITYSECRET}}|'"$VELOCITYSECRET"'|' server/config/paper-global.yml \ - || die "Could not insert velocity secret in paper-global.yml" - -echo "Depending on your player base, you might want to allow certain gamplay" -echo "exploits on your server. These are fixed by default in PaperMC, but would" -echo "allow your players to build certain vanilla machines (TNT blast chambers," -echo "bedrock removal, ...). My personal recommendation is to answer with yes" -echo "to all of these questions." -echo -if ask "Allow headless pistons and bedrock breaking?"; then - sed -i 's|allow-headless-pistons: false|allow-headless-pistons: true|' server/config/paper-global.yml \ - || die "Could not replace allow-headless-pistons config" - sed -i 's|allow-permanent-block-break-exploits: false|allow-permanent-block-break-exploits: true|' server/config/paper-global.yml \ - || die "Could not replace allow-permanent-block-break-exploits config" -fi +# deploy default velocity config +install_folder "installer/default_config/proxy" "proxy" -if ask "Allow piston TNT duping?"; then - sed -i 's|allow-piston-duplication: false|allow-piston-duplication: true|' server/config/paper-global.yml \ - || die "Could not replace allow-piston-duplication config" -fi +################################################################ +# Setup backend Minecraft Server -if ask "Enable Anti-XRAY?"; then - sed -i 's|false # ANTI_XRAY|true|' server/config/paper-world-defaults.yml \ - || die "Could not replace ANTI_XRAY config" -else - sed -i 's|false # ANTI_XRAY|false|' server/config/paper-world-defaults.yml \ - || die "Could not replace ANTI_XRAY config" -fi +status "Setting up backend minecraft server" -if ask "Replenish loot in loot chests after 1-2 realtime days?"; then - sed -i 's|auto-replenish: false|auto-replenish: true|' server/config/paper-world-defaults.yml \ - || die "Could not replace auto-replenish config" -fi +# variable amount of server names +SERVER_NAMES=(backend) -if ask "Disable hopper item move event to reduce lag?"; then - sed -i 's|disable-move-event: false|disable-move-event: true|' server/config/paper-world-defaults.yml \ - || die "Could not replace disable-move-event config" -fi +# make base server directory +mkdir servers +chown minecraft: servers +chmod 700 servers -if ask "Increase view-distance to 15 chunks?"; then - sed -i 's|view-distance=10|view-distance=15|' server/server.properties \ - || die "Could not replace view-distance config" -fi +declare -i server_num=1 +for server_name in $SERVER_NAMES; do + install_folder installer/default_config/server "servers/$server_name" + + install_file <(echo "eula=true") servers/"$server_name"/eula.txt minecraft: 600 + + substatus "Configuring $server_name server" + + sed -i 's|{{SERVER_PORT}}|'"$(($SERVER_PORT_OFFSET+$server_num))"'|' "servers/$server_name"/server.properties \ + || die "Could not insert server port into server.properties" + + sed -i 's|{{VELOCITYSECRET}}|'"$VELOCITYSECRET"'|' servers/"$server_name"/config/paper-global.yml \ + || die "Could not insert velocity secret in paper-global.yml" + + echo "Depending on your player base, you might want to allow certain gamplay" + echo "exploits on your server. These are fixed by default in PaperMC, but would" + echo "allow your players to build certain vanilla machines (TNT blast chambers," + echo "bedrock removal, ...). My personal recommendation is to answer with yes" + echo "to all of these questions." + echo + + if ask "Allow headless pistons and bedrock breaking?"; then + sed -i 's|allow-headless-pistons: false|allow-headless-pistons: true|' servers/"$server_name"/config/paper-global.yml \ + || die "Could not replace allow-headless-pistons config" + sed -i 's|allow-permanent-block-break-exploits: false|allow-permanent-block-break-exploits: true|' servers/"$server_name"/config/paper-global.yml \ + || die "Could not replace allow-permanent-block-break-exploits config" + fi + + if ask "Allow piston TNT duping?"; then + sed -i 's|allow-piston-duplication: false|allow-piston-duplication: true|' servers/"$server_name"/config/paper-global.yml \ + || die "Could not replace allow-piston-duplication config" + fi + + if ask "Enable Anti-XRAY?"; then + sed -i 's|false # ANTI_XRAY|true|' servers/"$server_name"/config/paper-world-defaults.yml \ + || die "Could not replace ANTI_XRAY config" + else + sed -i 's|false # ANTI_XRAY|false|' servers/"$server_name"/config/paper-world-defaults.yml \ + || die "Could not replace ANTI_XRAY config" + fi + + if ask "Replenish loot in loot chests after 1-2 realtime days?"; then + sed -i 's|auto-replenish: false|auto-replenish: true|' servers/"$server_name"/config/paper-world-defaults.yml \ + || die "Could not replace auto-replenish config" + fi + + if ask "Disable hopper item move event to reduce lag?"; then + sed -i 's|disable-move-event: false|disable-move-event: true|' servers/"$server_name"/config/paper-world-defaults.yml \ + || die "Could not replace disable-move-event config" + fi + + if ask "Increase view-distance to 15 chunks?"; then + sed -i 's|view-distance=10|view-distance=15|' servers/"$server_name"/server.properties \ + || die "Could not replace view-distance config" + fi + server_num+=1 +done echo @@ -240,8 +270,12 @@ echo postponed_service_message="" if ask "Enable and start system services now?"; then - systemctl enable --now minecraft-server minecraft-proxy < "$TTY" \ + systemctl enable --now minecraft-proxy < "$TTY" \ || die "Error while enabling services" + for server_name in $SERVER_NAMES; do + systemctl enable --now minecraft-server@"$server_name" < "$TTY" \ + || die "Error while enabling server named $server_name" + done else postponed_service_message=" You have postponed enabling the system services. Make sure to execute the diff --git a/installer/default_config/proxy/plugins/vane-velocity/config.toml b/installer/default_config/proxy/plugins/vane-velocity/config.toml index b83c049..369e088 100644 --- a/installer/default_config/proxy/plugins/vane-velocity/config.toml +++ b/installer/default_config/proxy/plugins/vane-velocity/config.toml @@ -22,20 +22,20 @@ allowed_uuids = [] # # It is *not* possible to have multiple multiplexers on the same port. -[managed_servers.server] +[managed_servers.backend] display_name = "§6◊ §6§lMY SERVER§6 ◊" -[managed_servers.server.online] -favicon = "../{SERVER}/server-icon.png" +[managed_servers.backend.online] +favicon = "../servers/{SERVER}/server-icon.png" motd = "{SERVER_DISPLAY_NAME}\n§a\\(^-^)/§7 | {QUOTE}" quotes = ["Yay, already online!"] -[managed_servers.server.offline] +[managed_servers.backend.offline] quotes = [ "Simply connect to start the server!", "Nobody here yet." ] motd = "{SERVER_DISPLAY_NAME}\n§c~(°·°)~§7 | {QUOTE}" -[managed_servers.server.start] -cmd = ["rm", "../{SERVER}/start.block"] +[managed_servers.backend.start] +cmd = ["rm", "../servers/{SERVER}/start.block"] kick_msg = "{SERVER_DISPLAY_NAME} §7is being started.\n§7Try again in §b10 Seconds§7 \\(^-^)/" # If this is not set, you must individually grant players the permission to start this server # by using an external permission plugin to assign one of `vane_proxy.start_server`, `vane_proxy.start_server.*` or `vane_proxy.start_server.` @@ -60,7 +60,7 @@ allow_anyone = true # [managed_servers.my_server.online] # # # The server favicon (absolute path or relative to proxy directory) -# favicon = "../{SERVER}/server-icon.png" +# favicon = "../servers/{SERVER}/server-icon.png" # # # The motd for the server list (up to two lines) # motd = "{SERVER_DISPLAY_NAME}\n§aowo§7 | {QUOTE}" diff --git a/installer/default_config/proxy/velocity.toml b/installer/default_config/proxy/velocity.toml index b8de2ed..db864a9 100644 --- a/installer/default_config/proxy/velocity.toml +++ b/installer/default_config/proxy/velocity.toml @@ -72,11 +72,11 @@ enable-player-address-logging = true [servers] # Configure your servers here. Each key represents the server's name, and the value # represents the IP address of the server to connect to. -server = "127.0.0.1:25501" +backend = "127.0.0.1:25501" # In what order we shoulid try servers when a player logs in or is kicked from a server. try = [ - "server" + "backend" ] [forced-hosts] diff --git a/installer/default_config/server/backup.sh b/installer/default_config/server/backup.sh index 348bde6..df41705 100755 --- a/installer/default_config/server/backup.sh +++ b/installer/default_config/server/backup.sh @@ -13,7 +13,7 @@ BACKUP_DIRS=( cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null \ || exit 1 -source "../contrib/utils.sh" || exit 1 +source "../../contrib/utils.sh" || exit 1 status_time "Starting backup" diff --git a/installer/default_config/server/start.sh b/installer/default_config/server/start.sh index c6dc188..99dd1d9 100755 --- a/installer/default_config/server/start.sh +++ b/installer/default_config/server/start.sh @@ -4,7 +4,7 @@ set -uo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null \ || exit 1 -source "../contrib/utils.sh" || exit 1 +source "../../contrib/utils.sh" || exit 1 # Use 80% of RAM, but not more than 12GiB and not less than 1GiB total_ram_gibi=$(free -g | grep -oP '\d+' | head -n1) diff --git a/installer/default_config/server/update.sh b/installer/default_config/server/update.sh index 1a6bff3..4193d71 100755 --- a/installer/default_config/server/update.sh +++ b/installer/default_config/server/update.sh @@ -3,7 +3,7 @@ set -uo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null \ || exit 1 -source "../contrib/utils.sh" || exit 1 +source "../../contrib/utils.sh" || exit 1 become_minecaft "./update.sh" diff --git a/installer/systemd/install.sh b/installer/systemd/install.sh index e3fbdc0..89dbdea 100755 --- a/installer/systemd/install.sh +++ b/installer/systemd/install.sh @@ -21,7 +21,7 @@ function install_file() { chmod "$4" "$2" || die "Could not chmod '$2'" } -for name in server proxy; do +for name in server@ proxy; do install_file "./minecraft-$name.service" \ "/lib/systemd/system/minecraft-$name.service" \ root: 644 diff --git a/installer/systemd/minecraft-server.service b/installer/systemd/minecraft-server@.service similarity index 61% rename from installer/systemd/minecraft-server.service rename to installer/systemd/minecraft-server@.service index c49753d..9e2ffd9 100644 --- a/installer/systemd/minecraft-server.service +++ b/installer/systemd/minecraft-server@.service @@ -1,16 +1,16 @@ [Unit] -Description=Minecraft server +Description=Minecraft server (%i) After=network.target [Service] User=minecraft Group=minecraft -RuntimeDirectory=minecraft-server +RuntimeDirectory=minecraft-server-%i Type=forking -ExecStart=tmux -S /run/minecraft-server/tmux set -g default-shell /bin/bash ";" new-session -d "/var/lib/minecraft/deploy/contrib/server_loop.py --block start.block ./start.sh :POST: ./backup.sh" -ExecStop=tmux -S /run/minecraft-server/tmux kill-server +ExecStart=tmux -S /run/minecraft-server-%i/tmux set -g default-shell /bin/bash ";" new-session -d "/var/lib/minecraft/deploy/contrib/server_loop.py --block start.block ./start.sh :POST: ./backup.sh" +ExecStop=tmux -S /run/minecraft-server-%i/tmux kill-server PrivateTmp=true PrivateDevices=true @@ -34,7 +34,7 @@ SystemCallFilter=@system-service AmbientCapabilities=CAP_KILL CapabilityBoundingSet=CAP_KILL -WorkingDirectory=/var/lib/minecraft/deploy/server +WorkingDirectory=/var/lib/minecraft/deploy/servers/%i ReadWriteDirectories=/var/lib/minecraft [Install] diff --git a/update.sh b/update.sh index 135a013..d7240d1 100755 --- a/update.sh +++ b/update.sh @@ -14,5 +14,10 @@ status "Updating proxy" proxy/update.sh "$@" || exit 1 echo -status "Updating server" -server/update.sh "$@" || exit 1 +status "Updating servers" +for dir in servers/*/; do + if [ -d "$dir" ]; then + status "Updating $(basename "$dir") server" + "$dir"update.sh "$@" || exit 1 + fi +done From 8bedd552a428f52db7c996383f08ab126e2d8ba2 Mon Sep 17 00:00:00 2001 From: set Date: Tue, 1 Jul 2025 15:36:32 +0200 Subject: [PATCH 3/3] add wget dependency --- installer/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/bootstrap b/installer/bootstrap index e9d5b50..2569e96 100755 --- a/installer/bootstrap +++ b/installer/bootstrap @@ -77,7 +77,7 @@ function install_folder() { # Ensure that all required tools are installed abort=0 -for i in jq git tmux rdiff-backup java openssl; do +for i in jq git tmux rdiff-backup java openssl wget; do if ! type "$i" &>/dev/null; then echo "missing: $i" >&2 abort=1