atr 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. CURR_USER="$USER"
  3. STEAM_USER="steam"
  4. TMUX_SESSION="$STEAM_USER-rust"
  5. RUST_SERVER_PATH="/home/steam/rust/server"
  6. if [[ "$CURR_USER" != "$STEAM_USER" ]]; then
  7. echo "Not steam user! Try login to steam..."
  8. /bin/su $STEAM_USER
  9. exit
  10. fi
  11. SESSION_EXISTS=`/usr/bin/tmux ls | /bin/grep "$TMUX_SESSION"`
  12. if [[ "$SESSION_EXISTS" == "" ]]; then
  13. # Create session
  14. /usr/bin/tmux new-session -d -s $TMUX_SESSION -n TOP
  15. # Create tabs
  16. /usr/bin/tmux new-window -t $TMUX_SESSION:1 -n APP
  17. /usr/bin/tmux new-window -t $TMUX_SESSION:2 -n LOGS
  18. /usr/bin/tmux new-window -t $TMUX_SESSION:3 -n MC1
  19. /usr/bin/tmux new-window -t $TMUX_SESSION:4 -n MC2
  20. /usr/bin/tmux new-window -t $TMUX_SESSION:5 -n SH
  21. # Execute commands
  22. /usr/bin/tmux send -t $TMUX_SESSION:0 "top" ENTER
  23. /usr/bin/tmux send -t $TMUX_SESSION:1 "cd $RUST_SERVER_PATH" ENTER
  24. /usr/bin/tmux send -t $TMUX_SESSION:1 "./run.sh"
  25. /usr/bin/tmux send -t $TMUX_SESSION:2 "cd $RUST_SERVER_PATH" ENTER
  26. /usr/bin/tmux send -t $TMUX_SESSION:2 "./log.sh" ENTER
  27. /usr/bin/tmux send -t $TMUX_SESSION:3 "cd $RUST_SERVER_PATH;mc" ENTER
  28. /usr/bin/tmux send -t $TMUX_SESSION:4 "cd $RUST_SERVER_PATH;mc" ENTER
  29. /usr/bin/tmux send -t $TMUX_SESSION:5 "cd $RUST_SERVER_PATH" ENTER
  30. # Select tab
  31. /usr/bin/tmux select-window -t $TMUX_SESSION:1
  32. /usr/bin/tmux attach-session -d -t $TMUX_SESSION
  33. else
  34. # Attach session
  35. /usr/bin/tmux attach-session -d -t $TMUX_SESSION
  36. fi