Update: add a script to attach to the Console + add the same "header"

This commit is contained in:
Peritia 2026-02-10 15:51:55 +01:00
parent c0a2e941fb
commit 79ef3fdfd0
8 changed files with 233 additions and 8 deletions

View file

@ -22,6 +22,7 @@ BZIP2_BIN="@BZIP2_BIN@"
XZ_BIN="@XZ_BIN@"
WC_BIN="@WC_BIN@"
FIND_BIN="@FIND_BIN@"
TMUX_BIN="@TMUX_BIN@"
# Convenience wrappers
@ -40,6 +41,7 @@ bzip2_cmd="$BZIP2_BIN"
xz_cmd="$XZ_BIN"
wc_cmd="$WC_BIN"
find_cmd="$FIND_BIN"
tmux_cmd="$TMUX_BIN"
@ -62,7 +64,9 @@ for bin in \
"$BZIP2_BIN" \
"$XZ_BIN" \
"$WC_BIN" \
"$FIND_BIN"
"$FIND_BIN" \
"$TMUX_BIN"
do
export PATH="$(dirname "$bin"):$PATH"
done

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# Injected by Nix
RSYNC_BIN="@RSYNC_BIN@"
DATA_DIR="@DATA_DIR@"
@ -20,6 +21,10 @@ PV_BIN="@PV_BIN@"
DU_BIN="@DU_BIN@"
BZIP2_BIN="@BZIP2_BIN@"
XZ_BIN="@XZ_BIN@"
WC_BIN="@WC_BIN@"
FIND_BIN="@FIND_BIN@"
TMUX_BIN="@TMUX_BIN@"
# Convenience wrappers
rsync_cmd="$RSYNC_BIN"
@ -35,11 +40,36 @@ pv_cmd="$PV_BIN"
du_cmd="$DU_BIN"
bzip2_cmd="$BZIP2_BIN"
xz_cmd="$XZ_BIN"
wc_cmd="$WC_BIN"
find_cmd="$FIND_BIN"
tmux_cmd="$TMUX_BIN"
# PATH extension
# (only figured that out later if you add it here it can actually just use the bin)
# So you can easily just switch out the "*_cmd" with the "normal" name
# export PATH="$(dirname "$GZIP_BIN")":"$(dirname "$ZSTD_BIN")":"$(dirname "$PV_BIN")":"$(dirname "$DU_BIN")":"$(dirname "$BZIP2_BIN")":"$(dirname "$XZ_BIN")":"$PATH"
# Extend PATH with all injected binaries so we can call them directly
for bin in \
"$RSYNC_BIN" \
"$MCSTATUS_BIN" \
"$MCRCON_BIN" \
"$AWK_BIN" \
"$TAR_BIN" \
"$ZIP_BIN" \
"$UNZIP_BIN" \
"$GZIP_BIN" \
"$ZSTD_BIN" \
"$PV_BIN" \
"$DU_BIN" \
"$BZIP2_BIN" \
"$XZ_BIN" \
"$WC_BIN" \
"$FIND_BIN" \
"$TMUX_BIN"
do
export PATH="$(dirname "$bin"):$PATH"
done

View file

