diff --git a/etc/change_hardcoded_username_first/mts-ENLIVEN.service b/etc/change_hardcoded_username_first/mts-ENLIVEN.service new file mode 100644 index 0000000..06d639b --- /dev/null +++ b/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 diff --git a/etc/change_hardcoded_username_first/runme after installing stuff in etc.sh b/etc/change_hardcoded_username_first/runme after installing stuff in etc.sh index f901f15..c605773 100644 --- a/etc/change_hardcoded_username_first/runme after installing stuff in etc.sh +++ b/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 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 diff --git a/etc/change_hardcoded_username_first/etc/init.d/mts-ENLIVEN.conf b/etc/change_hardcoded_username_first/upstart_version/etc/init.d/mts-ENLIVEN.conf similarity index 100% rename from etc/change_hardcoded_username_first/etc/init.d/mts-ENLIVEN.conf rename to etc/change_hardcoded_username_first/upstart_version/etc/init.d/mts-ENLIVEN.conf diff --git a/etc/change_hardcoded_username_first/upstart_version/install and start service.sh b/etc/change_hardcoded_username_first/upstart_version/install and start service.sh new file mode 100644 index 0000000..21692e5 --- /dev/null +++ b/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 diff --git a/etc/change_hardcoded_username_first/upstart_version/mts-ENLIVEN.conf b/etc/change_hardcoded_username_first/upstart_version/mts-ENLIVEN.conf new file mode 100644 index 0000000..af2ba68 --- /dev/null +++ b/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