Wrapper that auto-authenticates via rbw (Bitwarden) for RCON access. - Uses minecraft-rcon entry from Bitwarden - Defaults to 10.0.0.165:25575 (LoadBalancer IP) - Supports MCRCON_HOST/PORT overrides - Interactive terminal mode when no args provided Part of k3s-cluster-config bead k3s-cluster-config-byg
This commit is contained in:
@@ -3,4 +3,5 @@
|
|||||||
tea-rbw = pkgs.callPackage ./tea-rbw {};
|
tea-rbw = pkgs.callPackage ./tea-rbw {};
|
||||||
app-launcher-server = pkgs.callPackage ./app-launcher-server {};
|
app-launcher-server = pkgs.callPackage ./app-launcher-server {};
|
||||||
claude-code = pkgs.callPackage ./claude-code {};
|
claude-code = pkgs.callPackage ./claude-code {};
|
||||||
|
mcrcon-rbw = pkgs.callPackage ./mcrcon-rbw {};
|
||||||
}
|
}
|
||||||
|
|||||||
40
packages/mcrcon-rbw/default.nix
Normal file
40
packages/mcrcon-rbw/default.nix
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
pkgs.writeShellScriptBin "mcrcon" ''
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Configuration - can be overridden with environment variables
|
||||||
|
MINECRAFT_RCON_HOST="''${MCRCON_HOST:-10.0.0.165}"
|
||||||
|
MINECRAFT_RCON_PORT="''${MCRCON_PORT:-25575}"
|
||||||
|
RBW_ENTRY="minecraft-rcon"
|
||||||
|
|
||||||
|
# Check if rbw is available
|
||||||
|
if ! command -v rbw &> /dev/null; then
|
||||||
|
echo "Error: rbw is not available. Please ensure rbw is installed and configured."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Retrieve password from Bitwarden
|
||||||
|
if ! MCRCON_PASS=$(rbw get "$RBW_ENTRY" 2>/dev/null); then
|
||||||
|
echo "Error: Failed to retrieve RCON password from rbw entry '$RBW_ENTRY'"
|
||||||
|
echo "Please ensure the entry exists in Bitwarden and rbw is synced."
|
||||||
|
echo ""
|
||||||
|
echo "To create the entry:"
|
||||||
|
echo " 1. Add 'minecraft-rcon' to Bitwarden with the RCON password"
|
||||||
|
echo " 2. Run 'rbw sync' to refresh the local cache"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Export for mcrcon
|
||||||
|
export MCRCON_HOST="$MINECRAFT_RCON_HOST"
|
||||||
|
export MCRCON_PORT="$MINECRAFT_RCON_PORT"
|
||||||
|
export MCRCON_PASS
|
||||||
|
|
||||||
|
# If no arguments provided, start interactive terminal mode
|
||||||
|
if [[ $# -eq 0 ]]; then
|
||||||
|
exec ${pkgs.mcrcon}/bin/mcrcon -t
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Execute mcrcon with all provided arguments
|
||||||
|
exec ${pkgs.mcrcon}/bin/mcrcon "$@"
|
||||||
|
''
|
||||||
Reference in New Issue
Block a user