@ -0,0 +1,84 @@
#!/usr/bin/env bash
set -euo pipefail
# Injected by Nix
RSYNC_BIN="@RSYNC_BIN@"
DATA_DIR="@DATA_DIR@"
MCSTATUS_BIN="@MCSTATUS_BIN@"
MCRCON_BIN="@MCRCON_BIN@"
AWK_BIN="@AWK_BIN@"
QUERY_PORT="@QUERY_PORT@"
RCON_PORT="@RCON_PORT@"
RCON_PASSWORD="@RCON_PASSWORD@"
SERVER_NAME="@SERVER_NAME@"
TAR_BIN="@TAR_BIN@"
ZIP_BIN="@ZIP_BIN@"
UNZIP_BIN="@UNZIP_BIN@"
GZIP_BIN="@GZIP_BIN@"
ZSTD_BIN="@ZSTD_BIN@"
PV_BIN="@PV_BIN@"
DU_BIN="@DU_BIN@"
BZIP2_BIN="@BZIP2_BIN@"
XZ_BIN="@XZ_BIN@"
WC_BIN="@WC_BIN@"
FIND_BIN="@FIND_BIN@"
TMUX_BIN="@TMUX_BIN@"
# Convenience wrappers
rsync_cmd="$RSYNC_BIN"
awk_cmd="$AWK_BIN"
mcstatus_cmd="$MCSTATUS_BIN 127.0.0.1:${QUERY_PORT}"
mcrcon_cmd="$MCRCON_BIN -H 127.0.0.1 -P ${RCON_PORT} -p ${RCON_PASSWORD}"
tar_cmd="$TAR_BIN"
zip_cmd="$ZIP_BIN"
unzip_cmd="$UNZIP_BIN"
gzip_cmd="$GZIP_BIN"
zstd_cmd="$ZSTD_BIN"
pv_cmd="$PV_BIN"
du_cmd="$DU_BIN"
bzip2_cmd="$BZIP2_BIN"
xz_cmd="$XZ_BIN"
wc_cmd="$WC_BIN"
find_cmd="$FIND_BIN"
tmux_cmd="$TMUX_BIN"
# PATH extension
# (only figured that out later if you add it here it can actually just use the bin)
# So you can easily just switch out the "*_cmd" with the "normal" name
# Extend PATH with all injected binaries so we can call them directly
for bin in \
"$RSYNC_BIN" \
"$MCSTATUS_BIN" \
"$MCRCON_BIN" \
"$AWK_BIN" \
"$TAR_BIN" \
"$ZIP_BIN" \
"$UNZIP_BIN" \
"$GZIP_BIN" \
"$ZSTD_BIN" \
"$PV_BIN" \
"$DU_BIN" \
"$BZIP2_BIN" \
"$XZ_BIN" \
"$WC_BIN" \
"$FIND_BIN" \
"$TMUX_BIN"
do
export PATH="$(dirname "$bin"):$PATH"
done
# tmux socket path (matches systemd service)
SOCK_PATH="/run/minecraft/${SERVER_NAME}.sock"
if [[ ! -S "$SOCK_PATH" ]]; then
echo "Minecraft tmux socket not found: $SOCK_PATH" >&2
exit 1
fi
exec tmux -S "$SOCK_PATH" attach

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# Injected by Nix
RSYNC_BIN="@RSYNC_BIN@"
DATA_DIR="@DATA_DIR@"
@ -20,6 +21,10 @@ PV_BIN="@PV_BIN@"
DU_BIN="@DU_BIN@"
BZIP2_BIN="@BZIP2_BIN@"
XZ_BIN="@XZ_BIN@"
WC_BIN="@WC_BIN@"
FIND_BIN="@FIND_BIN@"
TMUX_BIN="@TMUX_BIN@"
# Convenience wrappers
rsync_cmd="$RSYNC_BIN"
@ -35,11 +40,36 @@ pv_cmd="$PV_BIN"
du_cmd="$DU_BIN"
bzip2_cmd="$BZIP2_BIN"
xz_cmd="$XZ_BIN"
wc_cmd="$WC_BIN"
find_cmd="$FIND_BIN"
tmux_cmd="$TMUX_BIN"
# PATH extension
# (only figured that out later if you add it here it can actually just use the bin)
# So you can easily just switch out the "*_cmd" with the "normal" name
# export PATH="$(dirname "$GZIP_BIN")":"$(dirname "$ZSTD_BIN")":"$(dirname "$PV_BIN")":"$(dirname "$DU_BIN")":"$(dirname "$BZIP2_BIN")":"$(dirname "$XZ_BIN")":"$PATH"
# Extend PATH with all injected binaries so we can call them directly
for bin in \
"$RSYNC_BIN" \
"$MCSTATUS_BIN" \
"$MCRCON_BIN" \
"$AWK_BIN" \
"$TAR_BIN" \
"$ZIP_BIN" \
"$UNZIP_BIN" \
"$GZIP_BIN" \
"$ZSTD_BIN" \
"$PV_BIN" \
"$DU_BIN" \
"$BZIP2_BIN" \
"$XZ_BIN" \
"$WC_BIN" \
"$FIND_BIN" \
"$TMUX_BIN"
do
export PATH="$(dirname "$bin"):$PATH"
done

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# Injected by Nix
RSYNC_BIN="@RSYNC_BIN@"
DATA_DIR="@DATA_DIR@"
@ -20,6 +21,10 @@ PV_BIN="@PV_BIN@"
DU_BIN="@DU_BIN@"
BZIP2_BIN="@BZIP2_BIN@"
XZ_BIN="@XZ_BIN@"
WC_BIN="@WC_BIN@"
FIND_BIN="@FIND_BIN@"
TMUX_BIN="@TMUX_BIN@"
# Convenience wrappers
rsync_cmd="$RSYNC_BIN"
@ -35,11 +40,36 @@ pv_cmd="$PV_BIN"
du_cmd="$DU_BIN"
bzip2_cmd="$BZIP2_BIN"
xz_cmd="$XZ_BIN"
wc_cmd="$WC_BIN"
find_cmd="$FIND_BIN"
tmux_cmd="$TMUX_BIN"
# PATH extension
# (only figured that out later if you add it here it can actually just use the bin)
# So you can easily just switch out the "*_cmd" with the "normal" name
# export PATH="$(dirname "$GZIP_BIN")":"$(dirname "$ZSTD_BIN")":"$(dirname "$PV_BIN")":"$(dirname "$DU_BIN")":"$(dirname "$BZIP2_BIN")":"$(dirname "$XZ_BIN")":"$PATH"
# Extend PATH with all injected binaries so we can call them directly
for bin in \
"$RSYNC_BIN" \
"$MCSTATUS_BIN" \
"$MCRCON_BIN" \
"$AWK_BIN" \
"$TAR_BIN" \
"$ZIP_BIN" \
"$UNZIP_BIN" \
"$GZIP_BIN" \
"$ZSTD_BIN" \
"$PV_BIN" \
"$DU_BIN" \
"$BZIP2_BIN" \
"$XZ_BIN" \
"$WC_BIN" \
"$FIND_BIN" \
"$TMUX_BIN"
do
export PATH="$(dirname "$bin"):$PATH"
done

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# Injected by Nix
RSYNC_BIN="@RSYNC_BIN@"
DATA_DIR="@DATA_DIR@"
@ -20,6 +21,10 @@ PV_BIN="@PV_BIN@"
DU_BIN="@DU_BIN@"
BZIP2_BIN="@BZIP2_BIN@"
XZ_BIN="@XZ_BIN@"
WC_BIN="@WC_BIN@"
FIND_BIN="@FIND_BIN@"
TMUX_BIN="@TMUX_BIN@"
# Convenience wrappers
rsync_cmd="$RSYNC_BIN"
@ -35,11 +40,36 @@ pv_cmd="$PV_BIN"
du_cmd="$DU_BIN"
bzip2_cmd="$BZIP2_BIN"
xz_cmd="$XZ_BIN"
wc_cmd="$WC_BIN"
find_cmd="$FIND_BIN"
tmux_cmd="$TMUX_BIN"
# PATH extension
# (only figured that out later if you add it here it can actually just use the bin)
# So you can easily just switch out the "*_cmd" with the "normal" name
# export PATH="$(dirname "$GZIP_BIN")":"$(dirname "$ZSTD_BIN")":"$(dirname "$PV_BIN")":"$(dirname "$DU_BIN")":"$(dirname "$BZIP2_BIN")":"$(dirname "$XZ_BIN")":"$PATH"
# Extend PATH with all injected binaries so we can call them directly
for bin in \
"$RSYNC_BIN" \
"$MCSTATUS_BIN" \
"$MCRCON_BIN" \
"$AWK_BIN" \
"$TAR_BIN" \
"$ZIP_BIN" \
"$UNZIP_BIN" \
"$GZIP_BIN" \
"$ZSTD_BIN" \
"$PV_BIN" \
"$DU_BIN" \
"$BZIP2_BIN" \
"$XZ_BIN" \
"$WC_BIN" \
"$FIND_BIN" \
"$TMUX_BIN"
do
export PATH="$(dirname "$bin"):$PATH"
done

