cPGS Installation Guide
Basic Requirements for cpgsd
- Perl 5+
- OpenSSL (including headers, usually in a separate package called something like openssl-devel or ssl-dev)
- Net::SSLeay perl module
- IO::Socket::SSL perl module
- IPC::Run perl module
On versions 0.4.0 and later, cPGS uses a server-client mechanism. This allows cPGS to control gameservers running on remote machines (without cpanel installed) to elliminate the overhead of running cPanel on the same physical servers running the gameservers. In this case, each game by each user has a unique configuration for the remote server. However, you are still able to run the cpgsd daemon on the local machine alongside cPanel by using the loopback IP 127.0.0.1
for all user's connections.
1) cPGS should be installed in WHM, as the root user (not reseller), in the "Manage Plugins" section.
2) Remote servers (without cPanel installed) can be installed in WHM once cPGS has been installed. There is a link in the Game Server Management page to "Install Remote Server" which gives you several different means by which to install the server remotely. If this isn't working for yoiu for some reason, put in a support ticket and we can help troubleshoot it.
3) After the installation on the cPanel or remote server(s), configure the /var/cpanel/cpgsd.cfg file. This applies to both remote and local installations.
- allowedips: comma delimited list of IP addresses that are allowed to talk to the daemon server (default: 127.0.0.1)
- logfile: path to the log for cPGSD (default: /var/log/cpgsd.log)
- sslpem: the SSL PEM file to use. This can be generated by the cpgsd_install script (default: /var/cpanel/cpgs.pem)
- pkgdir: location of the gameserver package files (default: /home/gameservers/)
- secret: the shared secret key/pass you will use between servers. Be sure this value is the same on any servers involved in cPGS
- qstat: path to the qstat binary for getting stats on some games (default: /usr/local/bin/qstat)
- root: the base directory for cpgsd files (default: /var/cpanel/)
- port: port that cpgsd listens on. do not change if at all possible. (default: 2092)
4) Start up the cpgsd.pl daemon on any gameserver boxes.
- The start up script: /var/cpanel/cpgsd.pl
- This will log data to /var/log/cpgsd.log by default.
- You can change the log file by editing /var/cpanel/cpgsd.cfg and setting the logfile= variable.
5) Log into WHM on the cPanel machine and begin configuring users you will allow to run gameservers.
- The "core config" option is where you will enter the IP address of the remote gameserver box for that user and the particular gameserver you select. A user can have an UT2004 server running on 220.127.116.11, while having a HLDS server runningon 18.104.22.168, for example.
- IPs the user's server will bind to on the gameserver machine and ports for each user/game should be self explanitory.
- Note that from 0.6.0+, it is possible to run multiple types of the same type of game under one account. For example, a user can run a CS:S server on 22.214.171.124:27015 , another CS:S server on 126.96.36.199:27025, a CS 1.6 server on 188.8.131.52:27018 and an ArmyOps server on 184.108.40.206:7617 .
6) Log into the user's cPanel account and configure the gameserver, start it up and, assuming all is well, play
- If you do not have the perl module IO::Socket::SSL , you will need to install it on all servers involved ( perl -MCPAN -e'install IO::Socket::SSL' ).
- If you do not have `wget` installed on the remote cpgsd.pl servers, you will need to in order to download and install gameserver packages from WHM.
A link to the gameserver control panel can be found at the bottom left of the WHM menu. From here, you can control the number of players and what types of games are allowed.
Clients can only admin servers they have been granted access to from the GameServers link in the x
, and gs
themes. The gs
theme only provides cP GS support on gameserver accounts. You cannot run a webpage from the gs
To access a cPanel account, enter the following address replacing example.com with your domain name:
This is a very basic feature that allows "UserA" on the cPanel server to control gameservers on remote servers from any account. For example, "drdoom" on the cPanel server could control CS:S on 220.127.116.11 as the user "malcom", Call of Duty on 18.104.22.168 as "mickey", and Savage on 22.214.171.124 as "janky". Remote usernames can be configured in WHM with inside of each user's game.
Creating a Custom Game Package
In this example we have a working server in /home/user/cod14/
. You will need to use the following commands to package it, inject the meta data, and move it to the right place:
- Change into the same directory as the server.
- Create a gzipped tarball of the contents from the current directory to somewhere outside the current directory:
- tar czvf ../cod14.cpgs ./
- Change to the same directory as the new package file.
- Inject the metadata into the newly created file so cPGS can handle it. The arguments: -p means we are going to pack a new file, "cod" is the internal name for CoD servers (cod2 for CoD2,cod4 for CoD4, etc), 1.4 is the version, and the last bit is a shortdescription of the package.
- /var/cpanel/cpgs/cpgs_pkg cod14.cpgs -p "cod" "1.4" "Custom package"
- This will take some time as the cpgs_pkg script searches through the file and appends the meta data. After the process is complete, move the package to the directory with the rest of your packages:
- mv cod14.cpgs /home/gameservers/
After this is finished, you should be able to select the cod14.cpgs in WHM for use when installing.
Automatic Restart on Reboot
When a client starts any of the gameservers, the server name is added into /var/cpanel/gameserv.restart. The command line executes the following:
The actual restart script, /usr/local/cpanel/bin/cpgs_chk
, reads the .restart file for all the users who own gameservers. If the restart script can find the command line it needs to restart the gameserver, it will drop privileges to the user and attempt to start the server. The script does not currently check to see if the server is running. We advise you not to run it unless the server has just been rebooted.
Currently this script is not added to the init system since it has not been thoroughly tested. We suggested you add it to the rc.local, local.start, etc file (depends on the distro) to have it run after the server reboots if manually running it is not feasible.
Unique Command Lines Per User/Game
If the admin has declared a custom command line (looks for existence of /var/cpanel/gameserv_saved/$user_$game_$installnum_useuniq
), client's starting their game server will be forced to use the custom command line. This is useful, allowing special mods that are not yet supported by cPGS directly and should only be used by those who understand what they are doing.
The Post Install Script
exists, it will be called upon finishing the installation of a game with the following arguments:
- /var/cpanel/cpgs_postinstall $user $query $srvn $maxc $defip $lowport
- $user is the system username of the game being installed for
- $query is the game server "shorthand" name
- $srvn is the server number
- Note : These 3 variables together are what is seen in /var/cpanel/gameserv.cfg and other configs in the form of user_game_#
- $maxc is the max clients/players allowed for the server
- $defip is the first IP address allowed for the server
- $lowport is the first port allowed for the server
The cpgs_postinstall script can be written in your language of choice. Be sure to do error checking, the first 3 arguments are the only consistantly reliable ones at this time.
Brief Description of Core cPGS Config Files
This file is automatically created by cpgsd when a game is started. It records the last startup line for the restart script called from cron, so it can restart the server in the same state as before it crashed was rebooted.
This is similar to the user_gametype_servernum file, in that it holds a full custom command line to be used in starting and stopping the server. However, it supercedes any config options normally passed on the command line. It is most useful when you need ultimate control over the command line. This is (normally) set in WHM in the "Manage Game" option of the advanced config section, and must be specifically enabled to be used by cpgsd. Whether or not it is used is determined by the existence of an empty file, /var/cpanel/gameserv_saved/user_gametype_servernum_useuniq
This file holds config information about which IPs the users are allowed to choose from when configuring their server from cPanel.
The same as the IPs file, but for ports. Some servers need as many as 3 unique ports, so be sure to allow enough.
This holds the config info for each user_game_num in where the frontend should connect to the backend. For accounts where the games are actually run on the same server cPanel is installed on, use 127.0.0.1 . For remote servers, use any reachable IP on it that cPGSD is bound to.
This just holds a list of user_game_num instances that are supposed to be restarted, across reboots and after crashes.
This file holds a list of all the users_games_servernums configured for cPGS and various info about them, such as remote user name, max clients/slots, the server package file to use, whether the gameserver is allowed to be mangaged by the user or not, a list of allowed mods for the server and command line append options, etc.
For all questions, suggestions, and bug reports, please email firstname.lastname@example.org