diff options
author | Conrad Kostecki <conikost@gentoo.org> | 2022-04-12 22:57:20 +0200 |
---|---|---|
committer | Conrad Kostecki <conikost@gentoo.org> | 2022-04-12 22:58:25 +0200 |
commit | 17d9e66641cfdec7bf1a2f97f8d50fd4d93d8435 (patch) | |
tree | 1a2af8cbb397ec3ac9d5a4ce706becb205e24b5c /games-simulation | |
parent | net-libs/ngtcp2: 0.3.1 version bump (diff) | |
download | gentoo-17d9e66641cfdec7bf1a2f97f8d50fd4d93d8435.tar.gz gentoo-17d9e66641cfdec7bf1a2f97f8d50fd4d93d8435.tar.bz2 gentoo-17d9e66641cfdec7bf1a2f97f8d50fd4d93d8435.zip |
games-simulation/openttd: add custom attach command
Adding a custom attach command, so you can attach yourself with 'dtach'
in the interactive console open OpenTTD, when running in server mode.
Signed-off-by: Conrad Kostecki <conikost@gentoo.org>
Diffstat (limited to 'games-simulation')
-rw-r--r-- | games-simulation/openttd/files/openttd.confd | 5 | ||||
-rw-r--r-- | games-simulation/openttd/files/openttd.confd-r1 | 10 | ||||
-rw-r--r-- | games-simulation/openttd/files/openttd.initd-r2 | 16 | ||||
-rw-r--r-- | games-simulation/openttd/files/openttd.initd-r3 | 34 | ||||
-rw-r--r-- | games-simulation/openttd/openttd-12.2-r1.ebuild (renamed from games-simulation/openttd/openttd-12.2.ebuild) | 5 |
5 files changed, 47 insertions, 23 deletions
diff --git a/games-simulation/openttd/files/openttd.confd b/games-simulation/openttd/files/openttd.confd deleted file mode 100644 index 399ab5d984c6..000000000000 --- a/games-simulation/openttd/files/openttd.confd +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright 1999-2022 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -# Options for your started OpenTTD server -openttd_opts="" 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-r2 b/games-simulation/openttd/files/openttd.initd-r2 deleted file mode 100644 index 6a24bbc25072..000000000000 --- a/games-simulation/openttd/files/openttd.initd-r2 +++ /dev/null @@ -1,16 +0,0 @@ -#!/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" -pidfile="/run/${SVCNAME}.pid" - -command="/usr/bin/openttd" -command_args="-D ${openttd_opts}" -command_background="true" -command_group="openttd" -command_user="openttd" - -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 +} diff --git a/games-simulation/openttd/openttd-12.2.ebuild b/games-simulation/openttd/openttd-12.2-r1.ebuild index aaeac2d9a8f2..2c6d18c4b2c4 100644 --- a/games-simulation/openttd/openttd-12.2.ebuild +++ b/games-simulation/openttd/openttd-12.2-r1.ebuild @@ -22,6 +22,7 @@ RDEPEND=" dedicated? ( acct-group/openttd acct-user/openttd + app-misc/dtach ) !dedicated? ( allegro? ( media-libs/allegro:5 ) @@ -90,8 +91,8 @@ src_configure() { src_install() { cmake_src_install if use dedicated ; then - newconfd "${FILESDIR}"/openttd.confd openttd - newinitd "${FILESDIR}"/openttd.initd-r2 openttd + newconfd "${FILESDIR}"/openttd.confd-r1 openttd + newinitd "${FILESDIR}"/openttd.initd-r3 openttd fi } |