Linux distro used | Linux Mint 20.3 Cinnamon v5.2.7 |
Linux Kernel | 5.4.0-107-generic |
Winetricks version | 20220411 |
Wine version | 7.0 |
1) Install Wine
Wine is an open-source compatibility layer that allows you to run Windows applications on Unix-like operating systems such as Linux. I will be installing the latest stable version from winehq.org in this setup.
Open up a terminal
If your system is 64 bit, enable 32 bit architecture:
Code: Select all
sudo dpkg --add-architecture i386
Code: Select all
wget -nc https://dl.winehq.org/wine-builds/winehq.key
Code: Select all
sudo mv winehq.key /usr/share/keyrings/winehq-archive.key
Code: Select all
wget -nc https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources
Code: Select all
sudo mv winehq-focal.sources /etc/apt/sources.list.d/
Code: Select all
sudo apt update
Code: Select all
sudo apt install --install-recommends winehq-stable
2) Install Winetricks
The normal install is either through the software manager or command line:
Code: Select all
sudo apt-get install winetricks
Code: Select all
sudo winetricks --self-update
3) Setup a wine Prefix for Nolf2
Just to explain this concept so that people who aren't used to dealing with this will understand how it works, a few programs such as NOLFSrv.exe for Nolf1 will run out of the box without any extra dependencies. Other software like Nolf2Srv.exe needs extra windows components in order to function.
I have my custom wine prefixes (also refered to as wine bottles) in a directory named Wine in my user's home directory.
Each program should have its own prefix, unless they are somewhat related and runs with the same dependencies.
So in a nutshell:
Here are 3 examples that have their own separate registry, dll files, C:\ drive and other windows components.
This is where Winetricks becomes relevant. You use this program to choose what extra components the program needs to function.
Let's create a wine prefix for Nolf2
From this point forward, you won't need sudo rights to configure the rest. This means that you can create a user with limited privileges who will run the game server.
Nolf2 is a win32 application, so we specify that with WINEARCH=win32, we also want to create the wine prefix, and last we put in the wine command that will create this prefix. I also prefer short names on folders when dealing with terminal, less to write and less problems with spaces. So I'll name my prefix folder nolf2 rather than No-One-Lives-Forever-A-Spy-In-Harms-Way.
Code: Select all
WINEARCH=win32 WINEPREFIX=~/Wine/nolf2 winecfg
After running this command, this window will eventually appear:
I'll choose Windows 7 here because I am not sure how the 2015 C++ redistributables will react to for example Windows XP.
You can then close the window.
To make Nolf2Srv run in wine, you'll need a couple of dependencies
Back in your terminal change the last word to winetricks
Code: Select all
WINEARCH=win32 WINEPREFIX=~/Wine/nolf2 winetricks
Select the default wine prefix
And choose to install a windows dll or component
vb6run | should take care of the original code for the game |
vcrun2015 | or newer should work just fine for the modernizer code |
vcrun6 | I suspect that I needed this in order to pass arguments to NOLF2Srv |
Install these and most likely ignore a lot of errors, if they don't install all at once, try installing them one by one.
When you're back to the main windows in winetricks, you click cancel to exit.
Tada, the prefix is ready!
4) Copy over Nolf2
When you go into Wine --> nolf2 (your wineprefix) you will find a bunch of newly created stuff
This folder named drive_c is now your C:\ drive
In there you will also find some familiar windows component that has a minimum of what Nolf2Srv needs to function
This is where I make another folder named nolf2, and copy the game (in preinstalled form) into it.
To finally test if the whole thing even runs, type this into your terminal
Code: Select all
WINEPREFIX=~/Wine/nolf2 wine ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe
If everything works, you should see this, you may or may not be able to choose a profile to load. I could never get the dropdown menu for profiles show up. ERROR - Unable to load resources simply means that it cannot find your profiles.
To load the server with a flag/argument you will need to alter the command slightly
Code: Select all
WINEPREFIX=~/Wine/nolf2 wine start /unix ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe -profile spawn
5) Create a new profile
NOTE: Make sure that lithtech.exe runs with admin privledges
In order for the profile to work with modernizer, it is a good idea to create a new profile from scratch, select:
Create a new profile and type in a profile name, hit ok and back
Next step is to start a new server by clicking Multiplayer (internet),
then select the game type you want to host.
Select Host, and this screen appears
Click Campaign and create a new campaign
The name here can be anything, this is not the one you pass on to the server later
Next up is map selection, this explains itself pretty well.
Next you should set a network port and forward this port and the next one in your firewall.
In this case port:27892 and port:27893
Make sure Dedicated Server is set to Yes
and finally click Launch
This will create everything you need in your game folder in order to run dedicated with the stand alone NOLF2Srv.exe
6) Copy profile over to the linux server
Open your Profiles folder on the computer you used to configure your game server and copy your <profile.txt> and the folder with the same name over to the Profiles folder on the server.
Also make sure that your DMMissions.txt and DDMissions.txt from the game folder are the same as the ones you have on the computer where you configured the game server.
Let's start this thing:
Code: Select all
WINEPREFIX=~/Wine/nolf2 wine start /unix ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe -profile spawn
If the Running time counter starts to run, it should work
7) Keep it alive
Nolf2 servers tend to crash from time to time, so a auto restart function could be a good idea.
My initial plan was to have Crontab running a check every mine to see if the server was alive or not, but Wine doesn't seem to be friends with Crontab. This is why I ended up creating a launcher that starts the server + a script that will guard it.
First of all, you would want to shut down any display of error messages after a crash, this will prevent the script from restarting Nolf2srv.exe. Launch Winetricks:
Code: Select all
WINEPREFIX=~/Wine/nolf2 winetricks
This time choose "Change settings"
Then disable the crash dialog by selecting nocrashdialog
Open up your favorite text editor and copy/paste this:
Code: Select all
#!/bin/bash
while :
do
(/bin/ps aux | /bin/grep -v 'grep' | /bin/grep 'nolf2srv' 2>&1 >/dev/null || WINEPREFIX=~/Wine/nolf2 wine start /unix ~/Wine/nolf2/drive_c/nolf2/nolf2srv.exe -profile spawn)
sleep 60
done
This little script will search for the process nolf2srv and execute the start server command if the process doesn't exist. This function is packed into a while loop that will run every 60 seconds and will go on forever.
I saved it as nolf2dm.sh in my Wine folder and made it executable.
Code: Select all
chmod +x ~/Wine/nolf2dm.sh
You can now start the server and script by command
Code: Select all
sh ~/Wine/nolf2dm.sh
If you prefer a clickable button on your desktop, this can be done by right clicking the desktop and creating a new launcher with the command:
Code: Select all
/home/<your username>/Wine/nolf2dm.sh