2 # Copyright 1999-2020 Gentoo Authors
3 # Distributed under the terms of the GNU General Public License v2
5 if [ "${SVCNAME}" = "bedrock-server" ]; then
8 instance="${SVCNAME#*.}"
11 bedrock_command="/opt/bin/bedrock-server"
12 bedrock_path="/var/lib/bedrock-server"
13 bedrock_path_data="/opt/bedrock-server"
14 bedrock_path_instance="${bedrock_path}/${instance}"
15 directory="${bedrock_path_instance}/"
16 dtach_tmpfile="$(mktemp -u)"
17 name="Minecraft Bedrock server (${instance})"
18 pidfile="/run/bedrock-server.${instance}.pid"
20 description_attach="Attaches to the session (interactive console) of the Minecraft Bedrock server"
21 extra_started_commands="attach"
23 command="/usr/bin/dtach"
24 command_background="true"
25 command_args="-N ${dtach_tmpfile} ${bedrock_command}"
26 command_group="bedrock"
27 command_user="bedrock"
34 checkpath -d -o "${command_user}:${command_group}" -q "${bedrock_path}" "${bedrock_path_instance}"
36 set -- "allowlist.json" "permissions.json" "server.properties"
37 for bedrock_config in $@; do
38 if [ ! -f "${bedrock_path_instance}/${bedrock_config}" ]; then
39 cp "${bedrock_path_data}/${bedrock_config}" "${bedrock_path_instance}"
40 checkpath -f -o "${command_user}:${command_group}" -q "${bedrock_path_instance}/${bedrock_config}"
44 set -- "behavior_packs" "definitions" "resource_packs" "structures"
45 for bedrock_ressource in $@; do
46 if [ ! -L "${bedrock_path_instance}/${bedrock_ressource}" ]; then
47 ln -sf "${bedrock_path_data}/${bedrock_ressource}" "${bedrock_path_instance}"
53 pidnumber="$(cat ${pidfile})"
54 dtach_tmpfile="$(cat /proc/${pidnumber}/cmdline | tr '\0' ' ' | awk '{print $3}')"
56 if [ -S "${dtach_tmpfile}" ]; then
57 eval "${command}" -a "${dtach_tmpfile}" "${DTACH_OPTS}"
59 eerror "The determined socket file for dtach could not be found!"
60 eerror "Did the process crash?"