View file

@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail
# Injected by Nix
RSYNC_BIN="@RSYNC_BIN@"
DATA_DIR="@DATA_DIR@"
@ -22,6 +23,7 @@ BZIP2_BIN="@BZIP2_BIN@"
XZ_BIN="@XZ_BIN@"
WC_BIN="@WC_BIN@"
FIND_BIN="@FIND_BIN@"
TMUX_BIN="@TMUX_BIN@"
# Convenience wrappers
@ -40,22 +42,30 @@ bzip2_cmd="$BZIP2_BIN"
xz_cmd="$XZ_BIN"
wc_cmd="$WC_BIN"
find_cmd="$FIND_BIN"
tmux_cmd="$TMUX_BIN"
# PATH extension
# (only figured that out later if you add it here it can actually just use the bin)
# So you can easily just switch out the "*_cmd" with the "normal" name
# Extend PATH with all injected binaries so we can call them directly
for bin in \
"$RSYNC_BIN" \
"$MCSTATUS_BIN" \
"$MCRCON_BIN" \
"$AWK_BIN" \
"$TAR_BIN" \
"$ZIP_BIN" \
"$UNZIP_BIN" \
"$GZIP_BIN" \
"$ZSTD_BIN" \
"$AWK_BIN" \
"$PV_BIN" \
"$DU_BIN" \
"$BZIP2_BIN" \
"$XZ_BIN" \
"$WC_BIN" \
"$FIND_BIN"
"$FIND_BIN" \
"$TMUX_BIN"
do
export PATH="$(dirname "$bin"):$PATH"
done

