diff options
Diffstat (limited to 'rconsole')
-rwxr-xr-x | rconsole/rconsole | 40 | ||||
-rwxr-xr-x | rconsole/rconsole-input | 9 | ||||
-rwxr-xr-x | rconsole/rconsole-output | 12 |
3 files changed, 61 insertions, 0 deletions
diff --git a/rconsole/rconsole b/rconsole/rconsole new file mode 100755 index 0000000..835952a --- /dev/null +++ b/rconsole/rconsole @@ -0,0 +1,40 @@ +#!/bin/bash + +if [ "$#" -lt 1 ]; then + echo "usage: $0 [instance]" + exit 1 +fi + +export RCONSOLE_INSTANCE="$1" +export RCONSOLE_SCREEN="rconsole" +export RCONSOLE_PIPE="/home/zittrig/tremulous/server/@$RCONSOLE_INSTANCE/home/slacker/pipe" + +if [ ! -p "$RCONSOLE_PIPE" ]; then + printf "\"%s\" is not a pipe\n" "$RCONSOLE_PIPE" + exit 1 +fi + +SESSION="$RCONSOLE_SCREEN" + +screen -S $SESSION -X quit + +screen -S $SESSION -a -O -d -m -T xterm -s rconsole-output || exit +screen -S $SESSION -X screen rconsole-input || exit + +( + while ! screen -list | grep "$SESSION.*Attached" > /dev/null; do + sleep 0.01s + done + + screen -S $SESSION -X select 0 + screen -S $SESSION -X title "Server logs" + screen -S $SESSION -X split + screen -S $SESSION -X focus + screen -S $SESSION -X select 1 + screen -S $SESSION -X title "Rcon" + screen -S $SESSION -X resize 10% +) & + +screen -d -r $SESSION +clear +echo "[rconsole has finished]" diff --git a/rconsole/rconsole-input b/rconsole/rconsole-input new file mode 100755 index 0000000..3fe076e --- /dev/null +++ b/rconsole/rconsole-input @@ -0,0 +1,9 @@ +#!/bin/bash + +trap 'screen -S "$RCONSOLE_SCREEN" -X quit; exit' SIGINT + +PROMPT="(rcon@$RCONSOLE_INSTANCE) " + +while read -e -p "$PROMPT" line; do + printf "$line\n" > "$RCONSOLE_PIPE" +done diff --git a/rconsole/rconsole-output b/rconsole/rconsole-output new file mode 100755 index 0000000..a6eba89 --- /dev/null +++ b/rconsole/rconsole-output @@ -0,0 +1,12 @@ +#!/bin/bash + +trap 'screen -S "$RCONSOLE_SCREEN" -X quit; exit' SIGINT + +IDENTIFIER="tremded@$RCONSOLE_INSTANCE" + +journalctl --user -f -o cat SYSLOG_IDENTIFIER="$IDENTIFIER" \ +|| ( + echo "journalctl didn't work" + read + exit +) |