mcserver/instances/forge-1.20.1-survival/runtime/console
2026-08-12 14:48:28 +00:00

21 lines
648 B
Bash
Executable file

#!/bin/bash
CONTAINER="mc_forge_server"
SESSION="mc_console"
# Install tmux if not installed
if ! command -v tmux &> /dev/null; then
echo "Installing tmux..."
sudo apt update && sudo apt install -y tmux
fi
# Clean up old session
tmux kill-session -t $SESSION 2>/dev/null
# Create top window: Live logs
tmux new-session -d -s $SESSION "docker logs -f --tail 100 $CONTAINER"
# Create bottom window: Interactive command prompt via rcon-cli
tmux split-window -v -l 3 -t $SESSION "while true; do read -e -p 'MC> ' cmd; [ -n \"\$cmd\" ] && docker exec -i $CONTAINER rcon-cli \"\$cmd\"; done"
# Open the split console
tmux attach -t $SESSION