Resource icon

[Open Assets] srb2srv - SRB2 Server CLI

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
Description

This shell script has number of uses related to SRB2/SRB2Kart server.
Mainly, the script obtains information about IP, number of players, game type, etc. from https://ms.srb2.org and https://ms.kartkrew.org, which allows user to connect directly to selected server from SRB2/SRB2Kart Master Server list.

134928198-1b1b3837-1da0-4f97-bb23-e533d4da3487.gif


Features
  • Connecting directly to selected server's IP from SRB2/SRB2Kart Master Server,
  • Starting your own server and playing, or just creating dedicated one,
  • Checking if server is reachable (using jameds.org's Port Checker),
  • Runs on Linux, macOS and Windows (Git Bash).
Dependencies
  • Basic system utilities like GNU Coreutils, BusyBox or macOS out-of-the-box system utilities,
  • Bash or any POSIX compliant shell,
  • Findutils,
  • Which,
  • Curl,
  • Gawk,
  • Ncurses.
Additionally, Windows users need to have installed Git Bash to run this script.

Dependencies Installation

Linux:


1. In terminal enter this following commands:
- Debian/Ubuntu/Debian based/Ubuntu based: sudo apt install make git debianutils coreutils findutils ncurses-bin curl gawk,

- Arch/Arch based: sudo pacman -S --needed make git which coreutils findutils ncurses curl gawk,

- Gentoo/Gentoo based: sudo emerge -av dev-vcs/git sys-apps/which sys-apps/coreutils sys-apps/findutils sys-libs/ncurses net-misc/curl sys-apps/gawk,

- Fedora/Fedora based: sudo dnf install make git which coreutils findutils ncurses curl gawk,

- Fedora Silverblue/Fedora Kinoite/Fedora Onyx/Fedora Sericea: rpm-ostree install -A --allow-inactive make git which coreutils findutils ncurses curl gawk,

- openSUSE Leap/openSUSE Tumbleweed/openSUSE Leap based/openSUSE Tumbleweed based: sudo zypper in make git which coreutils findutils ncurses curl gawk,

- Void/Void based: sudo xbps-install -S make git which coreutils findutils ncurses curl gawk,

- Alpine/Alpine based: sudo apk add make git which coreutils findutils ncurses curl gawk,

- Solus/Solus based: sudo eopkg it make git which coreutils findutils ncurses curl gawk,

- NixOS/NixOS based: sudo nix profile install nixpkgs#gnumake nixpkgs#git nixpkgs#which nixpkgs#coreutils nixpkgs#findutils nixpkgs#ncurses nixpkgs#curl nixpkgs#gawk --extra-experimental-features 'nix-command flakes' or set those packages in "environment.systemPackages = with pkgs;" in "/etc/nixos/configuration.nix", and then enter sudo nixos-rebuild switch.

- Immutable systems like Steam Deck's SteamOS need rootless method of getting dependencies to avoid issues with wiping out installed packages after system's update or not to be able to write to certain path, like "/usr/local":
  • Homebrew: brew install make git coreutils findutils ncurses curl gawk,
  • Nix Portable: nix profile install nixpkgs#gnumake nixpkgs#git nixpkgs#which nixpkgs#coreutils nixpkgs#findutils nixpkgs#ncurses nixpkgs#curl nixpkgs#gawk --extra-experimental-features 'nix-command flakes'.
Windows:

1. Installing Git Bash:
  • Watch this video from 7:19 to 9:33,
2. Git Bash can be found on start menu,
3. The rest of dependencies are installed, if you followed video.

macOS:

1. In terminal enter this following command:
  • Homebrew: brew install gawk curl,
  • MacPorts: sudo port install gawk curl.
Installation

Linux:

  1. Open terminal,
  2. Enter git clone https://github.com/Bijman/srb2srv or download zip file HERE, which is always up to date,
  3. Go to downloaded directory: cd srb2srv,
  4. Enter sudo make install, which will install to "/usr/local/bin". You can specify your path with variable PREFIX, for example make install PREFIX=$HOME/.local, which will copy script to "$HOME/.local/bin". Alternatively manually place script to your path, which is readable by shell (PATH environment variable), and change script's permissions to be executable: chmod 755 [path to srb2srv script],
  5. Set other environment variables from "Configuration" section.
Windows:
  1. Open Git Bash,
  2. Go to your user directory (usually "C:/Users/[your username]"): cd ~,
  3. Enter git clone https://github.com/Bijman/srb2srv or download zip file HERE, which is always up to date, to user directory,
  4. Create directory "bin" with command: mkdir ~/bin,
  5. Copy script to "~/bin": cp ~/srb2srv/srb2srv ~/bin,
  6. Change script's permissions to be executable: chmod 755 ~/bin/srb2srv,
  7. Open text editor for "~/.bash_profile": nano ~/.bash_profile,
  8. In opened text editor from previous step write new path to executables with environment variable PATH like export PATH="~/bin:$PATH" in "~/.bash_profile",
  9. Enter `source ~/.bash_profile` or restart Git Bash.
  10. Set other environment variables from "Configuration" section of README.
  11. Set other environment variables from "Configuration" section.
macOS:
  1. Open terminal,
  2. Enter git clone https://github.com/Bijman/srb2srv or download zip file HERE, which is always up to date,
  3. Go to downloaded directory: cd srb2srv,
  4. Enter sudo make install, which will install to "/usr/local/bin". You can specify your path with variable PREFIX, for example make install PREFIX=$HOME/.local, which will copy script to "$HOME/.local/bin". Alternatively manually place script to your path, which is readable by shell (PATH environment variable), and change script's permissions to be executable: chmod 755 [path to srb2srv script],
  5. Set other environment variables from "Configuration" section.
Configuration

If you want to connect to server in SRB2:

  1. Enter your path to SRB2 executable file ("lsdl2srb2", "lsdlsrb2", "srb2", "srb2win.exe", "srb2win64.exe", "srb2.exe", "Sonic Robo Blast 2") or just type "flatpak org.srb2.SRB2" (for installed Flatpaks, Linux only) in shell configuration file (for example ".bash_profile" or ".bashrc" or ".zshrc" in user's home directory): export SRB2="[path to SRB2 executable file]" or export SRB2="flatpak org.srb2.SRB2". Note for macOS users: SRB2 executable file should be in "/Applications/Sonic Robo Blast 2.app/Contents/MacOS/Sonic Robo Blast 2", if "Sonic Robo Blast 2.app" is installed in "/Applications",
  2. Enter source ~/.bash_profile or source ~/.bashrc or source ~/.zshrc or restart terminal/Git Bash.
If you want to start your own server in SRB2:
  1. Enter your path to SRB2 executable file ("lsdl2srb2", "lsdlsrb2", "srb2", "srb2win.exe", "srb2win64.exe", "srb2.exe", "Sonic Robo Blast 2") or just type "flatpak org.srb2.SRB2" (for installed Flatpaks, Linux only) in shell configuration file (for example ".bash_profile" or ".bashrc" or ".zshrc" in user's home directory): export SRB2="[path to SRB2 executable file]" or export SRB2="flatpak org.srb2.SRB2",
  2. Enter source ~/.bash_profile or source ~/.bashrc or source ~/.zshrc or restart terminal/Git Bash.
If you want to connect to server or start your own server in SRB2Kart:
  1. Enter your path to SRB2Kart executable file (lsdl2srb2kart", "srb2kart", "srb2kart.exe", "Sonic Robo Blast 2 Kart") or just type "flatpak org.srb2.SRB2Kart" (for installed Flatpaks, Linux only) in shell configuration file (for example ".bash_profile" or ".bashrc" or ".zshrc" in user's home directory): export SRB2KART="[path to SRB2Kart executable file]" or export SRB2KART="flatpak org.srb2.SRB2Kart". Note for macOS users: SRB2Kart executable file should be in "/Applications/Sonic Robo Blast 2 Kart.app/Contents/MacOS/Sonic Robo Blast 2 Kart", if "Sonic Robo Blast 2 Kart.app" is installed in "/Applications",
  2. Enter source ~/.bash_profile or source ~/.bashrc or source ~/.zshrc or restart terminal/Git Bash.
Usage (from help text):

CLI for server related tools of SRB2/SRB2Kart. Usage: srb2srv [OPTION] <parameter> OPTIONS: -h, --help Show this help text. -c, --checkport Check if SRB2/SRB2Kart server is reachable. -d, --dedicated <addon-path> Start dedicated SRB2 server. -dk, --dedicatedkart <addon-path> Start dedicated SRB2Kart server. -f, --filter <filter-query> Filter list of SRB2 servers by query like server name, IP, gametype or map. -fk, --filterkart <filter-query> Filter list of SRB2Kart servers by query like server name, IP, gametype, kartspeed or map. -i, --ip <server-ip> Join SRB2 server from IP. -ik, --ipkart <server-ip> Join SRB2Kart server from IP. -k, --kart Go to SRB2Kart Master Server. -p, --port <port-number> Specify the local UDP port to use. Works with -c, -d, -dk, -s and -sk options. -r, --room <room-name> Go to SRB2 Master Server room. Available parameters: "standard", "casual" and "custom". -s, --server <addon-path> Start SRB2 server and play. -sk, --serverkart <addon-path> Start SRB2Kart server and play. EXAMPLES: 1. Go to SRB2 Master Server and connect to selected server from list: srb2srv 2. Go to SRB2Kart Master Server and connect to selected server from list: srb2srv --kart 3. Check if port 5030 for SRB2/SRB2Kart server is opened (default port to be checked is 5029 without --port option): srb2srv --checkport --port 5030 4. Run SRB2 server and add path to addon or directory of addons (default port to hosting server is 5029): srb2srv --server "$HOME/addon.pk3" 5. Run SRB2Kart dedicated server with port 5030, and add path to addon or directory of addons (default port to hosting server is 5029 without --port option): srb2srv --dedicatedkart "$HOME/addon.pk3" --port 5030 6. Join SRB2 server: srb2srv --ip 123.84.116.123:5029 7. Go to SRB2 Master Server room. Available parameters: "standard", "casual" and "custom": srb2srv --room standard 8. Filter list of SRB2 servers by server name: srb2srv --filter "The Gaming Den - Vanilla" 9. Filter list of SRB2Kart servers by kartspeed: srb2srv --filterkart "Normal" NOTES: - Exporting SRB2/SRB2Kart executable file ("lsdl2srb2", "lsdlsrb2", "srb2", "srb2win.exe", "srb2win64.exe", "srb2.exe", "Sonic Robo Blast 2", "lsdl2srb2kart", "srb2kart", "srb2kart.exe", "Sonic Robo Blast 2 Kart") path or "flatpak [SRB2/SRB2Kart Flatpak Application ID]" (for installed Flatpaks, Linux only) in "SRB2" or "SRB2KART" environment variable to shell configuration file (for example in ".bashrc" or ".bash_profile" or ".zshrc") is required for script to work. Here are a few examples: SRB2 1. Linux: - export SRB2="$HOME/Games/SRB2/lsdl2srb2", - export SRB2="$HOME/Games/SRB2/lsdlsrb2", - export SRB2="$HOME/Games/SRB2/srb2", - export SRB2="/usr/bin/srb2", - export SRB2="flatpak org.srb2.SRB2". 2. Windows: - export SRB2="$HOME/Games/SRB2/srb2win.exe", - export SRB2="$HOME/Games/SRB2/srb2win64.exe", - export SRB2="$HOME/Games/SRB2/srb2.exe", - export SRB2="C:\Users\user\Games\SRB2\srb2win.exe". 3. macOS: - export SRB2="/Applications/Sonic Robo Blast 2.app/Contents/MacOS/Sonic Robo Blast 2". SRB2Kart 1. Linux: - export SRB2KART="$HOME/Games/SRB2Kart/lsdl2srb2kart", - export SRB2KART="$HOME/Games/SRB2Kart/srb2kart", - export SRB2KART="/usr/bin/srb2kart", - export SRB2KART="flatpak org.srb2.SRB2Kart". 2. Windows: - export SRB2KART="$HOME/Games/SRB2Kart/srb2kart.exe", - export SRB2KART="C:\Users\user\Games\SRB2Kart\srb2kart.exe". 3. macOS: - export SRB2KART="/Applications/Sonic Robo Blast 2 Kart.app/Contents/MacOS/Sonic Robo Blast 2 Kart". - This script does not set port forwarding and open port in system's firewall for you. You need to do this manually on your router and system. For more information read the guide in: https://www.jameds.org/portforward. - To automate inputting in script for hosting server, do for example 'echo "1\n3" | srb2srv -d [path to directory of addons for dedicated server]', which means it will make input to list dedicated server in Custom room on Master Server. - Full path to game's main configuration file can be set with SRB2MAINCFG or SRB2KARTMAINCFG variable to shell configuration file, otherwise script assumes default file, if SRB2MAINCFG or SRB2KARTMAINCFG is not set. - There is also additional SRB2CFG and SRB2KARTCFG variables of other configuration files, which can temporary override settings of set SRB2MAINCFG and SRB2KARTMAINCFG. - To turn off automatic restart of server after error, set environment variable "export NOSRB2SRVLOOP=1". - Other environment variables to use. To activate them with value "1", do for example "export SRB2SRVDEBUG=1": - SRB2SRVDEBUG - Getting verbose output from script. Useful for reporting issues in https://github.com/bijman/srb2srv/issues.

Notes:

- This script does not set port forwarding and open port in system's firewall for you. You need to do this manually on your router and system. For more information read the guide in: https://www.jameds.org/portforward.

- To automate inputting in script for hosting server, do for example echo "1\n3" | srb2srv -d [path to directory of addons for dedicated server], which means it will make input to list dedicated server in Custom room on Master Server.

- Full path to game's main configuration file can be set with SRB2MAINCFG or SRB2KARTMAINCFG variable to shell configuration file, otherwise script assumes default file, if SRB2MAINCFG or SRB2KARTMAINCFG is not set.

- There is also additional SRB2CFG and SRB2KARTCFG variables of other configuration files, which can temporary override settings of set SRB2MAINCFG and SRB2KARTMAINCFG.

- To turn off automatic restart of server after error, set environment variable export NOSRB2SRVLOOP=1

- Other environment variables to use. To activate them with value "1", do for example "export SRB2SRVDEBUG=1":
Author
Bijman
Views
12,258
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Bijman

Share this resource

Latest updates

  1. Update 2023-11-21

    - Fixed issues with filtering servers when selecting SRB2 Master Server room, - Filter query is...
  2. Update 2023-11-20

    Features: - Added options -f/--filter and -fk/--filterkart to filter list of SRB2/SRB2Kart...
  3. Update 2022-04-27

    Added option to disable automatic restart of server after error. To turn off, set environment...
Back
Top