View file

@ -68,6 +68,7 @@ with lib; let
"@DU_BIN@"
"@BZIP2_BIN@"
"@XZ_BIN@"
"@TMUX_BIN@"
]
# If you add anything here make sure to add it at the systemd service too
[
@ -89,6 +90,7 @@ with lib; let
"${pkgs.coreutils}/bin/du"
"${pkgs.bzip2}/bin/bzip2"
"${pkgs.xz}/bin/xz"
"${pkgs.tmux}/bin/tmux"
]
rawText;
in
@ -426,6 +428,7 @@ in {
queryBin = mkScript serverName serverCfg "query";
backupBin = mkScript serverName serverCfg "backup";
sayBin = mkScript serverName serverCfg "say";
consoleBin = mkScript serverName serverCfg "console";
routineBin = mkScript serverName serverCfg "backup-routine";
userActivityBin = mkScript serverName serverCfg "user-activity";
in {
@ -442,6 +445,7 @@ in {
"USERACTIVITY_BIN=${userActivityBin}/bin/minecraft-${serverName}-user-activity"
"BACKUP_BIN=${backupBin}/bin/minecraft-${serverName}-backup"
"SAY_BIN=${sayBin}/bin/minecraft-${serverName}-say"
"CONSOLE_BIN=${sayBin}/bin/minecraft-${serverName}-console"
"ROUTINE_BIN=${routineBin}/bin/minecraft-${serverName}-backup-routine"
"ZSTD_BIN=${pkgs.zstd}/bin/zstd"
# add more bin here
@ -459,6 +463,7 @@ in {
echo " $QUERY_BIN"
echo " $BACKUP_BIN"
echo " $SAY_BIN"
echo " $CONSOLE_BIN"
echo " $ROUTINE_BIN"
echo " $USERACTIVITY_BIN"
@ -468,6 +473,7 @@ in {
minecraft-${serverName}-rcon() { $RCON_BIN "$@"; }
minecraft-${serverName}-backup() { $BACKUP_BIN "$@"; }
minecraft-${serverName}-say() { $SAY_BIN "$@"; }
minecraft-${serverName}-console() { $CONSOLE_BIN "$@"; }
minecraft-${serverName}-backup-routine() { $ROUTINE_BIN "$@"; }
minecraft-${serverName}-user-activity() { $USERACTIVITY_BIN "$@"; }
@ -549,6 +555,7 @@ in {
(mkScript serverName serverCfg "query")
(mkScript serverName serverCfg "backup")
(mkScript serverName serverCfg "say")
(mkScript serverName serverCfg "console")
(mkScript serverName serverCfg "backup-routine")
(mkScript serverName serverCfg "user-activity")
])