Skip to content

command: adds the install-init command to the docs #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Replace `./gameserver` with the actual script name. Every command has a short ve
| [Validate](validate.md) | `./gameserver validate` | `./gameserver v` |
| [Console](console.md) | `./gameserver console` | `./gameserver c` |
| [Debug](debug.md) | `./gameserver debug` | `./gameserver d` |
| [Install init](install-init.md) | `./gameserver install-init` | `./gameserver ii` |

## Specific commands

Expand Down
25 changes: 25 additions & 0 deletions commands/install-init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# install-init
The `install-init` command can generate the contents from a systemd service file and place the contents automatically into `/etc/systemd/system`

The naming conventions are the short name of the server (e.g. `mcserver` as minecraft server) plus `-lgsm.service`

See [running on boot](../configuration/running-on-boot.md) for more information.

## Commands

Run the following command to install the systemd service files:

Standard: `./gameserver install-init`
Short: `./gameserver ii`

Then enter your root password.

## Example output

```
[ OK ] systemd service file mcserver: Generated the file contents
Information! Enter the password of root:
Password:
Complete! Placed the file in /etc/systemd/system/ as mcserver-lgsm.service
Information! run `systemctl enable mcserver-lgsm.service` (as root), to enable the game on boot
```
59 changes: 35 additions & 24 deletions configuration/running-on-boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,52 @@
## Using systemd

systemd is the default init system for most modern distros.
You can either generate and place the files contents using the install-init function, which will do it all for you, or do it manually.

You need to create a service file in `/etc/systemd/system/`
- ### Using the install-init command

Example `ts3server.service`
Run `./<gameserver> install-init`, this will create and place the contents in `/etc/systemd/system/short name-lgsm.service`.
The content will be based on the manual service file.

```text
[Unit]
Description=LinuxGSM Teamspeak3 Server
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
User=ts3server
WorkingDirectory=/home/ts3server
RemainAfterExit=yes #Assume that the service is running after main process exits with code 0
ExecStart=/home/ts3server/ts3server start
ExecStop=/home/ts3server/ts3server stop
Restart=no
- ### Manual service file

You need to create a service file in `/etc/systemd/system/`

Example `gameserver.service`

```text
[Unit]
Description=LinuxGSM Game Server
After=network-online.target
Wants=network-online.target

[Service]
Type=forking
User=gameserver
WorkingDirectory=/home/gameserver
RemainAfterExit=yes # Assume that the service is running after main process exits with code 0
ExecStart=/home/gameserver/gameserver start
ExecStop=/home/gameserver/gameserver stop
Restart=no

[Install]
WantedBy=multi-user.target
```

Replace the user and paths to fit your setup.

[Install]
WantedBy=multi-user.target
```

Replace the user and paths to fit your setup.

You need to reload the systemd-daemon once to make it aware of the new service file by `systemctl daemon-reload`

Now you can do
Now you can do (as root)

```bash
systemctl start ts3server # Start the server
systemctl stop ts3server # Stop the server
systemctl enable ts3server # Enable start on boot
systemctl disable ts3server # Disable start on boot
systemctl start gameserver # Start the server
systemctl stop gameserver # Stop the server
systemctl enable gameserver # Enable start on boot
systemctl disable gameserver # Disable start on boot
```

## Crontab
Expand Down