| 1 | == Introduction == |
| 2 | This wiki page will explain how to create a server on a dedicated machine with only a SSH access. It is highly inspired from this [http://forum.smokin-guns.org/viewtopic.php?f=27&t=3207#p24715 post]. |
| 3 | The server for this tutorial will be a Linux machine and we will only use a SSH access to the machine. |
| 4 | |
| 5 | = Content = |
| 6 | * Creating a new user |
| 7 | * Installing the game |
| 8 | * Starting the server |
| 9 | * with screen |
| 10 | * with an init.d daemon (if you have root) |
| 11 | |
| 12 | = Creating a new user = |
| 13 | It is always better to run things in a separated account, so we will create one. |
| 14 | {{{ |
| 15 | adduser <user> |
| 16 | }}} |
| 17 | and then log back with SSH as {{{user}}} or just do a {{{su user}}} and {{{cd /home/user/}}} |
| 18 | |
| 19 | == Installing the game == |
| 20 | So we will use wget for that, if you don't have it, {{{apt-get install wget}}} as root will install it on most deb-based distributions. |
| 21 | Then, download the game and unpack it with those commands: |
| 22 | {{{ |
| 23 | wget -c http://www.smokin-guns.org/downloads/Smokin_Guns_1.1.zip |
| 24 | unzip Smokin_Guns_1.1.zip |
| 25 | rm Smokin_Guns_1.1.zip |
| 26 | mv "Smokin' Guns" sgserver |
| 27 | }}} |
| 28 | also, you can do: |
| 29 | {{{ |
| 30 | cd sgserver |
| 31 | mv smokinguns_dedicated.i386 smokinguns_dedicated |
| 32 | chmod +x smokinguns_dedicated |
| 33 | }}} |
| 34 | As you see, we will run the 32bits binaries. If a problem occurs and you need the 64bits binaries, you may compile them yourself or ask them on the forum. Then you should replace the binaries to the 64bits you got. |
| 35 | |
| 36 | Finally, just have a look into the .cfg files into {{{~/sgserver/smokinguns}}} in particuliar read {{{server.cfg}}}. |
| 37 | == Starting the server == |
| 38 | === With screen === |
| 39 | Screen is a terminal emulator where you can have some program running even if you aren't logged. It is a really quick solution to start a server. If you don't have it, install screen. |
| 40 | To start a server via screen just do type those commands: |
| 41 | {{{ |
| 42 | screen |
| 43 | cd ~/sgserver/ |
| 44 | ./smokinguns_dedicated +exec server.cfg +set dedicated "2" |
| 45 | }}} |
| 46 | To quit from screen the right way, just do a CTRL-A + D and you can now logout safely. |
| 47 | If you want to see it back, just do either: |
| 48 | {{{ |
| 49 | screen -r |
| 50 | }}} |
| 51 | or: |
| 52 | {{{ |
| 53 | screen -ls |
| 54 | screen -r <id> |
| 55 | }}} |
| 56 | The {{{id}}} is the number that identifies the screen session when you displayed them all in the first command. |
| 57 | |
| 58 | === With an init.d daemon === |
| 59 | With this method, the server can now be used like any other daemon, but you need to do some root work for that matter. |
| 60 | So, create a daemon file into {{{/etc/init.d/sgserver.sh}}} with the following content: |
| 61 | {{{ |
| 62 | #!/bin/bash |
| 63 | |
| 64 | ### BEGIN INIT INFO |
| 65 | # Provides: sgserver |
| 66 | # Required-Start: |
| 67 | # Required-Stop: |
| 68 | # Default-Start: 2 3 4 5 |
| 69 | # Default-Stop: 0 1 6 |
| 70 | # Short-Description: Start/stop Smokin'Guns server |
| 71 | ### END INIT INFO |
| 72 | |
| 73 | RULE="su - user -c" |
| 74 | BIN="/home/user/sgserver/smokinguns_dedicated +set dedicated 2 +set net_port 27960 +set com_hunkmegs 128 +exec server.cfg >/dev/null 2>&1 &" |
| 75 | PROC="smokinguns_dedicated" |
| 76 | |
| 77 | case "$1" in |
| 78 | |
| 79 | 'start') |
| 80 | $RULE "$BIN" |
| 81 | echo "Smokin' Guns server is running..." |
| 82 | ;; |
| 83 | 'stop') |
| 84 | killall $PROC |
| 85 | echo "Smokin' Guns server is stopped..." |
| 86 | ;; |
| 87 | *) |
| 88 | echo "Usage: $0 start|stop" |
| 89 | ;; |
| 90 | esac |
| 91 | exit 0 |
| 92 | }}} |
| 93 | |
| 94 | You need then to do: |
| 95 | {{{ |
| 96 | chmod +x /etc/init.d/sgserver.sh |
| 97 | ln -s /etc/init.d/sgserver.sh /usr/local/bin/sgserver |
| 98 | }}} |
| 99 | |
| 100 | You can now use your server as a daemon like this: |
| 101 | |
| 102 | start: |
| 103 | {{{ |
| 104 | sgserver start |
| 105 | }}} |
| 106 | stop: |
| 107 | {{{ |
| 108 | sgserver stop |
| 109 | }}} |