aboutsummaryrefslogtreecommitdiff
path: root/env/.local/bin/scripts/autoport_mc.sh
blob: 370ff14e25787c266cf89ce888d5ae34ee3588eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh

# this finds the log file from a picked instance using rofi. then fords traffic thorugh 25565
if [ -z "$LOG_FILE" ]; then
    choice="$HOME/stuff/minecraft/polymc/instances/$(find ~/stuff/minecraft/polymc/instances -maxdepth 1 -exec basename {} \; | rofi -dmenu -p "Instance")"
    LOG_FILE="$(find "$choice" -mindepth 1 -maxdepth 1 -type d | grep "minecraft$")/logs/latest.log"
fi

setport="$(grep "Started on" "$LOG_FILE" | sed 's/.*Started on //' | tail -n 1)"
echo "$setport"
if [ "$setport" ]; then
    doas socat -v TCP6-LISTEN:25565,fork TCP4:127.0.0.1:"$setport"
fi