View | Details | Raw Unified | Return to bug 197387 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (+11 lines)
Lines 11-16 Link Here
11
MAINTAINER=	freebsd@jonathanprice.org
11
MAINTAINER=	freebsd@jonathanprice.org
12
COMMENT=	Dedicated server for the game Minecraft
12
COMMENT=	Dedicated server for the game Minecraft
13
13
14
OPTIONS_DEFINE=	DAEMON
15
DAEMON_DESC=	Allows controlling via rc.d
16
OPTIONS_SUB=	yes
17
14
USERS=		mcserver
18
USERS=		mcserver
15
GROUPS=		${USERS}
19
GROUPS=		${USERS}
16
20
Lines 27-32 Link Here
27
		usercache.json \
31
		usercache.json \
28
		whitelist.json
32
		whitelist.json
29
33
34
.include <bsd.port.options.mk>
35
36
.if ${PORT_OPTIONS:MDAEMON}
37
USE_RC_SUBR+=	minecraft
38
RUN_DEPENDS+=	tmux:${PORTSDIR}/sysutils/tmux
39
.endif
40
30
do-install:
41
do-install:
31
	${MKDIR} ${STAGEDIR}${PREFIX}/${PORTNAME}
42
	${MKDIR} ${STAGEDIR}${PREFIX}/${PORTNAME}
32
	${INSTALL_DATA} ${DISTDIR}/${DISTNAME} ${STAGEDIR}${PREFIX}/${PORTNAME}
43
	${INSTALL_DATA} ${DISTDIR}/${DISTNAME} ${STAGEDIR}${PREFIX}/${PORTNAME}
(-)files/minecraft.in (+91 lines)
Line 0 Link Here
1
#!/bin/sh
2
#
3
# $FreeBSD$
4
# PROVIDE: minecraft
5
# REQUIRE: LOGIN
6
# KEYWORD: shutdown
7
#
8
# rc.conf variables:
9
# minecraft_enable (Default: NO)
10
# minecraft_mem (Default: 1024M)
11
# minecraft_args (Default: "")
12
. /etc/rc.subr
13
14
name=minecraft
15
rcvar=minecraft_enable
16
desc="Dedicated server for the game Minecraft"
17
18
load_rc_config $name
19
20
minecraft_mem=${minecraft_mem:-"1024M"}
21
minecraft_args=${minecraft_args:-""}
22
23
extra_commands="console status"
24
start_cmd="${name}_start"
25
stop_cmd="${name}_stop"
26
console_cmd="${name}_console"
27
status_cmd="${name}_status"
28
29
minecraft_start()
30
{
31
	pgrep -qu mcserver java
32
	isrunning=$?
33
	if [ ${isrunning} -eq 0 ]; then
34
		echo "${name} already running."
35
	else
36
		echo "Starting ${name}."
37
		cd %%PREFIX%%/minecraft-server
38
		su mcserver -c "%%LOCALBASE%%/bin/tmux new-session -s minecraft -d '%%LOCALBASE%%/bin/java -Xmx${minecraft_mem} -Xms${minecraft_mem} ${minecraft_args} -jar %%PREFIX%%/minecraft-server/minecraft_server.1.8.1.jar nogui'"
39
	fi
40
}
41
42
minecraft_stop()
43
{
44
	pgrep -qu mcserver java
45
	isrunning=$?
46
	if [ ${isrunning} -eq 0 ]; then
47
		echo "Stopping ${name}."
48
		su mcserver -c "%%LOCALBASE%%/bin/tmux send-keys -t ${name} \"stop\" ENTER"
49
50
		i=0
51
		while [ $i -lt 10 ]; do
52
			i=$(($i + 1))
53
			pgrep -qu mcserver java
54
			stillrunning=$?
55
			if [ ${stillrunning} -eq 0 ]; then
56
				sleep 1
57
			else
58
				echo "${name} stopped."
59
				return
60
			fi
61
		done
62
		echo "ERROR: ${name} could not be stopped."
63
	else
64
		echo "${name} not running."
65
	fi
66
}
67
68
minecraft_console()
69
{
70
	pgrep -qu mcserver java
71
	isrunning=$?
72
	if [ ${isrunning} -ne 0 ]; then
73
		echo "${name} not running."
74
	else
75
		export TERM=xterm
76
		su mcserver -c "%%LOCALBASE%%/bin/tmux attach-session -t ${name}"
77
	fi
78
}
79
80
minecraft_status()
81
{
82
	pgrep -qu mcserver java
83
	isrunning=$?
84
	if [ ${isrunning} -eq 0 ]; then
85
		echo "${name} is running."
86
	else
87
		echo "${name} is not running."
88
	fi
89
}
90
91
run_rc_command "$1"
(-)files/pkg-message.in (-4 / +10 lines)
Lines 1-16 Link Here
1
When you first run minecraft-server, it will populate the file
1
When you first run minecraft-server, it will populate the file
2
%%ETCDIR%%/eula.txt
2
%%ETCDIR%%/eula.txt
3
3
4
It is required to read the EULA, and then set:
4
It is required to read the EULA, and then set eula=true
5
eula=true
6
5
7
- To run the server, run %%PREFIX%%/bin/minecraft-server
8
- Configuration files can be found at %%ETCDIR%%
6
- Configuration files can be found at %%ETCDIR%%
9
- Log and debug output files can be found at /var/log/minecraft-server/
7
- Log and debug output files can be found at /var/log/minecraft-server/
10
- World files can be found at /var/db/minecraft-server
8
- World files can be found at /var/db/minecraft-server
9
10
Without daemon option:
11
- To run the server, run %%PREFIX%%/bin/minecraft-server
11
- To edit java's parameters, edit %%ETCDIR%%/java-args.txt
12
- To edit java's parameters, edit %%ETCDIR%%/java-args.txt
12
13
13
NOTE:
14
With daemon option:
15
- The service has been installed with the name 'minecraft'
16
- To adjust memory usage, use MINECRAFT_MEM= in /etc/rc.conf
17
- To add other java parameters, use MINECRAFT_ARGS= in /etc/rc.conf
18
- To see the interactive console, type service minecraft console
19
14
Users upgrading from version < 1.8 are advised to run the server to
20
Users upgrading from version < 1.8 are advised to run the server to
15
generate new config files, and then modify them based on their existing
21
generate new config files, and then modify them based on their existing
16
configuration, as most files are now JSON instead of txt.
22
configuration, as most files are now JSON instead of txt.

Return to bug 197387