Running a Wine-based Dedicated Server
From GMod Wiki
Wine
+ Linux / FreeBSD / NetBSD / OpenBSD / DragonFlyBSD / Nexenta / Solaris / OpenSolaris / MINIX3 / Mac OS X
It is very easy to create a garrysmod server on any one of a number of UNIX like operating systems of your choice using wine.
This configuration document was written for FreeBSD 7.0 although the same should apply for any UNIX-like system that can run wine.
- Server requirements:
* X (make sure you also have "Xvfb" installed if you wish to disconnect from the server and let it run without X running) * sshd * wine * x86 compatible processor with SSE
- Download the installer for srcds and copy it to your server. If wget is installed on your server, you can use:
$ wget "http://www.steampowered.com/download/hldsupdatetool.exe"
- Run it using the command:
$ wine hldsupdatetool.exe
- When running the above installer, it will need an X server to output the installation dialog box to. The easiest solition is: if you are accessing the server via ssh from another UNIX or Linux machine, use the "-Y" option to ssh (e.g: ssh -Y [email protected]). You may then run the above command and the window will be tunnelled over the ssh connection and opened on the desktop of your computer instead.
- When the installer has finished, assuming you chose to install into "C:\srcds", your srcds directory will be available at "/home/user/.wine/drive_c/srcds"
- You can now change into this directory and run:
$ wine hldsupdatetool -command update -game garrysmod -dir .
- This will download the garrysmod content.
- To start the server, change into "/home/user/.wine/dosdevices/c:/srcds/orangebox" and run:
$ WINEDEBUG=-all wine srcds.exe -console -game garrysmod +map gm_flatgrass +maxplayers 10 etc
- This command will open a window on your desktop machine and the server will start up.
- If you have a command line only server, or you want to disconnect from the server and allow it to continue on its own without displaying the srcds console, you will need to run the following commands on the server before you run srcds.exe:
$ Xvfb :1& $ export DISPLAY=:1 $ cd /home/user/.wine/drive_c/srcds/orangebox $ WINEDEBUG=-all wine srcds.exe -console -game garrysmod +map gm_flatgrass +maxplayers 12 +ip 192.168.1.66 +sv_lan 0 +hostname "My UNIX server" +sv_defaultgamemode "LightRP" -autoupdate &
- Xvfb is an X server which accepts connections from applications (such as wine GUI apps) and draws them into RAM rather than Video Memory. The result is that you do not see the output and you do not have to waste resources displaying the srcds console. - This saves us having to run the real X server when all you really need is something to stop the command from complaining that there is no X server to connect to.
- How do you view the console? You don't, at least not until someone writes a lua addon that allows ssh-ing in on a different port to directly access console output (anyone want to take this on?)
- I have bash scripts in my home directory which when executed, run the above commands. Remember to put "#!/bin/bash" as the first line of the text file and to make it executable using chmod +x <filename>.
Here is an example of what the script may look like:
#!/bin/bash export DISPLAY=:1 cd /home/user/.wine/drive_c/srcds/orangebox && WINEDEBUG=-all wine srcds.exe -console -game garrysmod +map gm_flatgrass +maxplayers 12 +ip 192.168.1.66 +sv_lan 0 +hostname "My UNIX server" +sv_defaultgamemode "LightRP" -autoupdate &
- Make sure that you have run
Xvfb :1&
once before running the script. It would be useful to put this into one of your server's startup scripts to avoid having to run it each time you start the server.
- Finally, make sure that you put an "&" character after your "wine srcds.exe ... ... ..." command to send it into the background. You can then press Ctrl-D to disconnect the ssh session and leave the server running.
- WINEDEBUG -all switches off wine's error output, speeding up wine significantly.
- To shut down the server, either use
rcon quit
from within the game, or on your UNIX system, type:
ps ax
Find the process id <pid> of srcds.exe, and kill it using
kill -15 <pid>
Good luck!
Buglist
Even though the wine server works a bug has been found which causes significant problems with some maps. More details on http://forums.facepunchstudios.com/showthread.php?t=616699 Currently there is no fix for this.
--Capsup: I have found a fix for this on my own server, just download this pack: http://lker.dk/scripts.rar --- Facepunch thread: http://www.facepunch.com/showpost.php?p=16458710&postcount=1
--Chinoto: The pack is no longer at garrysmod.org
--Capsup: It's now at my own server, download it from there. :)
When the server crashes it might display an error dialog. This prevents a simple autorestarter script from working propely. ServerChecker is a good tool to get around this.