Call of Duty 1 server on Linux

In this guide, I will explain how to create a Call of Duty 1 server with CoDaM.
This guide assumes that you already have a basic understanding of the Linux shell, good general understanding and the following:

You can find the necessary files needed to setup a server on this resource: https://de.dvotx.org/dump/cod1.
The # symbol will be used to illustrate a root shell command.

PREREQUISITES

First ensure you have the appropriate Linux libraries installed.

On Ubuntu/Debian and variants:
# apt-get install lib32z1 libc6-i386
On Arch Linux and variants:
# pacman -S lib32-glibc lib32-zlib

STEP 1

We will setup the Call of Duty server under the following path: /data/myserver. If you don't have a /data folder, don't worry, we will create the path shortly.

Create a folder structure resulting in a path like /data/myserver/main.
# mkdir -p /data/myserver/main
We will continue by creating an appropriate user for the Call of Duty server called codserver.
On Ubuntu/Debian variants you may need to change /usr/bin/nologin to /usr/sbin/nologin in the following command.
Use whereis nologin command to see the path to nologin.
# useradd -r -s /usr/bin/nologin codserver

STEP 2

We will now copy the necessary server files over to our Call of Duty server directory.
You can find the nescessary basefiles here and the Linux binaries here.

Copy the following files to /data/myserver: Copy the following files to /data/myserver/main. For server versions other than Call of Duty 1.1, you will need to add different and additional .pk3 files and different Linux binaries.

STEP 3

We will now create the main config file inside the main/ folder. We'll call this file myserver.cfg.

Copy and paste in the following to the myserver.cfg file and edit the required CVARs to your needs:
// Add server to xFire
set gamename "Call of Duty"

// Server settings
set developer "0"
set sv_maxclients "16"

// Server information
set sv_hostname "<SERVER NAME>"
set scr_motd "<WELCOME MESSAGE>"
sets ^1Owner "<OWNER NAME>"
sets ^1Distro "Linux"
sets ^1Location "^2Germany (1000/1000mbit)"

// Server options
set sv_pure "0"
set rconpassword "<RCON PW HERE>"
set g_password "<JOIN PW HERE>"
set sv_privatepassword ""
set sv_privateclients "0"
set sv_allowdownload "0"
set sv_cheats "0"
set g_log ""
set g_logsync "0"
set sv_kickbantime "300"
set sv_fps "20"
set sv_allowanonymous "0"
set sv_floodprotect "1"
set g_inactivity "0"

// Network options
set sv_maxrate "0"
set sv_maxping "0"
set sv_minping "0"

// Alternative masterservers
set sv_master2 "master.cod.pm"
set sv_master3 "codmaster.comu-mvzg.com"

// Game options
set g_gametype "sd"
set g_allowvote "0"
set scr_allow_vote "0"
set scr_drawfriend "0"
set scr_forcerespawn "0"
set scr_friendlyfire "0"
set scr_freelook "1"
set scr_spectateenemy "0"
set scr_teambalance "0"

// Deathmatch
set scr_dm_scorelimit "50"
set scr_dm_timelimit "30"

// Team Deathmatch
set scr_tdm_scorelimit "100"
set scr_tdm_timelimit "30"

// Behind Enemy Lines
set scr_bel_scorelimit "50"
set scr_bel_timelimit "30"
set scr_bel_alivepointtime "10"

// Retrieval
set scr_re_scorelimit "10"
set scr_re_timelimit "0"
set scr_re_graceperiod "15"
set scr_re_roundlength "2.50"
set scr_re_roundlimit "0"
set scr_re_showcarrier "0"

// Search and Destroy
set scr_sd_scorelimit "10"
set scr_sd_timelimit "0"
set scr_sd_graceperiod "20"
set scr_sd_roundlength "2.50"
set scr_sd_roundlimit "0"

// Weapons
set scr_allow_mp40 "0"
set scr_allow_ppsh "0"
set scr_allow_sten "0"
set scr_allow_thompson "0"
set scr_allow_bar "0"
set scr_allow_bren "0"
set scr_allow_mp44 "0"
set scr_allow_m1carbine "0"
set scr_allow_m1garand "0"
set scr_allow_panzerfaust "0"
set scr_allow_mg42 "0"

// Execute CoDaM Configuration
exec CoDaM.cfg
exec CoDaM_HamGoodies.cfg
exec CoDaM_MiscMod.cfg

