mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-08-06 00:48:18 -07:00
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>
This commit is contained in:
@@ -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=""
|
||||
10
games-simulation/openttd/files/openttd.confd-r1
Normal file
10
games-simulation/openttd/files/openttd.confd-r1
Normal file
@@ -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=""
|
||||
@@ -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
|
||||
}
|
||||
34
games-simulation/openttd/files/openttd.initd-r3
Normal file
34
games-simulation/openttd/files/openttd.initd-r3
Normal file
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user