MacOSX Dedicated Server Setup

From GMod Wiki

Jump to: navigation, search

So you want to setup a GMod server on OS X? Okay good. UNIX "bash" is different than the Windows Command Prompt so I'll point out how to do this UNIX style. We're going to be using bash a lot here, so the first thing you need to do is go into your Applications -> Utilities folder, then open Terminal. You're now in bash! Writing this, I assume you have an Administrator account on the Mac you're going to be putting the server on. The command sudo will be used here. sudo will require your password every so often. Just type it in and hit return. Note: you will not see any text as you enter your password. (Note: This tutorial will only work with an Intel Mac. Power Macs will have to use qemu.)


Getting Wine.

First, download and install macports if you don't have it already. MacPorts is a great way to get common UNIX software.

Next we need to get wine. In the terminal type in: sudo port install wine This will take a few minutes but let it run.

After Wine is installed, restart the Terminal.

The first time you use Wine, it will take a few minutes to initialize. If it appears that nothing is happening, this is not the case. Have patience.

Getting started with HLDSUpdatetool.

First, you will need the downloader program. Download it here. Make sure it's saved to your Downloads folder (default in Safari).

In a new Terminal session, type in wine ~/Downloads/hldsupdatetool.exe and press return. This is assuming the file is in your Downloads folder of course. The tilde (~) is just a shortcut for your home directory.

Once the application launches, navigate the app until you are asked to "choose the destination location". Put it in "C:\srcds". Note: OS X is case-sensitive! Use the same cases I use in directory path names.

Navigate the rest of the app and click finish. "hldsupdatetool.exe" can be deleted from your Downloads now.

Downloading the files.

Enter cd ~/.wine/drive_c/srcds into the Terminal and press return. This will put you into the directory where your server will be!

Since we're so hardcore, we're going to write something called a "shell script". This is similar to a "batch file" in Windows, except shell scripts are actually useful!

Enter nano into the Terminal and press return. This will start up the GNU Nano text editor. When you're done editing, do control+o, press return to save, and then do control+x to exit.
Copy and paste the following:

cd ~/.wine/drive_c/srcds
echo This will take a long time, I would recommend you go do something else.
echo Updating/installing CS:S
wine hldsupdatetool -command update -game "Counter-Strike Source" -dir C:\\srcds
echo Updating/installing dods
wine hldsupdatetool -command update -game "dods" -dir C:\\srcds
echo Updating/installing hl2mp
wine hldsupdatetool -command update -game "hl2mp" -dir C:\\srcds
echo Updating/installing tf
wine hldsupdatetool -command update -game "tf" -dir C:\\srcds
echo Updating/installing Garrysmod
wine hldsupdatetool -command update -game garrysmod -verify_all -retry -dir C:\\srcds
echo Update/installation Complete
echo Installed to C:\\srcds\\
echo Your server is now ready to use!
echo To add extra addons or maps etc. place them in C:\\srcds\\orangebox\\garrysmod\\
echo This installer can also update necessary server files, so it is recommended that you run it often.

Once you exit Nano, type chmod a+x into the Terminal and press return. This will make the script runnable. Type ./ into the Terminal and press return. The download will commence and will take a while to finish. This command should be run every so often, to ensure you have the latest assets.

Port forwarding.

Assuming IPv4 is still alive, you have to tell your router to forward requests to GMod ports to your server.

You will need the server's local IPv4 address. To get this, go into Applications -> System Preferences and click on Network. You will see your IPv4 address somewhere on the screen. It may look like "".

Note: The following will assume you have an Apple AirPort as your router.

Go into Applications -> Utilities and run the AirPort Utility. Select your router, go into Advanced, then Port Mapping. Click the "+" to add a configuration. Leave "Service" as it is.

Public UDP Port(s): 27015 27020
Public TCP Port(s): 27015
Private UDP Port(s): 27015 27020
Private TCP Port(s): 27015

Click continue and make the description something like "GMod server!". Press done and exit the AirPort Utility.

Starting srcds.

Make another shell script in ~/.wine/drive_c/srcds/ called We'll use nano again.


cd ~/.wine/drive_c/srcds/orangebox

while [ true ]; do

echo Starting game server.
echo Beginning GMod
wine srcds.exe -console -game garrysmod -port 27015 +map gm_construct +maxplayers 16
echo GMod has now started.


Do chmod a+x To start the server, do ./ and you're all set! Notice how there is a while statement. This will cause the server to restart automatically if it crashes. Cool!

If you want to run the script in the background, do nohup ./ & in the Terminal. Note: the X Window will still be open!

In conclusion

This article is not for the faint of heart. One step done incorrectly could ruin the entire installation.

For those of you who think you're gurus, do NOT attempt to start the server from a remote shell, as it will attempt to launch an X client. This will probably break the server and you will have to restart OS X.

Personal tools
Lua Scripting