Browse Source

working on systemd service to start server

master
poikilos 7 years ago
committed by Jacob Gustafson
parent
commit
4083ce545f
  1. 14
      etc/change_hardcoded_username_first/mts-ENLIVEN.service
  2. 24
      etc/change_hardcoded_username_first/runme after installing stuff in etc.sh
  3. 0
      etc/change_hardcoded_username_first/upstart_version/etc/init.d/mts-ENLIVEN.conf
  4. 8
      etc/change_hardcoded_username_first/upstart_version/install and start service.sh
  5. 13
      etc/change_hardcoded_username_first/upstart_version/mts-ENLIVEN.conf

14
etc/change_hardcoded_username_first/mts-ENLIVEN.service

@ -0,0 +1,14 @@
[Unit]
description "Job that runs mts-ENLIVEN minetest server as specific user"
After=network.target
[Service]
Type=simple
Environment=statedir=/var/cache/mts-ENLIVEN
ExecStartPre=/usr/bin/mkdir -p ${statedir}
User=owner
Group=owner
ExecStart=/home/owner/minetest/bin/minetestserver --gameid ENLIVEN --worldname FCAGameAWorld
[Install]
WantedBy=multi-user.target

24
etc/change_hardcoded_username_first/runme after installing stuff in etc.sh

@ -1,5 +1,27 @@
#!/bin/sh
#enable the mts-ENLIVEN upstart service (after you've copied it) on Ubuntu:
#This is a systemd startup unit, and will only work if your system is running systemd
#(see https://wiki.ubuntu.com/SystemdForUpstartUsers or https://www.freedesktop.org/software/systemd/man/systemd.service.html
# and https://www.freedesktop.org/software/systemd/man/systemd.exec.html# --discusses execution options such as User)
#* Ignores invalid directives and starts the service ...
# systemd-analyze verify <unit> file to get warnings on typos and badly formatted options.
#* requires full path, so ExecStart=/bin/sleep 20 works but ExecStart=sleep 20 does not.
## Known Issues
# * should use machinectl shell instead of su or sudo as of 2016 updates to systemd
# * Restart=on-abort and RestartSec=3 settings could be used (but probably shouldn't, so minetest crash can be noticed [and debugged more easily by viewing tail of debug log])
# * Maybe for ExecStart, instead use:
# su owner "screen -S MinetestServer /home/owner/minetest/bin/minetestserver --gameid ENLIVEN --worldname FCAGameAWorld"
# OR
# sudo -u owner screen -S MinetestServer /home/owner/minetest/bin/minetestserver --gameid ENLIVEN --worldname FCAGameAWorld
# instead of User=owner
#Update the unit:
wget https://github.com/expertmm/EnlivenMinetest/raw/master/etc/change_hardcoded_username_first/mts-ENLIVEN.service
echo "This will only work if you are using systemd."
sudo mv -f mts-ENLIVEN.service /etc/init.d/
#? sudo mv -f mts-ENLIVEN.service /etc/systemd/system/
#enable the mts-ENLIVEN systemd service on Ubuntu:
sudo service mts-ENLIVEN enable
sudo service mts-ENLIVEN start

0
etc/change_hardcoded_username_first/etc/init.d/mts-ENLIVEN.conf → etc/change_hardcoded_username_first/upstart_version/etc/init.d/mts-ENLIVEN.conf

8
etc/change_hardcoded_username_first/upstart_version/install and start service.sh

@ -0,0 +1,8 @@
#!/bin/sh
echo "This doesn't work on Xenial since Ubuntu switched from Canonical upstart to systemd (unless you manually switched to upstart)"
wget https://github.com/expertmm/EnlivenMinetest/raw/master/etc/change_hardcoded_username_first/upstart_version/etc/init.d/mts-ENLIVEN.conf
sudo mv -f mts-ENLIVEN.conf /etc/init.d/
#enable the mts-ENLIVEN upstart service on Ubuntu:
sudo service mts-ENLIVEN enable
sudo service mts-ENLIVEN start

13
etc/change_hardcoded_username_first/upstart_version/mts-ENLIVEN.conf

@ -0,0 +1,13 @@
description "Job that runs mts-ENLIVEN minetest server as specific user"
# start in normal runlevels when disks are mounted and networking is available
start on runlevel [2345]
# stop on shutdown/halt, single-user mode and reboot
stop on runlevel [016]
#env statedir=/var/cache/mts-ENLIVEN
# create a directory needed by the daemon
#pre-start exec mkdir -p "$statedir"
exec sudu -u owner /home/owner/mts-ENLIVEN
Loading…
Cancel
Save