diff options
author | V3n3RiX <venerix@koprulu.sector> | 2022-04-16 13:07:24 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2022-04-16 13:07:24 +0100 |
commit | 0c100b7dd2b30e75b799d806df4ef899fd98e1ea (patch) | |
tree | 464c922e949c7e4d5d891fb2cdda5daee5612537 /games-simulation/openttd/files/openttd.initd-r3 | |
parent | e68d405c5d712af4387159df07e226217bdda049 (diff) |
gentoo resync : 16.04.2022
Diffstat (limited to 'games-simulation/openttd/files/openttd.initd-r3')
-rw-r--r-- | games-simulation/openttd/files/openttd.initd-r3 | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/games-simulation/openttd/files/openttd.initd-r3 b/games-simulation/openttd/files/openttd.initd-r3 new file mode 100644 index 000000000000..89680f91d267 --- /dev/null +++ b/games-simulation/openttd/files/openttd.initd-r3 @@ -0,0 +1,34 @@ +#!/sbin/openrc-run +# Copyright 1999-2022 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later + +description="OpenTTD dedicated game server" +dtach_tmpfile="$(mktemp -u)" +name="OpenTTD dedicated game server" +openttd_command="/usr/bin/openttd" +pidfile="/run/${SVCNAME}.pid" + +description_attach="Attaches to the session (interactive console) of the OpenTTD game server" +extra_started_commands="attach" + +command="/usr/bin/dtach" +command_args="-N ${dtach_tmpfile} ${openttd_command} -D ${openttd_opts}" +command_background="true" +command_group="openttd" +command_user="openttd" + +depend() { + need net +} + +attach() { + pidnumber="$(cat ${pidfile})" + dtach_tmpfile="$(cat /proc/${pidnumber}/cmdline | tr '\0' ' ' | awk '{print $3}')" + + if [ -S "${dtach_tmpfile}" ]; then + eval "${command}" -a "${dtach_tmpfile}" "${dtach_opts}" + else + eerror "The determined socket file for dtach could not be found!" + eerror "Did the process crash?" + fi +} |