Linux Setting up 7days to launch as a systemctl service on Ubuntu linux

Currently setting up scripts to run under init.d is not recommended and will at some point become deprecated. The current recommened practice is to use systemctl in Ubuntu. The documentation on this stuff is out there, but I could not find anything really on how to set it up specifically for 7days to die.

I will give you the steps I used that work:


to add as service: Specifying multi-user.target launches the script after the system is ready for users to login to the system after it is fully booted up.

in /etc/system/system

add file 7days.service containing:

[Unit]

Description=My Custom Service [Service] Type=simple ExecStart=/usr/local/bin/7days.sh # Replace with the actual path to your script

Restart=always [Install] WantedBy=multi-user.target

WantedBy=multi-user.target


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

add the start script to /usr/local/bin (This is the recommended place to add all startup scripts. Any directory is OK. /boot is another good option as well.

name file 7days.sh and it contains:

#!/bin/bash

nohup sh /home/7days/7days/startserver.sh -configfile=/home/7days/7days/serverconfig.xml -nographics -dedicated -quit

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

to start the service. First you have to reload systemctl to read the setting changes. Then you have to enable the service, then you have to start it. Bouncing the service is a simple matter of using restart or stop then start.

sudo systemctl daemon-reload

sudo systemctl enable 7days.service

sudo systemctl start 7days.service
 
Back
Top