IzNoGoD
26th April 2021, 17:05
Hello,
This is a tutorial on how to run a libcod-enabled cod2 server on WSL2, on top of windows 10. This is a very quick and dirty tutorial.
This tutorial assumes you have a working wsl2 install: https://www.sitepoint.com/wsl2/ up to and including the part where you set wsl --set-default-version 2
Now, download and install ubuntu 20.04 from the windows store. This will present you with a screen asking you to enter a username. I'm using "cod2user" as my username.
After setting a password, you get logged in to the WSL2 ubuntu 20.04 terminal.
From here, we are running a few commands:
sudo apt update
sudo apt dist-upgrade
sudo apt install ssh
Now we need to add our public key to the VM. Generate one using puttygen, which you can find after installing putty from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html I personally prefer using a ED25519 key.
My public key looks something like this:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIALemzRolc4EjY9F0xp0YpfYgf KLqptc9+XRrWkGphk9 ed25519-key-20210426
My private key is private, and I saved it using "save private key". I am not using a passphrase to protect it.
I'm now creating the files required for the ssh key to be associated with my account on the VM:
mkdir .ssh
chmod 700 .ssh
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIALemzRolc4EjY9F0xp0YpfYgf KLqptc9+XRrWkGphk9 ed25519-key-20210426" >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
Now it's time to restart our ssh daemon:
sudo service ssh restart
Furthermore, we need to determine the ip of the vm. Running
ip addr show eth0 | grep "inet "
Gives you the ip (and subnet) of the machine. Mine is 172.31.140.5.
From here, we switch to using winscp: https://winscp.net/eng/download.php
Create a new site, host name is the ip you found in the previous part. Port number remains 22, user name is the user you created earlier (cod2user for this tutorial). Password remains empty.
Click advanced, ssh, authentication and brows to your private key file you saved earlier using the "..." behind the "private key file" box.
Click Ok, save, and connect. On first connect it will warn you about the change in the server's key file, which is fine.
Now that we are connected through winscp (and by extension have acces to ssh), we can close the VM window.
Setting up the machine
Now, install some prerequisites:
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libstdc++5:i386 libmysqlclient-dev:i386 screen g++-multilib git
Now, lets clone ourselves a git repo of libcod and compile it:
git clone https://github.com/voron00/libcod
cd libcod
./doit.sh cod2_1_3
cd
With that out of the way, lets create a folder for our cod2 install to reside:
mkdir -p cod2/main
Now we switch back to winscp (refresh) and go to cod2/main. Upload all stock iwd files from your local cod2 install to there. This should go rather quick as it's local network.
Download the cod2_lnxded binary of choice from here: https://killtube.org/showthread.php?1719-Latest-cod2-linux-binaries-%281-0-1-2-1-3%29 My personal choice is the cod2_lnxded_1_3_nodelay_va_loc. After downloading and extracting, rename it to cod2_lnxded_1_3 and upload it to the cod2 folder (next to the main folder).
Now we need to create the bash script that actually starts the server. Create a file in your home directory named run.sh and copy paste the content below into it:
#!/bin/bash
sv_maxclients="32"
fs_game=""
fs_homepath="/home/$USER/cod2"
cod="/home/$USER/cod2/cod2_lnxded_1_3"
com_hunkMegs="256"
config="configfile.cfg"
cracked="1"
net_port="28960"
args=\
"+set fs_homepath \"$fs_homepath\" "\
"+set sv_cracked $cracked "\
"+set fs_game $fs_game "\
"+set net_port $net_port "\
"+set com_hunkMegs $com_hunkMegs "\
"+set sv_maxclients $sv_maxclients "\
"+set fs_basepath \"$fs_homepath\" "\
"+exec $config"
LD_PRELOAD="/home/$USER/libcod/bin/libcod2_1_3.so" $cod $args +set g_gametype tdm +map mp_toujane
Now, lets grant execute permissions to both the binary and the bash files:
chmod 700 run.sh
chmod 700 cod2/cod2_lnxded_1_3
And run the actual server:
./run.sh
You can now start your cod2 client and connect to your server using /connect [ip]. In case of this tutorial, that's /connect 172.31.140.5
And that's all there's to it.
This is a tutorial on how to run a libcod-enabled cod2 server on WSL2, on top of windows 10. This is a very quick and dirty tutorial.
This tutorial assumes you have a working wsl2 install: https://www.sitepoint.com/wsl2/ up to and including the part where you set wsl --set-default-version 2
Now, download and install ubuntu 20.04 from the windows store. This will present you with a screen asking you to enter a username. I'm using "cod2user" as my username.
After setting a password, you get logged in to the WSL2 ubuntu 20.04 terminal.
From here, we are running a few commands:
sudo apt update
sudo apt dist-upgrade
sudo apt install ssh
Now we need to add our public key to the VM. Generate one using puttygen, which you can find after installing putty from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html I personally prefer using a ED25519 key.
My public key looks something like this:
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIALemzRolc4EjY9F0xp0YpfYgf KLqptc9+XRrWkGphk9 ed25519-key-20210426
My private key is private, and I saved it using "save private key". I am not using a passphrase to protect it.
I'm now creating the files required for the ssh key to be associated with my account on the VM:
mkdir .ssh
chmod 700 .ssh
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIALemzRolc4EjY9F0xp0YpfYgf KLqptc9+XRrWkGphk9 ed25519-key-20210426" >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
Now it's time to restart our ssh daemon:
sudo service ssh restart
Furthermore, we need to determine the ip of the vm. Running
ip addr show eth0 | grep "inet "
Gives you the ip (and subnet) of the machine. Mine is 172.31.140.5.
From here, we switch to using winscp: https://winscp.net/eng/download.php
Create a new site, host name is the ip you found in the previous part. Port number remains 22, user name is the user you created earlier (cod2user for this tutorial). Password remains empty.
Click advanced, ssh, authentication and brows to your private key file you saved earlier using the "..." behind the "private key file" box.
Click Ok, save, and connect. On first connect it will warn you about the change in the server's key file, which is fine.
Now that we are connected through winscp (and by extension have acces to ssh), we can close the VM window.
Setting up the machine
Now, install some prerequisites:
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install libstdc++5:i386 libmysqlclient-dev:i386 screen g++-multilib git
Now, lets clone ourselves a git repo of libcod and compile it:
git clone https://github.com/voron00/libcod
cd libcod
./doit.sh cod2_1_3
cd
With that out of the way, lets create a folder for our cod2 install to reside:
mkdir -p cod2/main
Now we switch back to winscp (refresh) and go to cod2/main. Upload all stock iwd files from your local cod2 install to there. This should go rather quick as it's local network.
Download the cod2_lnxded binary of choice from here: https://killtube.org/showthread.php?1719-Latest-cod2-linux-binaries-%281-0-1-2-1-3%29 My personal choice is the cod2_lnxded_1_3_nodelay_va_loc. After downloading and extracting, rename it to cod2_lnxded_1_3 and upload it to the cod2 folder (next to the main folder).
Now we need to create the bash script that actually starts the server. Create a file in your home directory named run.sh and copy paste the content below into it:
#!/bin/bash
sv_maxclients="32"
fs_game=""
fs_homepath="/home/$USER/cod2"
cod="/home/$USER/cod2/cod2_lnxded_1_3"
com_hunkMegs="256"
config="configfile.cfg"
cracked="1"
net_port="28960"
args=\
"+set fs_homepath \"$fs_homepath\" "\
"+set sv_cracked $cracked "\
"+set fs_game $fs_game "\
"+set net_port $net_port "\
"+set com_hunkMegs $com_hunkMegs "\
"+set sv_maxclients $sv_maxclients "\
"+set fs_basepath \"$fs_homepath\" "\
"+exec $config"
LD_PRELOAD="/home/$USER/libcod/bin/libcod2_1_3.so" $cod $args +set g_gametype tdm +map mp_toujane
Now, lets grant execute permissions to both the binary and the bash files:
chmod 700 run.sh
chmod 700 cod2/cod2_lnxded_1_3
And run the actual server:
./run.sh
You can now start your cod2 client and connect to your server using /connect [ip]. In case of this tutorial, that's /connect 172.31.140.5
And that's all there's to it.