summaryrefslogtreecommitdiff
path: root/games-simulation/openttd/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-04-16 13:07:24 +0100
committerV3n3RiX <venerix@koprulu.sector>2022-04-16 13:07:24 +0100
commit0c100b7dd2b30e75b799d806df4ef899fd98e1ea (patch)
tree464c922e949c7e4d5d891fb2cdda5daee5612537 /games-simulation/openttd/files
parente68d405c5d712af4387159df07e226217bdda049 (diff)
gentoo resync : 16.04.2022
Diffstat (limited to 'games-simulation/openttd/files')
-rw-r--r--games-simulation/openttd/files/openttd.confd-r110
-rw-r--r--games-simulation/openttd/files/openttd.initd-r113
-rw-r--r--games-simulation/openttd/files/openttd.initd-r334
3 files changed, 44 insertions, 13 deletions
diff --git a/games-simulation/openttd/files/openttd.confd-r1 b/games-simulation/openttd/files/openttd.confd-r1
new file mode 100644
index 000000000000..47cae2fda01a
--- /dev/null
+++ b/games-simulation/openttd/files/openttd.confd-r1
@@ -0,0 +1,10 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# Dtach options, which will used, when the `attach` extra command is called.
+# By default, CTRL+D is used, and no signal is send,
+# when you want to detach from the attached console.
+dtach_opts="-e '^D' -r none"
+
+# Options for your started OpenTTD server
+openttd_opts=""
diff --git a/games-simulation/openttd/files/openttd.initd-r1 b/games-simulation/openttd/files/openttd.initd-r1
deleted file mode 100644
index 0bfeefddf6d6..000000000000
--- a/games-simulation/openttd/files/openttd.initd-r1
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License, v2 or later
-
-description="OpenTTD dedicated game server"
-pidfile="/run/${SVCNAME}.pid"
-command="/usr/bin/openttd"
-command_args="-D"
-command_background="true"
-
-depend() {
- need net
-}
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
+}