Results 1 to 4 of 4

Thread: How to run my Call of Duty 2 server using Libcod?

  1. #1
    Private
    Join Date
    Mar 2019
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 3 Posts

    How to run my Call of Duty 2 server using Libcod?

    Hello everyone,

    Well, can someone explain to me how to run my server with libcod? I've tried this already

    Code:
    LD_PRELOAD=libcod2_1_3_nomysql.so ./cod2_lnxded...
    But it doesn't work, my directory is cd /root/mysrv ... if changes are needed, please tell me how!

    Thanks.

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    1,959
    Thanks
    1,882
    Thanked 1,058 Times in 735 Posts
    On some systems you need to specify LD_LIBRARY_PATH, like:

    LD_LIBRARY_PATH=. LD_PRELOAD=libcod2_1_3_nomysql.so ./cod2_lnxded ...

    If that doesn't help, follow the proper tutorial: https://killtube.org/showthread.php?...u-14-04-server

    If you are using one of those years-old precompiled .so's, compile it yourself
    timescale 0.01

  3. #3
    Private
    Join Date
    Mar 2019
    Posts
    16
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Oh okay, thank you ))

  4. #4
    ... connecting
    Join Date
    Jul 2019
    Posts
    4
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I'm here, but was a fairly active modder at IWNation back in the days. Just started to play and mod COD2 again last week. This site is great to get started again, since I wasn't using libcod in the past. So I'm happy to share some knowledge back.

    Which Linux distro are you using? If you're using Ubuntu 18.04 64-bit (or newer) I'm glad to help you out. There are thousand ways to do this, but if you don't have any Linux experience you'll have to follow the instructions by the letter. Otherwise, you will end up with permission issues.

    1) First install Call of Duty 2 on a Windows system, and patch it to the latest version 1.3.

    2) Gain terminal / SSH access to your Ubuntu server. You can use PuTTY for SSH - or even PowerShell for SSH access on newer Windows 10 machines. Connect to your server and log in with your user (normally this shouldn't be the root user).

    Now gain root rights using the 'sudo su' command. Note the prefix '$' and '#' ($ = user privileges, # = root privileges).

    Code:
    $ sudo su
    3) With root privileges, you can now create the directory to store the game files. I'll prefer a directory in '/opt' for Debian (Ubuntu) based distros.

    Code:
    # mkdir /opt/cod2
    4) Set the owner and group of the '/opt/cod2' folder. If we don't do this, you can't manage this folder with your default non-root user. Also set the group to www-data, so we can set up a HTTP server. The HTTP server will be used by clients to download any mods running on your server. Last, set a group sticky bit so the group will be inherited when new files are placed this directory.

    Code:
    # chown yourusername:www-data -R /opt/cod2
    # chmod g+s /opt/cod2
    4) Add your user to the 'www-data' group.

    Code:
    # usermod -a -G www-data yourusername
    5) Now the directory is made, and all permission are set correctly, we can copy over the game files. You can use WinSCP or any other compatible program to transfer files via SSH to your server. Run WinSCP, connect to your server using your username and password and navigate to the newly created '/opt/cod2' folder. Now copy the contents of Call of Duty game folder (default 'C:\Program Files (x86)\Activision\Call of Duty 2') to '/opt/cod2' on your server.

    6) Verify the copied files and ownership. It should look like this. Note that every file and folder is owned by your user name and the 'www-data' group.

    Code:
    # ls -l
    Code:
    -rw-rw-r-- 1 yourusername www-data 1974272 May  1  2006 CoD2MP_s.exe
    -rw-rw-r-- 1 yourusername www-data      67 Jun 23 17:06 cod2patch.ini
    -rw-rw-r-- 1 yourusername www-data 3150807 Mar 30  2006 CoD2SP_s.exe
    -rw-rw-r-- 1 yourusername www-data  921656 Sep  2  2005 cod.bmp
    -rw-rw-r-- 1 yourusername www-data  109976 Sep  7  2005 codlogo.bmp
    drwxrwsr-x 3 yourusername www-data    4096 Jun 23 17:17 Docs
    -rw-rw-r-- 1 yourusername www-data 1855488 May  1  2006 gfx_d3d_mp_x86_s.dll
    -rw-rw-r-- 1 yourusername www-data 1851392 May  1  2006 gfx_d3d_x86_s.dll
    -rw-rw-r-- 1 yourusername www-data    2271 Oct  2  2005 localization.txt
    drwxrwsr-x 2 yourusername www-data    4096 Jun 23 22:12 main
    drwxrwsr-x 2 yourusername www-data    4096 Jun 23 17:17 miles
    -rw-rw-r-- 1 yourusername www-data  370688 Aug 11  2005 mss32.dll
    drwxrwsr-x 4 yourusername www-data    4096 Jun 23 17:17 pb
    -rw-rw-r-- 1 yourusername www-data     141 Jun  5  2006 version.inf
    7) Download a copy of the Call of Duty 2 Linux Server binaries and place it in the '/opt/cod2' folder. Rename it to 'cod2_lnxded' and make sure again the ownership of the files are correct. This should be automatically correct if you download the binaries on your Windows machine and upload it directly to the '/opt/cod2' folder using WinSCP.

    8). Give the Linux binaries execution permissions.

    Code:
    # chmod +x /opt2/cod/cod2_lnxded
    9) Download Voron00's libcod on your windows machine. Use the latest release on his Github. Press the green 'Clone or download' button on the Github page and download a ZIP file. Extract the ZIP file on your Windows machine and rename the extracted folder from 'libcod-master' to 'libcod'. Upload the folder to your server and place it in '/opt/cod2' using WinSCP (that is the whole folder, not the contents inside it).

    10) Install additional required packages on your Ubuntu server in order to build libcod and run the Call of Duty 2 server. Enter each line manually, don't copy over the whole bunch of commands and paste it.

    Code:
    # dpkg --add-architecture i386
    # apt-get update
    # apt-get install libstdc++6:i386 
    # apt-get install gcc-multilib
    # apt-get install g++-multilib
    Additionally, install a MySQL client if you want SQL support in libcod. Of course, you also will need to setup a MySQL server if you do that (not explained here).

    Code:
    # apt-get install libmysqlclient-dev:i386
    11) Build libcod for Call of Duty 2 version 1.3

    Code:
    # cd /opt/cod2/libcod
    # ./doit.sh cod2_1_3
    If everything goes right, you can find the compiled binary 'libcod2_1_3.so' in the folder '/opt/cod2/libcod/bin'.

    12) Now setup some start up scripts so we can automatically start the server on boot and control it as a service.

    Code:
    # vi /lib/systemd/system/cod2-server.service
    Press 'i' to allow editing in vim. Then paste the following code into vim (right click when you use PuTTY).

    Code:
    [Unit]
    Description=cod2-server
    After=network.target
    Wants=network-online.target
    
    [Service]
    Environment="LD_PRELOAD=/opt/cod2/libcod/bin/libcod2_1_3.so"
    ExecStart=/opt/cod2/cod2_lnxded <additional parameters>
    Restart=always
    KillMode=process
    Type=idle
    
    [Install]
    WantedBy=multi-user.target
    Don't forget to modify the additional parameters. This is basic stuff for running a dedicated Call of Duty 2 server. For example:

    Code:
    ExecStart=/opt/cod2/cod2_lnxded "1" +set fs_homepath "/opt/cod2" +set fs_game "henkspermatank" +set fs_basepath "/opt/cod2" +set com_hunkmegs "512" +exec "server.cfg"
    Save and exit by pressing ESC and typing ':wq'.

    13) Enable the service to startup on boot.

    Code:
    # systemctl daemon-reload
    # systemctl enable cod2-server
    14) The service will start automatically on (re-)boot. But you can control the service manually.

    Code:
    # systemctl start cod2-server
    # systemctl stop cod2-server
    # systemctl status cod2-server
    Extra) Set up the HTTP server for your clients for faster mod downloads. I use lighttpd because my server is only running Call of Duty 2 and don't expect the HTTP server to do more than serving downloads to game clients. So the lightweight http server would be perfect in this case. I would not recommend this step if you don't have any knowledge about is. Basically, I create a symlink from the public http directory to my fs_game folder. Then I use the lighttpd config to exclude serving cfg files (only allowing iwd files), and set up my server config to use HTTP downloads.

    Code:
    set sv_allowdownload "1"
    set sv_wwwdownload "1"
    set sv_wwwbaseurl "urloriptoyourserver"
    set sv_wwwdldisconnected "0"
    Extra) You can use journalctl to see the server logs. First command show the full log, the second command prints the last 100 lines of the log.

    Code:
    # journalctl -u cod2-server
    # journalctl -u cod2-server -n 100 --no-pager
    Extra) Run the server directly instead of a service to see and enter commands in the Call of Duty 2 console. Just like on Windows. Handy for debugging purposes. The export command only needs to be entered once a session (and can give you warnings if you user other commands during this session).

    Close down the service first.

    Code:
    # systemctl stop cod2-server
    Run the Call of Duty 2 server directly.

    Code:
    # export LD_PRELOAD=/opt/cod2/libcod2/bin/libcod2_1_3.so
    # /opt/cod2/cod2_lnxded <additional parameters>
    Extra) Enable firewall. Adjust accordingly if you already have UFW running. These are instructions for a fresh, unconfigured firewall! It will reset your existing configuration! Enter each line manually, don't copy over the whole bunch of commands and paste it.

    Code:
    # ufw disable
    # ufw reset
    
    # ufw default deny incoming
    # ufw default allow outgoing
    
    # ufw allow 22/tcp
    # ufw allow 80/tcp
    
    # ufw allow 28960/tcp
    # ufw allow 28960/udp
    # ufw allow 20500/udp
    # ufw allow 20510/udp
    
    # ufw enable
    Ports 22 and 80 are for SSH and HTTP respectively. You can drop the port 80 rule if you don't run a HTTP server to serve mods to your clients via HTTP.

    It's best practice to avoid SSH (22) being exposed to the whole world. Mines behind a VPN, and the router forwards only COD2 related ports to the server. If you're running a virtual server without external firewall, better restrict SSH access to a set of whitelisted IP addresses in UFW. Always make sure you have a backup (like kvm console), or multiple IP addresses to manage the server. If you can't restrict SSH access (e.g. no static own IP on your home internet line), use a program like Fail2Ban to secure SSH access.

    If you have any questions, feel free to ask. I posted this manual because I found the previous posted manual a little bit outdated. There are also no mentions of permissions there, as anything is ran in the home directory instead of the correct locations. Also, the system service script is based on the old init.d instead of the newer systemd system.
    Last edited by snoopdoge90; 1st July 2019 at 18:39.

  5. The Following User Says Thank You to snoopdoge90 For This Useful Post:

    kung foo man (3rd July 2019)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •