mirror of
https://github.com/greenseeker/t2server.git
synced 2026-01-21 12:14:47 +00:00
Compare commits
No commits in common. "master" and "0.7.1" have entirely different histories.
50
README.md
50
README.md
|
|
@ -2,44 +2,41 @@
|
|||
Scripts to install and run a Tribes 2 server on Linux with Wine.
|
||||
|
||||
## about
|
||||
t2server automates the installation of Tribes 2 and the TribesNEXT patch to run under wine on Linux. After installation, it provides systemd service units and Python scripts for the purpose of managing your server.
|
||||
t2server automates the installation of Tribes 2 and the TribesNEXT patch to run under wine on Linux.
|
||||
After installation, it provides systemd service units and Python scripts for the purpose of managing
|
||||
your server.
|
||||
|
||||
## prerequisites
|
||||
t2server has a handful of dependencies which are not automatically handled at this time. Before you run the setup script, run the following commands depending on your distro:
|
||||
t2server has a handful of dependencies which are not automatically handled at this time. Before you
|
||||
run the setup script, run the following commands depending on your distro:
|
||||
|
||||
### Debian 10; Ubuntu 20.04 LTS
|
||||
```
|
||||
$ sudo dpkg --add-architecture i386
|
||||
$ sudo apt update
|
||||
$ sudo apt upgrade
|
||||
$ sudo apt install unzip xvfb python3-minimal python3-pip wine32 cpulimit less
|
||||
$ sudo apt install unzip xvfb python3-minimal python3-pip wine32 cpulimit
|
||||
$ sudo pip3 install tqdm requests pyyaml
|
||||
```
|
||||
(more to be tested and added)
|
||||
|
||||
## installation
|
||||
Run the 'setup' script and follow the instructions on screen.
|
||||
|
||||
The Tribes 2 installer (tribes2\_gsi.exe) and the TribesNEXT installer (TribesNext\_rc2a.exe) will be downloaded automatically. If you already have a copy of these, you can place them in the winbin directory and setup will use them instead of downloading.
|
||||
|
||||
Before automatic installation, you'll be asked to review and agree to both the Tribes 2 and TribesNEXT License Agreements.
|
||||
|
||||
A 't2server' user will be created with a home directory of /opt/t2server, which is also where Tribes 2 will be installed.
|
||||
|
||||
A compiled AutoIt script handles automatic installation of Tribes 2 and TribesNEXT via Wine. This script logs to /var/log/t2server/install\_wrapper.log.
|
||||
|
||||
After install, any .vl2 files in the addons directory will be copied to the GameData/base directory. Any .tar, .tgz, .tar.gz, .txz, .tar.xz, .tbz, or .tar.bz files will be extracted into GameData. This can be used to automate the installation of any mods, map packs, texture packs, etc, just make sure the archive file contains the directory that should be created under GameData (eg. if you're including the Version2 mod, your archive file should have only a 'Version2' directory at the top level with all the contents within it). The setup script will not do any safety checks on these archive files, so an improperly set up archive file will make a mess in GameData.
|
||||
|
||||
## running and managing t2server
|
||||
The basic config file is /etc/t2server/config.yaml. Here you can specify which server prefs file to load, which mod to use, and whether the server is public or private (LAN). Additionally, you can schedule a day and time to auto-restart t2server each week as Tribes 2 servers are known to have stability issues as uptime increases. There is also a setting for overriding Tribes 2's man-in-the-middle attack detection, which tends to interfere with multihomed servers or those behind a NAT. Finally, you can specify a map rotation here. Some mods provide their own mechanisms for this and some do not. Be sure to only enable one or the other.
|
||||
t2server can be controlled using systemctl.
|
||||
|
||||
ServerPrefs files can be kept in /etc/t2server/serverprefs:
|
||||
- t2server can be controlled using systemctl:
|
||||
- Start server: `$ sudo systemctl start t2server`
|
||||
- Stop server: `$ sudo systemctl stop t2server`
|
||||
- Restart server: `$ sudo systemctl restart t2server`
|
||||
Start server: `$ sudo systemctl start t2server`
|
||||
|
||||
The Tribes 2 console logs to /var/log/t2server/console.log.
|
||||
Stop server: `$ sudo systemctl stop t2server`
|
||||
|
||||
Restart server: `$ sudo systemctl restart t2server`
|
||||
|
||||
The basic config file is /etc/t2server/config.yaml. Here you can specify which server prefs file to load, which mod to use, and whether the server is public or private (LAN).
|
||||
|
||||
Additionally, you can schedule a day and time to auto-restart t2server each week as Tribes 2 servers are known to have stability issues as uptime increases.
|
||||
|
||||
There is also a setting for overriding Tribes 2's man-in-the-middle attack detection, which tends to interfere with multihomed servers or those behind a NAT.
|
||||
|
||||
Finally, you can specify a map rotation here. Some mods provide their own mechanisms for this and some do not. Be sure to only enable one or the other.
|
||||
|
||||
serverprefs files can be kept in /etc/t2server/serverprefs.
|
||||
|
||||
## known issues
|
||||
If you attempt to install from /root or one of its subdirectories, the t2server user will not be able to access the winbin directory and the automated Tribes 2 and TribesNEXT installation will fail. Place the installer under /home, /tmp, /var/tmp, or some other path that is traversable by unprivileged users.
|
||||
|
|
@ -48,6 +45,7 @@ RHEL/CentOS 7 and 8 no longer include wine32 in their repos, so installing on th
|
|||
|
||||
t2server depends on systemd, so it definitely won't work on any distro that's not using it.
|
||||
|
||||
When wine is run in the background, it spawns 2 "wineconsole --use-event=*nn*" processes that will consume all available CPU. I have been unable to find a proper solution to this, so for now t2server will run cpulimit against these processes at startup in order to contain them. I have not seen this result in any performance issues.
|
||||
When wine is run in the background, it spawns a `wineconsole --use-event=52` process that will consume all available CPU. I have been unable to find a proper solution to this, so for now t2server will run cpulimit against this process at startup in order to contain it.
|
||||
|
||||
console.log includes ANSI escape sequences to set colors and terminal size, so your shell will get a little funky after tailing this log. Just run `reset` to reinitialize your session and you'll be back to normal.
|
||||
## legal compliance
|
||||
Tribes 2 and TribesNEXT are freely available but are not Free Software so the installers have not been bundled in. Instead, the setup script will automatically download and run them during installation. As the automated installation of both prevents you from seeing their license agreements, the setup script will display them in plain text and require you to accept them before installation runs.
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
---
|
||||
## ServerPrefs indicates the server config file in /etc/t2server/serverprefs to
|
||||
## use. This is case-sensitive and must match the filename exactly.
|
||||
## ServerPrefs indicates the server config file in /etc/t2server/serverprefs
|
||||
## to use. This is case-sensitive and must match the filename exactly.
|
||||
ServerPrefs: Classic_CTF.cs
|
||||
|
||||
## Tribes 2 servers tend to get unstable after a couple weeks of being online.
|
||||
## Here you can specify a day and hour to automatically bounce the server. Set
|
||||
## RestartTime to the hour of the day, 0-23, to cycle the server (eg. 4=4:00am,
|
||||
## 16=4:00pm) or False to disable. Set RestartDay to the three-letter
|
||||
## abbreviation of the day on which the server should be restarted (Sun, Mon,
|
||||
## Tue, Wed, Thu, Fri, or Sat). This will be ignored if RestartTime = False.
|
||||
## Here you can specify a day and hour to automatically bounce the server.
|
||||
## Set RestartTime to the hour of the day, 0-23, to cycle the server
|
||||
## (eg. 4=4:00am, 16=4:00pm) or False to disable. Set RestartDay to the
|
||||
## three-letter abbreviation of the day on which the server should be restarted
|
||||
## (Sun, Mon, Tue, Wed, Thu, Fri, or Sat). This will be ignored if
|
||||
## RestartTime = False.
|
||||
RestartTime: False
|
||||
RestartDay: Mon
|
||||
|
||||
## Set Mod to the directory name of the mod to be loaded, or 'base' for vanilla
|
||||
## (but why?). This is case-sensitive and must match the subdirectory name
|
||||
## exactly.
|
||||
## Set Mod to the directory name of the mod to be loaded, or 'base' for
|
||||
## vanilla (but why?). This is case-sensitive and must match the subdirectory
|
||||
## name exactly.
|
||||
Mod: Classic
|
||||
|
||||
## Set Public to False to host a LAN-only game, or to True to host a public
|
||||
|
|
@ -28,26 +29,14 @@ Public: False
|
|||
## detection. This setting has no effect if Public = False.
|
||||
OverrideMITM: True
|
||||
|
||||
## The built-in master server heartbeat sometimes works inconsistently. If you
|
||||
## have this problem, you can enable t2server's heartbeat. This has no effect
|
||||
## if Public = False.
|
||||
Heartbeat: False
|
||||
|
||||
## At startup, Tribes 2 compiles cs scripts into a dso binary format. If those
|
||||
## scripts are later updated, the changes won't take effect because the game
|
||||
## will continue to use the compiled dso. If DSOCleanup is enabled, t2server
|
||||
## will delete all dso files that are older than their associated cs file at
|
||||
## startup. Note that dso files associated with a cs file that only exists
|
||||
## within a vl2 package won't be touched and may occasionally need manual
|
||||
## cleanup.
|
||||
DSOCleanup: True
|
||||
|
||||
## Configure a custom map rotation list. The standard Mission Types are
|
||||
## "Bounty", "CnH" (Capture and Hold), "CTF" (Capture the Flag), "DM"
|
||||
## (Deathmatch), "DnD" (Defend and Destroy), "Hunters", "Rabbit", "Siege", map
|
||||
## "TeamHunters", and "TeamRabbit". If you're running a mod that handles
|
||||
## rotation, set these to 'False'.
|
||||
##
|
||||
## (Deathmatch), "DnD" (Defend and Destroy), "Hunters", "Rabbit", "Siege",
|
||||
## "TeamHunters", and "TeamRabbit". Your server will always launch with the
|
||||
## MissionType and Map specified in your serverprefs file ($Host::MissionType
|
||||
## and $Host::Map), so make sure MissionType matches $Host::MissionType and
|
||||
## the first map in MapList matches $Host::Map. If you're running a mod that
|
||||
## handles map rotation, set these to 'False'.
|
||||
## Example:
|
||||
## MissionType: CTF
|
||||
## MapList: ["Katabatic", "Minotaur", "Tombstone"]
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
0.8.0
|
||||
52
etc/t2server/serverprefs/Classic_CTF.cs
Normal file
52
etc/t2server/serverprefs/Classic_CTF.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
$Host::AdminPassword = "changethis";
|
||||
$Host::allowAdminPlayerVotes = "0";
|
||||
$Host::AllowMapScript = 1;
|
||||
$Host::BanTime = 1800;
|
||||
$Host::BotCount = 7;
|
||||
$Host::BotsEnabled = "0";
|
||||
$Host::ClassicSuperAdminPassword = "changethis";
|
||||
$Host::CRCTextures = 0;
|
||||
$Host::FloodProtectionEnabled = 1;
|
||||
$Host::GameName = "Tribes 2 Classic CTF Server";
|
||||
$Host::HiVisibility = "1";
|
||||
$Host::holoName1 = "Storm";
|
||||
$Host::holoName2 = "Inferno";
|
||||
$Host::holoName3 = "Starwolf";
|
||||
$Host::holoName4 = "DSword";
|
||||
$Host::holoName5 = "BloodEagle";
|
||||
$Host::holoName6 = "Harbinger";
|
||||
$Host::Info = "This is a Tribes 2 Classic Server.";
|
||||
$Host::KickBanTime = 300;
|
||||
$Host::Map = "Minotaur";
|
||||
$Host::MarkDnDObjectives = 1;
|
||||
$Host::MaxMessageLen = 120;
|
||||
$Host::MaxPlayers = "64";
|
||||
$Host::MissionType = "CTF";
|
||||
$Host::NoSmurfs = 0;
|
||||
$Host::PlayerRespawnTimeout = "60";
|
||||
$Host::Port = "28000";
|
||||
$Host::PureServer = 0;
|
||||
$Host::TeamDamageOn = "1";
|
||||
$Host::TeamName0 = "Unassigned";
|
||||
$Host::TeamName1 = "Storm";
|
||||
$Host::TeamName2 = "Inferno";
|
||||
$Host::TeamName3 = "Starwolf";
|
||||
$Host::TeamName4 = "Diamond Sword";
|
||||
$Host::TeamName5 = "Blood Eagle";
|
||||
$Host::TeamName6 = "Phoenix";
|
||||
$Host::TeamSkin0 = "blank";
|
||||
$Host::TeamSkin1 = "base";
|
||||
$Host::TeamSkin2 = "baseb";
|
||||
$Host::TeamSkin3 = "swolf";
|
||||
$Host::TeamSkin4 = "dsword";
|
||||
$Host::TeamSkin5 = "beagle";
|
||||
$Host::TeamSkin6 = "cotp";
|
||||
$Host::TimeLimit = "200";
|
||||
$Host::TN::beat = 3;
|
||||
$Host::TN::echo = 1;
|
||||
$Host::TournamentMode = "0";
|
||||
$Host::UseHighPerformanceCounter = 0;
|
||||
$Host::VotePassPercent = "60";
|
||||
$Host::VoteSpread = 20;
|
||||
$Host::VoteTime = "30";
|
||||
$Host::warmupTime = "20";
|
||||
430
setup
430
setup
|
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/env -S python3 -B
|
||||
from tqdm import tqdm
|
||||
from hashlib import md5
|
||||
from os import system, unlink, symlink, makedirs, geteuid, getcwd, chmod, rename
|
||||
from os.path import isfile, isdir
|
||||
from time import time
|
||||
|
|
@ -62,59 +60,10 @@ def download_file(url, filename):
|
|||
pbar.close()
|
||||
return filename
|
||||
|
||||
def version_compare(installed_version, package_version):
|
||||
if installed_version == package_version: return 0
|
||||
installed = installed_version.split(".")
|
||||
packaged = package_version.split(".")
|
||||
if installed[0] < packaged[0]:
|
||||
return 1
|
||||
elif installed[0] > packaged[0]:
|
||||
return -1
|
||||
if installed[1] < packaged[1]:
|
||||
return 1
|
||||
elif installed[1] > packaged[1]:
|
||||
return -1
|
||||
if installed[2] < packaged[2]:
|
||||
return 1
|
||||
elif installed[2] > packaged[2]:
|
||||
return -1
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Check for an existing install. Read version from the release file if it exists, otherwise assume 0.7.3
|
||||
if isfile(release_file):
|
||||
with open(release_file, 'r') as rf:
|
||||
installed_version = rf.read().rstrip()
|
||||
elif isfile(f"{install_dir}/GameData/Tribes2.exe"):
|
||||
installed_version = "0.7.3"
|
||||
else:
|
||||
installed_version = None
|
||||
|
||||
# Get the version in this install package
|
||||
if isfile(f"{pwd}/etc/t2server/release"):
|
||||
with open(f"{pwd}/etc/t2server/release", 'r') as rf:
|
||||
package_version = rf.read().rstrip()
|
||||
else:
|
||||
package_version = None
|
||||
|
||||
# Compare versions to see if the install package is newer than the installed version and quit if not
|
||||
if installed_version and package_version: upgrade = version_compare(installed_version, package_version)
|
||||
else: upgrade = None
|
||||
|
||||
# Exit if trying to update to an older version or the same version, otherwise display the initial menu and determine the setup mode
|
||||
if upgrade == -1:
|
||||
bail(f"This would install t2server {package_version} which is older than what's already installed, version {installed_version}.")
|
||||
elif upgrade == 0:
|
||||
bail(f"The existing t2server install is the same version as this install package, {package_version}.")
|
||||
elif upgrade == 1:
|
||||
setup_mode=menu([f"[U]pgrade to {package_version}","[Q]uit"],header=f"An existing t2server {installed_version} install was detected. 'Upgrade' will only update the scripts and files that come with t2server and won't reinstall Tribes 2.")
|
||||
if setup_mode == "Q": bail()
|
||||
else:
|
||||
action=menu(["~~[C]ontinue","[Q]uit"],header="This script will install Tribes 2 for use as a dedicated server.")
|
||||
if action == "Q": bail()
|
||||
setup_mode="I"
|
||||
|
||||
if setup_mode == "R":
|
||||
system(f"{pwd}/usr/local/bin/t2remove -Y")
|
||||
action=menu(["~~[C]ontinue","[Q]uit"],header="This script will install Tribes 2 for use as a dedicated server.")
|
||||
if action == "Q": bail()
|
||||
|
||||
# Check if user exists
|
||||
try:
|
||||
|
|
@ -122,232 +71,225 @@ if __name__ == "__main__":
|
|||
except KeyError:
|
||||
user_info = False
|
||||
|
||||
if setup_mode == "I" or setup_mode == "R":
|
||||
# Create or repurpose user if installing or reinstalling
|
||||
if user_info:
|
||||
if user_info.pw_dir == install_dir:
|
||||
pwarn(f"User '{user}' exists and will be reused.")
|
||||
else:
|
||||
bail(f"ERROR: User '{user}' already exists and may belong to another person or process.")
|
||||
# Create or repurpose user
|
||||
if user_info:
|
||||
if user_info.pw_dir == install_dir:
|
||||
pwarn(f"User '{user}' exists and will be reused.")
|
||||
else:
|
||||
print(f"Creating {user} user and {install_dir}.")
|
||||
system(f"useradd -md {install_dir} {user}")
|
||||
bail(f"ERROR: User '{user}' already exists and may belong to another person or process.")
|
||||
else:
|
||||
pinfo(f"Creating {user} user and {install_dir}.")
|
||||
system(f"useradd -md {install_dir} {user}")
|
||||
|
||||
if not user_info: user_info = getuser(user)
|
||||
if not user_info: user_info = getuser(user)
|
||||
|
||||
# Create log_dir
|
||||
print(f"Creating {log_dir}.")
|
||||
makedirs(log_dir, mode=0o777, exist_ok=True)
|
||||
chmod(log_dir, 0o777)
|
||||
# Create log_dir
|
||||
pinfo(f"Creating {log_dir}.")
|
||||
makedirs(log_dir, mode=0o777, exist_ok=True)
|
||||
chmod(log_dir, 0o777)
|
||||
|
||||
# Create .wine dir
|
||||
print(f"Creating {install_dir}/.wine defaults.")
|
||||
system(f"su - {user} -c'wineboot -i > /dev/null 2>&1'")
|
||||
# Create .wine dir
|
||||
pinfo(f"Creating {install_dir}/.wine defaults.")
|
||||
system(f"su - {user} -c'wineboot -i > /dev/null 2>&1'")
|
||||
|
||||
# Map wine I: drive to pwd T: drive to install_dir and L: to log_dir
|
||||
print(f"Mapping I: in wine for {user}.")
|
||||
try:
|
||||
symlink(f"{pwd}/winbin", f"{install_dir}/.wine/dosdevices/i:")
|
||||
except FileExistsError:
|
||||
# Map wine I: drive to pwd T: drive to install_dir and L: to log_dir
|
||||
pinfo(f"Mapping I: in wine for {user}.")
|
||||
try:
|
||||
symlink(f"{pwd}/winbin", f"{install_dir}/.wine/dosdevices/i:")
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
pinfo(f"Mapping L: in wine for {user}.")
|
||||
try:
|
||||
symlink(log_dir, f"{install_dir}/.wine/dosdevices/l:")
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
pinfo(f"Mapping T: in wine for {user}.")
|
||||
try:
|
||||
symlink(install_parent, f"{install_dir}/.wine/dosdevices/t:")
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
|
||||
# Check for needed exe/zip/dll files in winbin dir
|
||||
needed_files=[]
|
||||
if isfile(f"{pwd}/winbin/tribes2gsi.exe"):
|
||||
pinfo("tribes2gsi.exe found.")
|
||||
installer_exe = f"{pwd}/winbin/tribes2gsi.exe"
|
||||
elif isfile(f"{pwd}/winbin/tribes2_gsi.exe"):
|
||||
pinfo("tribes2_gsi.exe found.")
|
||||
installer_exe = f"{pwd}/winbin/tribes2_gsi.exe"
|
||||
else:
|
||||
pwarn("Tribes 2 installer not found.")
|
||||
needed_files.append("tribes2_gsi.exe")
|
||||
installer_exe = False
|
||||
|
||||
if isfile(f"{pwd}/winbin/TribesNext_rc2a.exe"):
|
||||
pinfo("TribesNext_rc2a.exe found.")
|
||||
tnpatch_exe = f"{pwd}/winbin/TribesNext_rc2a.exe"
|
||||
else:
|
||||
pwarn("Tribes Next patch not found.")
|
||||
needed_files.append("TribesNext_rc2a.exe")
|
||||
tnpatch_exe = False
|
||||
|
||||
ruby_dll = f"{pwd}/winbin/msvcrt-ruby191.dll"
|
||||
instwrap_exe = f"{pwd}/winbin/install_wrapper.exe"
|
||||
|
||||
# Download files if needed
|
||||
if not installer_exe or not tnpatch_exe:
|
||||
action=menu(["~~[D]ownload automatically","[Q]uit"],header="One or more needed files were not found. Download automatically or quit so they can be manually placed in the 'winbin' subdirectory?")
|
||||
if needed_files == 2:
|
||||
needed_files=f"{needed_files[0]} and {needed_files[1]}"
|
||||
if action=="Q": bail(f"Manually place {needed_files} in the 'winbin' subdirectory then rerun setup.")
|
||||
|
||||
if not installer_exe:
|
||||
for url in installer_mirror_list:
|
||||
try:
|
||||
pinfo(f"\nDownloading from {url.split('/')[2]}...")
|
||||
installer_exe = download_file(url, f"{pwd}/winbin/tribes2_gsi.exe")
|
||||
if md5sum(installer_exe) == installer_checksum:
|
||||
pinfo("Checksum validation passed.")
|
||||
break
|
||||
else:
|
||||
perror("Checksum validation failed. Trying next mirror.")
|
||||
except KeyError:
|
||||
perror("Download error. Trying next mirror.")
|
||||
continue
|
||||
|
||||
if not installer_exe:
|
||||
bail("ERROR: Tribes 2 installer could not be downloaded.")
|
||||
|
||||
if not tnpatch_exe:
|
||||
for url in tnpatch_mirror_list:
|
||||
try:
|
||||
pinfo(f"\nDownloading from {url.split('/')[2]}...")
|
||||
tnpatch_exe = download_file(url, f"{pwd}/winbin/TribesNext_rc2a.exe")
|
||||
if md5sum(tnpatch_exe) == tnpatch_checksum:
|
||||
pinfo("Checksum validation passed.")
|
||||
break
|
||||
else:
|
||||
perror("Checksum validation failed. Trying next mirror." )
|
||||
except KeyError:
|
||||
perror("Download error. Trying next mirror.")
|
||||
continue
|
||||
|
||||
if not tnpatch_exe:
|
||||
bail("ERROR: Tribes Next patch could not be downloaded.")
|
||||
|
||||
# Present SLAs before beginning install
|
||||
sla = None
|
||||
while not sla:
|
||||
sla=menu(["[V]iew Tribes 2 and TribesNext License Agreements", "[A]ccept License Agreements", "[Q]uit"], header="Please take a moment to review and accept the Tribes 2 and TribeNext License Agreements before beginning automated install.")
|
||||
if sla == "V":
|
||||
print(color.DY)
|
||||
system(f"/usr/bin/less {pwd}/sla/tribes2.txt")
|
||||
print(color.DP)
|
||||
system(f"/usr/bin/less {pwd}/sla/tribesnext.txt")
|
||||
sla = None
|
||||
elif sla == "A":
|
||||
break
|
||||
elif sla == "Q":
|
||||
bail("You must accept the License Agreements to install.")
|
||||
|
||||
# Ensure sufficient permissions on winbin and its contents
|
||||
chmod(f"{pwd}/winbin", 0o777)
|
||||
chmod(installer_exe, 0o777)
|
||||
chmod(tnpatch_exe, 0o777)
|
||||
chmod(instwrap_exe, 0o777)
|
||||
chmod(ruby_dll, 0o777)
|
||||
|
||||
# Execute install wrapper
|
||||
pinfo(f"\nInstalling Tribes 2 and the TribesNext patch in wine. Please wait...")
|
||||
chowner(install_dir, user)
|
||||
system(f"su - {user} -c'xvfb-run -as " + '"-fbdir /var/tmp"' + " wine I:/install_wrapper.exe > /dev/null 2>&1'")
|
||||
|
||||
# Rudamentary check to see if T2 install succeeded
|
||||
if not isfile(f"{install_dir}/Tribes 2 Solo & LAN.lnk"): bail(f"ERROR: Tribes 2 installation appears to have failed. Check {log_dir}/install_wrapper.log")
|
||||
|
||||
# Rudamentary check to see if TN install succeeded
|
||||
if not isfile(f"{install_dir}/GameData/TN_Uninstall.exe"): bail(f"ERROR: Tribes Next installation appears to have failed. Check {log_dir}/install_wrapper.log")
|
||||
|
||||
# Replace msvcrt-ruby190.dll with msvcrt-ruby191.dll
|
||||
pinfo("Updating msvcrt-ruby190.dll to msvcrt-ruby191.dll.\n")
|
||||
copyfile(ruby_dll,f"{install_dir}/GameData/msvcrt-ruby191.dll")
|
||||
unlink(f"{install_dir}/GameData/msvcrt-ruby190.dll")
|
||||
symlink(f"{install_dir}/GameData/msvcrt-ruby191.dll", f"{install_dir}/GameData/msvcrt-ruby190.dll")
|
||||
|
||||
# Install addons
|
||||
for addon in iglob(f"{pwd}/addons/*"):
|
||||
if addon.endswith(".zip"):
|
||||
pinfo(f"Unpacking {addon} into {install_dir}/GameData.")
|
||||
system(f"unzip -qqd {install_dir}/GameData {addon}")
|
||||
elif addon.endswith((".tar",".tgz",".tar.gz",".txz",".tar.xz",".tbz",".tar.bz")):
|
||||
pinfo(f"Unpacking {addon} into {install_dir}/GameData.")
|
||||
system(f"tar -C {install_dir}/GameData -xf {addon}")
|
||||
elif addon.endswith(".vl2"):
|
||||
pinfo(f"Copying {addon} to {install_dir}/GameData/base.")
|
||||
copyfile(addon,f"{install_dir}/GameData/base/{addon.split('/')[-1]}")
|
||||
elif addon.endswith("readme.txt"):
|
||||
pass
|
||||
|
||||
print(f"Mapping L: in wine for {user}.")
|
||||
try:
|
||||
symlink(log_dir, f"{install_dir}/.wine/dosdevices/l:")
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
print(f"Mapping T: in wine for {user}.")
|
||||
try:
|
||||
symlink(install_parent, f"{install_dir}/.wine/dosdevices/t:")
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
# Check for needed exe/zip/dll files in winbin dir
|
||||
needed_files=[]
|
||||
if isfile(f"{pwd}/winbin/tribes2gsi.exe"):
|
||||
pinfo("tribes2gsi.exe found.")
|
||||
rename(f"{pwd}/winbin/tribes2gsi.exe",f"{pwd}/winbin/tribes2_gsi.exe")
|
||||
installer_exe = f"{pwd}/winbin/tribes2_gsi.exe"
|
||||
elif isfile(f"{pwd}/winbin/tribes2_gsi.exe"):
|
||||
pinfo("tribes2_gsi.exe found.")
|
||||
installer_exe = f"{pwd}/winbin/tribes2_gsi.exe"
|
||||
else:
|
||||
pwarn("Tribes 2 installer not found.")
|
||||
needed_files.append("tribes2_gsi.exe")
|
||||
installer_exe = False
|
||||
|
||||
if isfile(f"{pwd}/winbin/TribesNext_rc2a.exe"):
|
||||
pinfo("TribesNext_rc2a.exe found.")
|
||||
tnpatch_exe = f"{pwd}/winbin/TribesNext_rc2a.exe"
|
||||
else:
|
||||
pwarn("Tribes Next patch not found.")
|
||||
needed_files.append("TribesNext_rc2a.exe")
|
||||
tnpatch_exe = False
|
||||
|
||||
ruby_dll = f"{pwd}/winbin/msvcrt-ruby191.dll"
|
||||
instwrap_exe = f"{pwd}/winbin/install_wrapper.exe"
|
||||
|
||||
# Download files if needed
|
||||
if not installer_exe or not tnpatch_exe:
|
||||
action=menu(["~~[D]ownload automatically","[Q]uit"],header="One or more needed files were not found. Download automatically or quit so they can be manually placed in the 'winbin' subdirectory?")
|
||||
if needed_files == 2:
|
||||
needed_files=f"{needed_files[0]} and {needed_files[1]}"
|
||||
if action=="Q": bail(f"Manually place {needed_files} in the 'winbin' subdirectory then rerun setup.")
|
||||
|
||||
if not installer_exe:
|
||||
for url in installer_mirror_list:
|
||||
try:
|
||||
pinfo(f"\nDownloading from {url.split('/')[2]}...")
|
||||
installer_exe = download_file(url, f"{pwd}/winbin/tribes2_gsi.exe")
|
||||
if md5sum(installer_exe) == installer_checksum:
|
||||
print("Checksum validation passed.")
|
||||
break
|
||||
else:
|
||||
perror("Checksum validation failed. Trying next mirror.")
|
||||
except KeyError:
|
||||
perror("Download error. Trying next mirror.")
|
||||
continue
|
||||
|
||||
if not installer_exe:
|
||||
bail("ERROR: Tribes 2 installer could not be downloaded.")
|
||||
|
||||
if not tnpatch_exe:
|
||||
for url in tnpatch_mirror_list:
|
||||
try:
|
||||
pinfo(f"\nDownloading from {url.split('/')[2]}...")
|
||||
tnpatch_exe = download_file(url, f"{pwd}/winbin/TribesNext_rc2a.exe")
|
||||
if md5sum(tnpatch_exe) == tnpatch_checksum:
|
||||
print("Checksum validation passed.")
|
||||
break
|
||||
else:
|
||||
perror("Checksum validation failed. Trying next mirror." )
|
||||
except KeyError:
|
||||
perror("Download error. Trying next mirror.")
|
||||
continue
|
||||
|
||||
if not tnpatch_exe:
|
||||
bail("ERROR: Tribes Next patch could not be downloaded.")
|
||||
|
||||
# Present SLAs before beginning install
|
||||
sla = None
|
||||
while not sla:
|
||||
sla=menu(["[V]iew Tribes 2 and TribesNext License Agreements", "[A]ccept License Agreements", "[Q]uit"], header="Please take a moment to review and accept the Tribes 2 and TribeNext License Agreements before beginning automated install.")
|
||||
if sla == "V":
|
||||
print(color.DY)
|
||||
system(f"/usr/bin/less {pwd}/sla/tribes2.txt")
|
||||
print(color.DP)
|
||||
system(f"/usr/bin/less {pwd}/sla/tribesnext.txt")
|
||||
sla = None
|
||||
elif sla == "A":
|
||||
break
|
||||
elif sla == "Q":
|
||||
bail("You must accept the License Agreements to install.")
|
||||
|
||||
# Ensure sufficient permissions on winbin and its contents
|
||||
chmod(f"{pwd}/winbin", 0o777)
|
||||
chmod(installer_exe, 0o777)
|
||||
chmod(tnpatch_exe, 0o777)
|
||||
chmod(instwrap_exe, 0o777)
|
||||
chmod(ruby_dll, 0o777)
|
||||
|
||||
# Execute install wrapper
|
||||
pinfo(f"\nInstalling Tribes 2 and the TribesNext patch in wine. Please wait...")
|
||||
chowner(install_dir, user)
|
||||
system(f"su - {user} -c'xvfb-run -as " + '"-fbdir /var/tmp"' + " wine I:/install_wrapper.exe > /dev/null 2>&1'")
|
||||
|
||||
# Rudamentary check to see if T2 install succeeded
|
||||
if not isfile(f"{install_dir}/Tribes 2 Solo & LAN.lnk"): bail(f"ERROR: Tribes 2 installation appears to have failed. Check {log_dir}/install_wrapper.log")
|
||||
|
||||
# Rudamentary check to see if TN install succeeded
|
||||
if not isfile(f"{install_dir}/GameData/TN_Uninstall.exe"): bail(f"ERROR: Tribes Next installation appears to have failed. Check {log_dir}/install_wrapper.log")
|
||||
|
||||
# Replace msvcrt-ruby190.dll with msvcrt-ruby191.dll
|
||||
print("Updating msvcrt-ruby190.dll to msvcrt-ruby191.dll.\n")
|
||||
copyfile(ruby_dll,f"{install_dir}/GameData/msvcrt-ruby191.dll")
|
||||
unlink(f"{install_dir}/GameData/msvcrt-ruby190.dll")
|
||||
symlink(f"{install_dir}/GameData/msvcrt-ruby191.dll", f"{install_dir}/GameData/msvcrt-ruby190.dll")
|
||||
|
||||
# Install addons
|
||||
for addon in iglob(f"{pwd}/addons/*"):
|
||||
if addon.endswith(".zip"):
|
||||
pinfo(f"Unpacking {addon} into {install_dir}/GameData.")
|
||||
system(f"unzip -qqd {install_dir}/GameData {addon}")
|
||||
elif addon.endswith((".tar",".tgz",".tar.gz",".txz",".tar.xz",".tbz",".tar.bz")):
|
||||
pinfo(f"Unpacking {addon} into {install_dir}/GameData.")
|
||||
system(f"tar -C {install_dir}/GameData -xf {addon}")
|
||||
elif addon.endswith(".vl2"):
|
||||
pinfo(f"Copying {addon} to {install_dir}/GameData/base.")
|
||||
copyfile(addon,f"{install_dir}/GameData/base/{addon.split('/')[-1]}")
|
||||
elif addon.endswith("readme.txt"):
|
||||
pass
|
||||
else:
|
||||
pwarn(f"Ignoring {addon}.")
|
||||
pwarn(f"Ignoring {addon}.")
|
||||
|
||||
# Copy t2server and t2bouncer to /usr/local/bin/
|
||||
if setup_mode == "U": print("Updating t2server script.")
|
||||
else: print("Installing t2server script.")
|
||||
pinfo("Installing t2server script.")
|
||||
copyfile(f"{pwd}/usr/local/bin/t2server",f"{bin_dir}/t2server")
|
||||
|
||||
if setup_mode == "U": print("Updating t2bouncer script.")
|
||||
else: print("Installing t2bouncer script.")
|
||||
pinfo("Installing t2bouncer script.")
|
||||
copyfile(f"{pwd}/usr/local/bin/t2bouncer",f"{bin_dir}/t2bouncer")
|
||||
|
||||
# Set owner/group on install_dir
|
||||
chowner(install_dir, user)
|
||||
|
||||
if setup_mode == "I" or setup_mode == "R":
|
||||
# Clean up temp dir and some unneeded files
|
||||
print("A little housekeeping...")
|
||||
if isfile(f"{install_dir}/Tribes 2 Online.lnk"): unlink(f"{install_dir}/Tribes 2 Online.lnk")
|
||||
if isfile(f"{install_dir}/Tribes 2 Solo & LAN.lnk"): unlink(f"{install_dir}/Tribes 2 Solo & LAN.lnk")
|
||||
if isfile(f"{install_dir}/UNWISE.EXE"): unlink(f"{install_dir}/UNWISE.EXE")
|
||||
if isfile(f"{install_dir}/Readme.txt"): unlink(f"{install_dir}/Readme.txt")
|
||||
if isfile(f"{install_dir}/GameData/Classic_LAN.bat"): unlink(f"{install_dir}/GameData/Classic_LAN.bat")
|
||||
if isfile(f"{install_dir}/GameData/Classic_dedicated_server.bat"): unlink(f"{install_dir}/GameData/Classic_dedicated_server.bat")
|
||||
if isfile(f"{install_dir}/GameData/Classic_online.bat"): unlink(f"{install_dir}/GameData/Classic_online.bat")
|
||||
if isfile(f"{install_dir}/GameData/base/EULA.txt"): unlink(f"{install_dir}/GameData/base/EULA.txt")
|
||||
if isfile(f"{install_dir}/GameData/base/UKEULA.txt"): unlink(f"{install_dir}/GameData/base/UKEULA.txt")
|
||||
if isdir(f"{install_dir}/Manual"): rmtree(f"{install_dir}/Manual")
|
||||
if isdir(f"{install_dir}/.wine/drive_c/users/t2server/Temp"): rmtree(f"{install_dir}/.wine/drive_c/users/t2server/Temp")
|
||||
if isfile(f"{install_dir}/t2csri_eula.txt"): unlink(f"{install_dir}/t2csri_eula.txt")
|
||||
if isfile(f"{install_dir}/Inside\ Team\ Rabbit\ 2.txt"): unlink(f"{install_dir}/Inside\ Team\ Rabbit\ 2.txt")
|
||||
if isfile(f"{install_dir}/UpdatePatch.txt"): unlink(f"{install_dir}/UpdatePatch.txt")
|
||||
if isfile(f"{install_dir}/Classic/Classic_readme.txt"): unlink(f"{install_dir}/Classic/Classic_readme.txt")
|
||||
if isfile(f"{install_dir}/Classic_technical.txt"): unlink(f"{install_dir}/Classic_technical.txt")
|
||||
# Clean up temp dir and some unneeded files
|
||||
pinfo("A little housekeeping...")
|
||||
if isfile(f"{install_dir}/Tribes 2 Online.lnk"): unlink(f"{install_dir}/Tribes 2 Online.lnk")
|
||||
if isfile(f"{install_dir}/Tribes 2 Solo & LAN.lnk"): unlink(f"{install_dir}/Tribes 2 Solo & LAN.lnk")
|
||||
if isfile(f"{install_dir}/UNWISE.EXE"): unlink(f"{install_dir}/UNWISE.EXE")
|
||||
if isfile(f"{install_dir}/Readme.txt"): unlink(f"{install_dir}/Readme.txt")
|
||||
if isfile(f"{install_dir}/GameData/Classic_LAN.bat"): unlink(f"{install_dir}/GameData/Classic_LAN.bat")
|
||||
if isfile(f"{install_dir}/GameData/Classic_dedicated_server.bat"): unlink(f"{install_dir}/GameData/Classic_dedicated_server.bat")
|
||||
if isfile(f"{install_dir}/GameData/Classic_online.bat"): unlink(f"{install_dir}/GameData/Classic_online.bat")
|
||||
if isfile(f"{install_dir}/GameData/base/EULA.txt"): unlink(f"{install_dir}/GameData/base/EULA.txt")
|
||||
if isfile(f"{install_dir}/GameData/base/UKEULA.txt"): unlink(f"{install_dir}/GameData/base/UKEULA.txt")
|
||||
if isdir(f"{install_dir}/Manual"): rmtree(f"{install_dir}/Manual")
|
||||
if isdir(f"{install_dir}/.wine/drive_c/users/t2server/Temp"): rmtree(f"{install_dir}/.wine/drive_c/users/t2server/Temp")
|
||||
if isfile(f"{install_dir}/t2csri_eula.txt"): unlink(f"{install_dir}/t2csri_eula.txt")
|
||||
if isfile(f"{install_dir}/Inside\ Team\ Rabbit\ 2.txt"): unlink(f"{install_dir}/Inside\ Team\ Rabbit\ 2.txt")
|
||||
if isfile(f"{install_dir}/UpdatePatch.txt"): unlink(f"{install_dir}/UpdatePatch.txt")
|
||||
if isfile(f"{install_dir}/Classic/Classic_readme.txt"): unlink(f"{install_dir}/Classic/Classic_readme.txt")
|
||||
if isfile(f"{install_dir}/Classic_technical.txt"): unlink(f"{install_dir}/Classic_technical.txt")
|
||||
|
||||
# Create config directory and files
|
||||
print(f"\nCreating {etc_dir}, default config, and installing prefs files.")
|
||||
pinfo(f"\nCreating {etc_dir}, default config, and installing prefs files.")
|
||||
makedirs(f"{etc_dir}/serverprefs", mode=0o775, exist_ok=True)
|
||||
if isfile(f"{etc_dir}/config.yaml"):
|
||||
timestamp = int(time())
|
||||
rename(f"{etc_dir}/config.yaml",f"{etc_dir}/config.yaml.{timestamp}")
|
||||
pwarn(f"Existing {etc_dir}/config.yaml renamed to {etc_dir}/config.yaml.{timestamp}. Be sure to compare with and update the new config.yaml file.")
|
||||
print(f"Writing default {etc_dir}/config.yaml.")
|
||||
pinfo(f"Writing default {etc_dir}/config.yaml.")
|
||||
copyfile(f"{pwd}/etc/t2server/config.yaml", f"{etc_dir}/config.yaml")
|
||||
print(f"Writing {etc_dir}/release")
|
||||
copyfile(f"{pwd}/etc/t2server/release", f"{etc_dir}/release")
|
||||
for pfile in iglob(f"{pwd}/etc/t2server/serverprefs/*"):
|
||||
pinfo(f"Copying {pfile} to {etc_dir}/serverprefs.")
|
||||
copyfile(pfile,f"{etc_dir}/serverprefs/{pfile.split('/')[-1]}")
|
||||
|
||||
# Create systemd units
|
||||
print("\nCreating systemd units:")
|
||||
print("- t2server service")
|
||||
pinfo("\nCreating systemd units:")
|
||||
pinfo("- t2server service")
|
||||
copyfile(f"{pwd}/etc/systemd/system/t2server.service",f"{unit_dir}/t2server.service")
|
||||
print("- t2bouncer service")
|
||||
pinfo("- t2bouncer service")
|
||||
copyfile(f"{pwd}/etc/systemd/system/t2bouncer.service",f"{unit_dir}/t2bouncer.service")
|
||||
print("- t2bouncer timer")
|
||||
pinfo("- t2bouncer timer")
|
||||
copyfile(f"{pwd}/etc/systemd/system/t2bouncer.timer",f"{unit_dir}/t2bouncer.timer")
|
||||
system("systemctl daemon-reload")
|
||||
|
||||
# Install utility scripts
|
||||
print("\nInstalling utilities:")
|
||||
print("- t2bouncer")
|
||||
pinfo("\nInstalling utilities:")
|
||||
pinfo("- t2bouncer")
|
||||
copyfile(f"{pwd}/usr/local/bin/t2fixer",f"{bin_dir}/t2fixer")
|
||||
print("- t2remove")
|
||||
pinfo("- t2remove")
|
||||
copyfile(f"{pwd}/usr/local/bin/t2remove",f"{bin_dir}/t2remove")
|
||||
print("- t2help")
|
||||
pinfo("- t2help")
|
||||
copyfile(f"{pwd}/usr/local/bin/t2help",f"{bin_dir}/t2help")
|
||||
|
||||
# Install python module
|
||||
|
|
@ -357,6 +299,6 @@ if __name__ == "__main__":
|
|||
|
||||
# Show help
|
||||
system(f"{bin_dir}/t2help")
|
||||
pinfo("You can run 't2help' at any time to view the info above again.")
|
||||
menu(['~~[E]xit'],header="You can run 't2help' at any time to view the info above again.")
|
||||
|
||||
print(f"{color.X}\n")
|
||||
|
|
@ -47,15 +47,6 @@ def setperm(file):
|
|||
pwarn(f"Failed to set permissions on {file}")
|
||||
log.write(f"... FAILED!\n")
|
||||
pass
|
||||
elif file == f"{etc_dir}/release":
|
||||
log.write(f"Setting mode 444 on {file}")
|
||||
try:
|
||||
chmod(file,0o444)
|
||||
log.write(f"\n")
|
||||
except:
|
||||
pwarn(f"Failed to set permissions on {file}")
|
||||
log.write(f"... FAILED!\n")
|
||||
pass
|
||||
else:
|
||||
log.write(f"Setting mode 664 on file {file}")
|
||||
try:
|
||||
|
|
@ -109,5 +100,4 @@ with open(f'{log_dir}/t2fixer.log', 'w') as log:
|
|||
setperm(f"{bin_dir}/t2remove")
|
||||
setperm(f"{bin_dir}/t2fixer")
|
||||
setperm(f"{bin_dir}/t2help")
|
||||
setperm(f"{bin_dir}/t2support.py")
|
||||
setperm(f"{etc_dir}/release")
|
||||
setperm(f"{bin_dir}/t2support.py")
|
||||
|
|
@ -1,20 +1,10 @@
|
|||
#!/usr/bin/env -S python3 -B
|
||||
from t2support import color, release_file
|
||||
from os.path import isfile
|
||||
|
||||
# Get the version from the release file
|
||||
if isfile(release_file):
|
||||
with open(release_file, 'r') as rf:
|
||||
version = rf.read().rstrip()
|
||||
else:
|
||||
version = None
|
||||
|
||||
if version: print(f"{color.DC}t2server {version}")
|
||||
from t2support import color
|
||||
|
||||
print(f"\n{color.DC}The follow commands can be used to manage your Tribes 2 server:")
|
||||
|
||||
print(f"""\n{color.BW}systemctl <action> t2server{color.DC}: The t2server service can be managed with the
|
||||
standard Linux systemctl command. See 'man systemctl' for more info.""")
|
||||
standard Linux systemctl command.""")
|
||||
|
||||
print(f"""\n{color.BW}t2fixer{color.DC}: This command resets the owner and permissions on all files associated
|
||||
with t2server. It's recommended to run this command any time you make changes
|
||||
|
|
|
|||
|
|
@ -10,26 +10,32 @@ from requests import get
|
|||
from threading import Thread
|
||||
from t2support import *
|
||||
|
||||
winecmd = ["/usr/bin/wine"]
|
||||
argbase = ["Tribes2.exe","-dedicated"]
|
||||
basecmd = winecmd + argbase
|
||||
parent = getppid()
|
||||
winecmd=["/usr/bin/wineconsole", "--backend=curses"]
|
||||
argbase=["Tribes2.exe","-dedicated"]
|
||||
basecmd=winecmd+argbase
|
||||
parent=getppid()
|
||||
|
||||
def dso_cleanup():
|
||||
"""
|
||||
This function finds all .dso files (compiled .cs scripts) and deletes them
|
||||
so that Tribes 2 will recompile them at startup.
|
||||
This function finds all .dso files (compiled .cs scripts) and deletes them
|
||||
if they are older than their associated .cs script so that Tribes 2 will
|
||||
recompile them at startup.
|
||||
"""
|
||||
for dso_file in iglob(f"{install_dir}/**/*.dso", recursive = True):
|
||||
print(f"Deleting {dso_file} so it can be rebuilt.")
|
||||
unlink(dso_file)
|
||||
for dso_file in iglob(f"{install_dir}/**/*.dso", recursive=True):
|
||||
cs_file=dso_file[:-4]
|
||||
if isfile(cs_file):
|
||||
cs_mtime=getmtime(cs_file)
|
||||
dso_mtime=getmtime(dso_file)
|
||||
if cs_mtime > dso_mtime:
|
||||
print(f"Deleting {dso_file} so it can be rebuilt.")
|
||||
unlink(dso_file)
|
||||
|
||||
def build_args(basecmd,config):
|
||||
"""
|
||||
This function assembles the command line to launch the server based on the
|
||||
config.yaml file.
|
||||
"""
|
||||
server_command = basecmd
|
||||
server_command=basecmd
|
||||
if config['Public']:
|
||||
server_command.append("-online")
|
||||
else:
|
||||
|
|
@ -57,12 +63,12 @@ def server_files(config):
|
|||
print(f"Deleting {install_dir}/GameData/{config['Mod']}/prefs/ServerPrefs.cs")
|
||||
unlink(f"{install_dir}/GameData/{config['Mod']}/prefs/ServerPrefs.cs")
|
||||
print(f"Linking {install_dir}/GameData/{config['Mod']}/prefs/ServerPrefs.cs -> {etc_dir}/serverprefs/{config['ServerPrefs']}")
|
||||
makedirs(f"{install_dir}/GameData/{config['Mod']}/prefs", mode = 0o755, exist_ok = True)
|
||||
makedirs(f"{install_dir}/GameData/{config['Mod']}/prefs", mode=0o755, exist_ok=True)
|
||||
symlink(f"{etc_dir}/serverprefs/{config['ServerPrefs']}", f"{install_dir}/GameData/{config['Mod']}/prefs/ServerPrefs.cs")
|
||||
|
||||
|
||||
if config["MapList"] and config["MissionType"]:
|
||||
print(f"Writing {install_dir}/GameData/base/prefs/missions.txt")
|
||||
makedirs(f"{install_dir}/GameData/base/prefs", mode = 0o755, exist_ok = True)
|
||||
makedirs(f"{install_dir}/GameData/base/prefs", mode=0o755, exist_ok=True)
|
||||
with open(f"{install_dir}/GameData/base/prefs/missions.txt", 'w') as mlist:
|
||||
for mission in config["MapList"]:
|
||||
mlist.write(f"{config['MissionType']} {mission}\n")
|
||||
|
|
@ -72,27 +78,28 @@ def server_files(config):
|
|||
with open(f"{install_dir}/GameData/base/prefs/missions.txt", 'w') as mlist:
|
||||
mlist.write("")
|
||||
|
||||
def runaway_control(runaway_proc_cmd):
|
||||
|
||||
def runaway_control():
|
||||
"""
|
||||
When run in the background, wine will spawn two 'wineconsole'
|
||||
processes that will consume all available CPU. This function finds these
|
||||
processes and uses cpulimit to keep them under control.
|
||||
When run in the background, wine will spawn a 'wineconsole --use-event=52'
|
||||
process that will consume all available CPU. This function finds that
|
||||
process and uses cpulimit to keep it under control.
|
||||
"""
|
||||
for x in range(20):
|
||||
sleep(15)
|
||||
print(f"Checking for runaway '{runaway_proc_cmd}' process...")
|
||||
runaway_pid = run(["/usr/bin/pgrep","-f", runaway_proc_cmd],stdout = PIPE).stdout
|
||||
print("Checking for runaway wineconsole process...")
|
||||
runaway_pid=run(["/usr/bin/pgrep","-f","wineconsole --use-event=52"],stdout=PIPE).stdout
|
||||
if runaway_pid:
|
||||
runaway_pid = str(int(runaway_pid))
|
||||
runaway_pid=str(int(runaway_pid))
|
||||
print(f"Limiting runaway wineconsole process: {runaway_pid}")
|
||||
run(["/usr/bin/cpulimit","-bp", runaway_pid,"-l2"])
|
||||
run(["/usr/bin/cpulimit","-bp",runaway_pid,"-l2"])
|
||||
break
|
||||
|
||||
def master_heartbeat():
|
||||
"""
|
||||
A public Tribes 2 server should send a regular heartbeat to the TribexNext
|
||||
master server so that it appears in the list, however this seems
|
||||
inconsistent, so this function takes over that responsibility if enabled.
|
||||
inconsistent, so this function takes over that responsibility.
|
||||
"""
|
||||
print("Starting TribesNext heartbeat thread...")
|
||||
while True:
|
||||
|
|
@ -103,24 +110,43 @@ def is_valid_ip(ip):
|
|||
"""Check if an ip looks like a valid IP address."""
|
||||
return bool(match(r"^(\d{1,3}\.){3}\d{1,3}$", ip))
|
||||
|
||||
def override_mitm():
|
||||
"""
|
||||
Tribes 2 servers try to detect descrepencies between their own IP and the IP
|
||||
that the client believes it's connecting to as possible man-in-the-middle
|
||||
attacks, however this often interfers with connections when the server is
|
||||
NATed or multi-homed. This function gets the public-facing IP of the host
|
||||
and writes an autoexec script to effectively disable this detection.
|
||||
"""
|
||||
for ip_service in ["http://api.ipify.org","http://ifconfig.me","http://ipinfo.io/ip"]:
|
||||
r=get(ip_service)
|
||||
if r.status_code == 200 and is_valid_ip(r.text):
|
||||
print(f"Got public IP address {r.text}")
|
||||
break
|
||||
if r.status_code != 200: bail("Could not get this server's public IP address.")
|
||||
print(f"Overriding Man-in-the-Middle attack detection.")
|
||||
with open(f'{install_dir}/GameData/base/scripts/autoexec/noMITM.cs', 'w') as nomitm_script:
|
||||
nomitm_script.write(f'$IPv4::InetAddress = "{r.text}";\n')
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Get the version from the release file and print it.
|
||||
if isfile(release_file):
|
||||
with open(release_file, 'r') as rf:
|
||||
version = rf.read().rstrip()
|
||||
else:
|
||||
version = None
|
||||
|
||||
if version: print(f"t2server version {version}")
|
||||
|
||||
# If run interactively, warn user that they probably don't want to do this unless troubleshooting.
|
||||
if parent == 1:
|
||||
print(f"Started by init")
|
||||
else:
|
||||
interactive_run = menu([f'[Y]es, run t2server interactively.',"~~[N]o, abort."], header = "Running t2server directly can be helpful for troubleshooting but generally it's best to manage your server with 'systemctl'. Do you still want to run t2server?", footer = "Choose [N] and run 't2help' if you're unsure of what to do.")
|
||||
interactive_run=menu(['[Y]es, run t2server interactively.',"~~[N]o, abort."],header="Running t2server directly can be helpful for troubleshooting but generally it's best to manage your server with 'systemctl'. Do you still want to run t2server?",footer="Choose [N] and run 't2help' if you're unsure of what to do.")
|
||||
if interactive_run == 'N': bail()
|
||||
chdir(f"{install_dir}/GameData")
|
||||
|
||||
# Set default configuration
|
||||
config_defaults = {
|
||||
'ServerPrefs' : 'Classic_CTF.cs',
|
||||
'Mod' : 'Classic',
|
||||
'Public' : False,
|
||||
'OverrideMITM': True,
|
||||
'MissionType' : 'CTF',
|
||||
'MapList' : False
|
||||
}
|
||||
|
||||
# Read configuration from config.yaml
|
||||
with open(f'{etc_dir}/config.yaml', 'r') as f:
|
||||
loaded_config = yaml.full_load(f)
|
||||
|
|
@ -135,55 +161,31 @@ if __name__ == "__main__":
|
|||
if not isfile(f"{etc_dir}/serverprefs/{config['ServerPrefs']}"):
|
||||
bail(f"Invalid ServerPrefs file: {config['ServerPrefs']}")
|
||||
|
||||
# Delete any pre-existing 00_t2server_opts script. It will be recreated below, if needed.
|
||||
if isfile(f"{install_dir}/GameData/base/scripts/autoexec/00_t2server_opts.cs"): unlink(f"{install_dir}/GameData/base/scripts/autoexec/00_t2server_opts.cs")
|
||||
# Delete any pre-existing noMITM script/dso. It will be recreated below, if needed.
|
||||
if isfile(f"{install_dir}/GameData/base/scripts/autoexec/noMITM.cs"): unlink(f"{install_dir}/GameData/base/scripts/autoexec/noMITM.cs")
|
||||
if isfile(f"{install_dir}/GameData/base/scripts/autoexec/noMITM.cs.dso"): unlink(f"{install_dir}/GameData/base/scripts/autoexec/noMITM.cs.dso")
|
||||
|
||||
# Create serverprefs symlink and missions.txt (if appropriate), clean out dso files, then assemble the command line arguments to launch the server
|
||||
# Create serverprefs symlink and missions.txt (if appropriate), clean out stale dso files, then assemble the command line arguments to launch the server
|
||||
server_files(config)
|
||||
if config['DSOCleanup']: dso_cleanup()
|
||||
server_command = build_args(basecmd,config)
|
||||
dso_cleanup()
|
||||
server_command=build_args(basecmd,config)
|
||||
|
||||
# Start the opts script with a comment at the top indicating this is auto-generated and shouldn't be edited, and also disable PureServer.
|
||||
opts_script_content = "// This file is updated automatically by t2server based on /etc/t2server/config.yaml.\n// Do not edit this file directly.\n$Host::PureServer = 0;\n"
|
||||
|
||||
# If this is a public server...
|
||||
# If this is a public server, start a hearbeat thread. Also write the MITM override file if configured.
|
||||
if config['Public']:
|
||||
# Start a heartbeat thread, if configured.
|
||||
if config['Heartbeat']:
|
||||
heartbeat = Thread(target = master_heartbeat)
|
||||
heartbeat.daemon = True
|
||||
heartbeat.start()
|
||||
# Capture the public IP for MITM override, if configured.
|
||||
if config['OverrideMITM']:
|
||||
for ip_service in ["http://api.ipify.org","http://ifconfig.me","http://ipinfo.io/ip"]:
|
||||
r = get(ip_service)
|
||||
if r.status_code == 200 and is_valid_ip(r.text):
|
||||
print(f"Got public IP address {r.text}")
|
||||
break
|
||||
if r.status_code != 200: bail("Could not get this server's public IP address.")
|
||||
opts_script_content += f'$IPv4::InetAddress = "{r.text}";\n'
|
||||
print(f"Overriding Man-in-the-Middle attack detection.")
|
||||
|
||||
# If MissionType and MapList are defined, write the first map into 00_t2server_opts.cs
|
||||
if config['MissionType'] and config['MapList']:
|
||||
opts_script_content += f'$Host::MissionType = "' + config['MissionType'] + '";\n$Host::Map = "' + config['MapList'][0] + '";\n'
|
||||
if config['MissionType'] and config['MissionType'].lower() != 'teamrabbit':
|
||||
opts_script_content += "$Host::LoadTR2Gametype = 0;\n"
|
||||
|
||||
# Write all options to the 00_t2server_opts file
|
||||
with open(f'{install_dir}/GameData/base/scripts/autoexec/00_t2server_opts.cs', 'w') as opts_script:
|
||||
opts_script.write(opts_script_content)
|
||||
print("Starting heartbeat...")
|
||||
if config['OverrideMITM']: override_mitm()
|
||||
heartbeat=Thread(target=master_heartbeat)
|
||||
heartbeat.daemon=True
|
||||
heartbeat.start()
|
||||
|
||||
# Cap the CPU of the runaway wineconsole processes
|
||||
wcpid1_limit = Thread(target = runaway_control, args = ("wineconsole --use-event=52",))
|
||||
wcpid1_limit.start()
|
||||
wcpid2_limit = Thread(target = runaway_control, args = ("wineconsole --use-event=188",))
|
||||
wcpid2_limit.start()
|
||||
# Cap the CPU of the runaway wineconsole process
|
||||
wcpid_limit=Thread(target=runaway_control)
|
||||
wcpid_limit.start()
|
||||
|
||||
# Open the console log file if running as service and start the Tribes 2 server
|
||||
print(f"Starting Tribes 2 server: " + " ".join(server_command))
|
||||
if parent == 1:
|
||||
with open(f"{log_dir}/console.log", 'w') as consolelog:
|
||||
run(server_command,stdout = consolelog)
|
||||
run(server_command,stdout=consolelog)
|
||||
else:
|
||||
run(server_command)
|
||||
run(server_command)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from tqdm import tqdm
|
||||
from re import search
|
||||
from requests import get
|
||||
from hashlib import md5
|
||||
from os import walk
|
||||
from os.path import join, islink
|
||||
from shutil import chown
|
||||
|
|
@ -14,18 +16,6 @@ etc_dir = "/etc/t2server"
|
|||
log_dir = "/var/log/t2server"
|
||||
unit_dir = "/etc/systemd/system"
|
||||
bin_dir = "/usr/local/bin"
|
||||
release_file = f"{etc_dir}/release"
|
||||
|
||||
config_defaults = {
|
||||
'ServerPrefs' : 'Classic_CTF.cs',
|
||||
'Mod' : 'Classic',
|
||||
'Public' : False,
|
||||
'OverrideMITM': False,
|
||||
'Heartbeat' : False,
|
||||
'DSOCleanup' : True,
|
||||
'MissionType' : 'CTF',
|
||||
'MapList' : False
|
||||
}
|
||||
|
||||
class color:
|
||||
X = '\033[m' # Reset
|
||||
|
|
@ -90,7 +80,7 @@ def menu(option_list,header="",footer=""):
|
|||
try:
|
||||
key=search(r'\[([0-9a-zA-Z])\]', option).group(1)
|
||||
except AttributeError:
|
||||
bail("Error while processing menu option list.")
|
||||
pass
|
||||
if option.startswith("~~"):
|
||||
default = str(key)
|
||||
keys.append(key.upper())
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ WriteLog("Wait for Tribes Vengeance Preorder window: " & WinWait("Tribes: Vengea
|
|||
WriteLog("Click [Next]: " & ControlClick("Tribes: Vengeance", "Click here to Pre-order Tribes: Vengeance Now!", 5)) ; click "Next >"
|
||||
|
||||
; Welcome 2
|
||||
WriteLog("Wait for Welcome: " & WinWait("Welcome", "Welcome to the Tribes 2 Setup program", 180))
|
||||
WriteLog("Wait for Welcome: " & WinWait("Welcome", "Welcome to the Tribes 2 Setup program", 60))
|
||||
WriteLog("Click [Next]: " & ControlClick("Welcome", "Welcome to the Tribes 2 Setup program", 3)) ; click "Next >"
|
||||
|
||||
; Credits
|
||||
|
|
@ -46,7 +46,7 @@ WriteLog("Wait for Start Installation window: " & WinWait("Start Installation",
|
|||
WriteLog("Click [Next]: " & ControlClick("Start Installation", "You are now ready to install Tribes 2.", 3)) ; click "Next >"
|
||||
|
||||
; Register
|
||||
WriteLog("Wait for Register window: " & WinWait("Register", "You can register Tribes 2 on the World Wide Web.", 180))
|
||||
WriteLog("Wait for Register window: " & WinWait("Register", "You can register Tribes 2 on the World Wide Web.", 60))
|
||||
WriteLog("Uncheck 'Register Tribes 2 Now': " & ControlClick("Register", "You can register Tribes 2 on the World Wide Web.", 9)) ; uncheck "Register Tribes 2 Now"
|
||||
WriteLog("Click [Next]: " & ControlClick("Register", "You can register Tribes 2 on the World Wide Web.", 3)) ; click "Next >"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue