| 111 | |
| 112 | === With a systemd unit file === |
| 113 | It is similar as the previous method, but instead of having a classic BSD-like init system (SysVinit, Upstart or OpenRC), your linux distribution comes with systemd. |
| 114 | One big change is that now, you have the possibility to create a unit file instead of a starting shell script. |
| 115 | |
| 116 | For this, you can create a file into {{{/etc/systemd/system/sgserver.service}}} or {{{/usr/lib/systemd/system/sgserver.service}}} with this following content: |
| 117 | {{{ |
| 118 | [Unit] |
| 119 | Description=Smokin' Guns dedicated server |
| 120 | |
| 121 | [Service] |
| 122 | User=user # account we created |
| 123 | ExecStart=/home/user/sgserver/smokinguns_dedicated +set dedicated 2 +set net_port 27960 +set com_hunkmegs 128 +exec server.cfg |
| 124 | Restart=on-abort |
| 125 | |
| 126 | [Install] |
| 127 | WantedBy=multi-user.target |
| 128 | }}} |
| 129 | |
| 130 | You can now use your server with the commands provided by systemd: |
| 131 | |
| 132 | start: |
| 133 | {{{ |
| 134 | systemctl start sgserver.service |
| 135 | }}} |
| 136 | |
| 137 | stop: |
| 138 | {{{ |
| 139 | systemctl stop sgserver.service |
| 140 | }}} |
| 141 | |
| 142 | If you need more commands, you can have a look at the [https://wiki.archlinux.org/index.php/Systemd ArchLinux Wiki page]. |