STEP 4

(This step is optional for those who wish to install CoDaM.)

Now, we are going to install CoDaM. Download the following CoDaM core files: Extract the following files and folders to your main/ folder.

From CoDaM_V1.31.zip: From CoDaM_HamGoodies_V1.35.zip: Now edit the following in modlist.gsc located inside the /data/myserver/codam folder.
UNDER:
// Example from Hammer's Goodies -- REMOVE the // to activate

ADD:
[[ register ]]( "Hammer's Goodies", codam\HamGoodies::main );
Now edit the configuration (.cfg) files to suit your needs, and you will have CoDaM installed on your server.
This guide does not explain how to configure the configuration files of CoDaM as they are already well documented inside the configuration files.

STEP 5

Now that the server is created and configured lets create the start script.
Enter the /data/myserver directory and create a file called startmyserver.sh then copy and paste in the following code section into the file:
#!/bin/sh
exec setpriv --reuid=codserver --regid=codserver --clear-groups sh -- <<- 'COD'
	HOME=/data/myserver
	exec env - LD_PRELOAD=$HOME/codextended.so $HOME/cod_lnxded +set fs_homepath $HOME +set fs_basepath $HOME +set net_ip <ipaddr> +set net_port 28960 +exec myserver.cfg +map mp_harbor < /dev/tty
COD
NOTE: You can't use a path with spaces using LD_PRELOAD. The above script does not support a path with spaces.
Edit the startmyserver.sh file to suit your configuration, notably the +set net_ip and +set net_port parts.

Ensure that the server has the appropriate permissions set for the codserver user we created earlier, by running the following commands:
# chown -R codserver:codserver /data/myserver
# find /data/myserver -type d -exec chmod 0770 {} \;
# find /data/myserver -type f -exec chmod 0660 {} \;
# chmod u+x /data/myserver/cod_lnxded /data/myserver/startmyserver.sh
You can now start the server with the following command:
# /data/myserver/startmyserver.sh
Press CTRL + C to stop the server or type quit in the server console.

You can if you prefer use the following command to run server in the background instead:
# nohup /data/myserver/startmyserver.sh >/dev/null 2>&1 &
To bring the server back to the foreground you can use the fg command.

The server will run on the host machine as the user codserver.
Please discuss/suggest a better way to run the Call of Duty server without involving the root user.

STEP 6

(This step is optional for those who wish to install codextended.so.)

If you would like to enhance the server by using codextended.so (repo|releases), all you have to do is add this file into the myserver/ folder.
The above mentioned start script already attempt to load codextended.so into cod_lnxded.

Ensure that the codextended.so file has the appropriate permission for the codserver user.
# chown codserver:codserver /data/myserver/codextended.so
# chmod 660 /data/myserver/codextended.so
You can add the following codextended.so CVARs into myserver.cfg (taken from THiNK forum):
set x_deadchat 0		// Make death-chat visible to alive players? 1= yes 0= no
set x_nameflood 0		// Allow Spamming Names? 1= Yes 0= No
set x_nopbots 1			// New bot movements (only takes effect if "scr_numbots" is enabled)
set x_spectator_noclip 0	// Allow spectator to fly through walls (noclip)? 1= Yes 0= No
set x_authorize 0		// 0= cracked server, 1 = non cracked server (cd key required)
set x_contents -1		// important - for collision of players - default = -1

TROUBLESHOOTING

Error 1

Sys_Error: Couldn't load default_mp.cfg.  Make sure Call of Duty is run from the correct folder.
Make sure you use the localized_english_pak0.pk3 and localized_english_pak1.pk3 files.

Error 2

-bash: /data/myserver/startmyserver.sh: /bin/sh^M: bad interpreter: No such file or directory
The file has DOS/Windows style line endings (CR LF), but on Unix-like systems only the LF control character is used as line break.
You can fix this by installing and running the dos2unix command on the file.
dos2unix /data/myserver/startmyserver.sh

A guide by Cato

Original URL: https://de.dvotx.org/dump/cod1/server_guide.linux.html
Author(s): Cato
Created on: 2021-08-26 15:46:11
Last update: 2023-05-01 19:36:10

Revision(s):
2023-02-19 22:39:00 by Cato & Cheese: Updated startmyserver.sh and moved CVARs to myserver.cfg