blob: 89680f91d2670da4319086a0030a895e6f4acde0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
}
|