aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GIDs1
-rw-r--r--UIDs1
-rw-r--r--games/minecraft-server/Makefile79
-rw-r--r--games/minecraft-server/files/banned-ips.txt.sample1
-rw-r--r--games/minecraft-server/files/banned-players.txt.sample1
-rw-r--r--games/minecraft-server/files/minecraft.in120
-rw-r--r--games/minecraft-server/files/ops.txt.sample1
-rw-r--r--games/minecraft-server/files/pkg-deinstall.in26
-rw-r--r--games/minecraft-server/files/pkg-message.in40
-rw-r--r--games/minecraft-server/files/server.properties.sample24
-rw-r--r--games/minecraft-server/files/white-list.txt.sample1
-rw-r--r--games/minecraft-server/pkg-plist25
12 files changed, 307 insertions, 13 deletions
diff --git a/GIDs b/GIDs
index 197ca4cb379a..1845f476691e 100644
--- a/GIDs
+++ b/GIDs
@@ -96,6 +96,7 @@ moinmoin:*:192:
cups:*:193:
saned:*:194:
radns:*:195:
+mcserver:*:199:
sympa:*:200:
dspam:*:202:
yate:*:204:
diff --git a/UIDs b/UIDs
index 387fb7f426f9..82549f7433c6 100644
--- a/UIDs
+++ b/UIDs
@@ -102,6 +102,7 @@ moinmoin:*:192:192::0:0:MoinMoin User:/nonexistent:/usr/sbin/nologin
cups:*:193:193::0:0:Cups Owner:/nonexistent:/usr/sbin/nologin
saned:*:194:194::0:0:SANE Scanner Daemon:/nonexistent:/bin/sh
radns:*:195:195::0:0:radns user:/nonexistent:/sbin/nologin
+mcserver:*:199:199::0:0:Minecraft Server:/nonexistent:/bin/sh
sympa:*:200:200::0:0:Sympa Owner:/nonexistent:/usr/sbin/nologin
privoxy:*:201:201::0:0:Privoxy proxy user:/nonexistent:/usr/sbin/nologin
dspam:*:202:202::0:0:Dspam:/nonexistent:/usr/sbin/nologin
diff --git a/games/minecraft-server/Makefile b/games/minecraft-server/Makefile
index 4ecf19219955..6ffc60ff146f 100644
--- a/games/minecraft-server/Makefile
+++ b/games/minecraft-server/Makefile
@@ -6,28 +6,37 @@
#
PORTNAME= minecraft-server
-PORTVERSION= 1.0.0
+PORTVERSION= 1.0.1
CATEGORIES= games java
MASTER_SITES= http://s3.amazonaws.com/MinecraftDownload/launcher/:minecraft \
- http://www.minecraftwiki.net/images/f/f7/:icon
-DISTNAME= minecraft_server
-DISTFILES= minecraft_server.jar:minecraft \
- Bookshelf.png:icon
+ http://www.minecraftwiki.net/images/f/f7/:icon
+DISTNAME= minecraft_server
+DISTFILES= minecraft_server.jar:minecraft \
+ Bookshelf.png:icon
EXTRACT_ONLY=
-MAINTAINER= freebsd@rakor-net.de
-COMMENT= Server for the block building game
+MAINTAINER= freebsd@rakor-net.de
+COMMENT= Server for the block building game
-OPTIONS= X11 "Build with X11 support" On
+RUN_DEPENDS= tmux:${PORTSDIR}/sysutils/tmux
+
+OPTIONS= X11 "Build with X11 support" On
+
+ETCDIR= ${PREFIX}/etc/minecraft
.include <bsd.port.options.mk>
-WRKSRC= ${WRKDIR}
-NO_BUILD= yes
-USE_JAVA= yes
+WRKSRC= ${WRKDIR}
+NO_BUILD= yes
+USE_JAVA= yes
+USERS?= mcserver
+GROUPS?= ${USERS}
+USE_RC_SUBR= minecraft
+SUB_FILES= pkg-deinstall \
+ pkg-message
.if !defined(WITHOUT_X11)
-DESKTOP_ENTRIES= "Minecraft-Server" "Block building game (server)" "${DATADIR}/Bookshelf.png" "minecraft-server" "Application;Game;" false
+DESKTOP_ENTRIES="Minecraft-Server" "Block building game (server)" "${DATADIR}/Bookshelf.png" "minecraft-server" "Application;Game;" false
.endif
.if !defined(WITHOUT_X11)
@@ -54,5 +63,51 @@ do-install:
${INSTALL_SCRIPT} ${WRKDIR}/${PORTNAME} ${PREFIX}/bin/
.endif
${INSTALL_SCRIPT} ${WRKDIR}/${PORTNAME}-nogui ${PREFIX}/bin/
+ ${MKDIR} ${ETCDIR}
+ ${INSTALL_DATA} ${FILESDIR}/server.properties.sample ${DATADIR}/server.properties.sample
+ ${INSTALL_DATA} ${FILESDIR}/ops.txt.sample ${DATADIR}/ops.txt.sample
+ ${INSTALL_DATA} ${FILESDIR}/white-list.txt.sample ${DATADIR}/white-list.txt.sample
+ ${INSTALL_DATA} ${FILESDIR}/banned-ips.txt.sample ${DATADIR}/banned-ips.txt.sample
+ ${INSTALL_DATA} ${FILESDIR}/banned-players.txt.sample ${DATADIR}/banned-players.txt.sample
+ if [ ! -f ${ETCDIR}/server.properties ]; then \
+ ${CP} -p ${DATADIR}/server.properties.sample ${ETCDIR}/server.properties ; \
+ fi
+ if [ ! -f ${ETCDIR}/ops.txt ]; then \
+ ${CP} -p ${DATADIR}/ops.txt.sample ${ETCDIR}/ops.txt ; \
+ fi
+ if [ ! -f ${ETCDIR}/white-list.txt ]; then \
+ ${CP} -p ${DATADIR}/white-list.txt.sample ${ETCDIR}/white-list.txt ; \
+ fi
+ if [ ! -f ${ETCDIR}/banned-ips.txt ]; then \
+ ${CP} -p ${DATADIR}/banned-ips.txt.sample ${ETCDIR}/banned-ips.txt ; \
+ fi
+ if [ ! -f ${ETCDIR}/banned-players.txt ]; then \
+ ${CP} -p ${DATADIR}/banned-players.txt.sample ${ETCDIR}/banned-players.txt ; \
+ fi
+ ${LN} -s ${ETCDIR}/server.properties ${DATADIR}/server.properties
+ ${LN} -s ${ETCDIR}/ops.txt ${DATADIR}/ops.txt
+ ${LN} -s ${ETCDIR}/white-list.txt ${DATADIR}/white-list.txt
+ ${LN} -s ${ETCDIR}/banned-ips.txt ${DATADIR}/banned-ips.txt
+ ${LN} -s ${ETCDIR}/banned-players.txt ${DATADIR}/banned-players.txt
+ ${CHOWN} -R ${USERS}:${GROUPS} ${DATADIR}
+ ${CHOWN} -R ${USERS}:${GROUPS} ${ETCDIR}
+ ${CHMOD} -R 644 ${DATADIR}/banned-ips.txt
+ ${CHMOD} -R 644 ${DATADIR}/banned-players.txt
+ ${CHMOD} -R 644 ${DATADIR}/ops.txt
+ ${CHMOD} -R 644 ${DATADIR}/white-list.txt
+ ${CHMOD} -R 644 ${DATADIR}/server.properties
+ ${CHMOD} -R 644 ${DATADIR}/banned-ips.txt.sample
+ ${CHMOD} -R 644 ${DATADIR}/banned-players.txt.sample
+ ${CHMOD} -R 644 ${DATADIR}/ops.txt.sample
+ ${CHMOD} -R 644 ${DATADIR}/white-list.txt.sample
+ ${CHMOD} -R 644 ${DATADIR}/server.properties.sample
+ ${CHMOD} -R 644 ${ETCDIR}/banned-ips.txt
+ ${CHMOD} -R 644 ${ETCDIR}/banned-players.txt
+ ${CHMOD} -R 644 ${ETCDIR}/ops.txt
+ ${CHMOD} -R 644 ${ETCDIR}/white-list.txt
+ ${CHMOD} -R 644 ${ETCDIR}/server.properties
+
+post-install:
+ ${CAT} ${PKGMESSAGE}
.include <bsd.port.mk>
diff --git a/games/minecraft-server/files/banned-ips.txt.sample b/games/minecraft-server/files/banned-ips.txt.sample
new file mode 100644
index 000000000000..4b2789f21526
--- /dev/null
+++ b/games/minecraft-server/files/banned-ips.txt.sample
@@ -0,0 +1 @@
+# each line one ip.
diff --git a/games/minecraft-server/files/banned-players.txt.sample b/games/minecraft-server/files/banned-players.txt.sample
new file mode 100644
index 000000000000..99be54e4bfc5
--- /dev/null
+++ b/games/minecraft-server/files/banned-players.txt.sample
@@ -0,0 +1 @@
+# each line one name
diff --git a/games/minecraft-server/files/minecraft.in b/games/minecraft-server/files/minecraft.in
new file mode 100644
index 000000000000..32897a981262
--- /dev/null
+++ b/games/minecraft-server/files/minecraft.in
@@ -0,0 +1,120 @@
+#!/bin/sh
+#
+# PROVIDE: minecraft
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name="minecraft"
+rcvar=`set_rcvar`
+
+load_rc_config $name
+
+extra_commands="clean killworld clearlog"
+start_cmd="${name}_start"
+stop_cmd="${name}_stop"
+clean_cmd="${name}_clean"
+killworld_cmd="${name}_killworld"
+clearlog_cmd="${name}_clearlog"
+
+eval "${rcvar}=\${${rcvar}:-'NO'}"
+
+minecraft_start()
+{
+if [ -e %%DATADIR%%/server.log.lck ]; then
+ echo "Server already running."
+else
+ echo "Starting Minecraft-Server..."
+ cd %%DATADIR%%
+ /usr/bin/su %%MC_USER%% -c "%%PREFIX%%/bin/tmux new-session -d -s minecraft \"java -Xmx1024M -Xms1024M -jar %%DATADIR%%/minecraft_server.jar nogui\""
+
+ i=0
+ while [ $i -lt 15 ]; do
+ i=$(($i + 1))
+ if [ -e %%DATADIR%%/server.log.lck ]; then
+ echo "Minecraft-Server running."
+ break
+ else
+ sleep 1
+ fi
+ done
+
+ if [ $i -ge 10 ]; then
+ echo "ERROR: Server could not be startet."
+ /usr/bin/su mcserver -c "%%PREFIX%%/bin/tmux kill-session -t minecraft"
+ fi
+fi
+}
+
+minecraft_stop(){
+if [ -e %%DATADIR%%/server.log.lck ]; then
+ echo "Halting Minecraft-Server."
+ /usr/bin/su mcserver -c "%%PREFIX%%/bin/tmux send -t minecraft:0.0 stop \"Enter\""
+
+
+ i=0
+ while [ $i -lt 15 ]; do
+ i=$(($i + 1))
+ if [ -e %%DATADIR%%/server.log.lck ]; then
+ sleep 1
+ else
+ echo "Minecraft-Server haltet."
+ break
+ fi
+ done
+
+ if [ $i -ge 10 ];then
+ echo "ERROR: Server could not be haltet."
+ fi
+else
+ echo "Minecraft-Server not running."
+fi
+}
+
+minecraft_clean(){
+ echo "Giving a stop to the server..."
+ minecraft_stop
+ echo "Cleaning..."
+ if [ -e %%DATADIR%%/server.log.lck ]; then
+ rm %%DATADIR%%/server.log.lck
+ echo "Cleaning done."
+ else
+ echo "Nothing to do. No unclean sessions."
+ fi
+}
+
+minecraft_killworld(){
+ echo "Trying to delete World"
+ if [ -e %%DATADIR%%/server.log.lck ]; then
+ echo "Server seems to be running. Stop server before deletion."
+ else
+ rm -rf %%DATADIR%%/world
+ if [ -d %%DATADIR%%/world ]; then
+ echo "ERROR: World could not be deleted"
+ else
+ echo "World deleted. Next serverstart will generate a new one"
+ fi
+ fi
+}
+
+minecraft_clearlog(){
+ echo "Trying to delete server.log"
+ if [ -e %%DATADIR%%/server.log.lck ]; then
+ echo "Server seems to be running. Stop server before deletion."
+ else
+ if [ -e %%DATADIR%%/server.log ]; then
+ rm %%DATADIR%%/server.log
+ if [ -e %%DATADIR%%/server.log ]; then
+ echo "ERROR: server.log could not be deleted"
+ else
+ echo "server.log deleted."
+ fi
+ else
+ echo "No server.log found"
+ fi
+ fi
+}
+
+run_rc_command "$1"
+
diff --git a/games/minecraft-server/files/ops.txt.sample b/games/minecraft-server/files/ops.txt.sample
new file mode 100644
index 000000000000..99be54e4bfc5
--- /dev/null
+++ b/games/minecraft-server/files/ops.txt.sample
@@ -0,0 +1 @@
+# each line one name
diff --git a/games/minecraft-server/files/pkg-deinstall.in b/games/minecraft-server/files/pkg-deinstall.in
new file mode 100644
index 000000000000..24ab45a267a1
--- /dev/null
+++ b/games/minecraft-server/files/pkg-deinstall.in
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+if [ "$2" != "POST-DEINSTALL" ]; then
+ exit 0
+fi
+
+if [ -d %%DATADIR%% ]; then
+ echo "There are some files (like your world and your server.log)"
+ echo "left in %%DATADIR%%."
+ echo "Use 'rm -rf %%DATADIR%%' to delete them."
+ echo
+fi
+
+if [ -d %%ETCDIR%% ]; then
+ echo "There are some changed config files left in %%ETCDIR%%."
+ echo "Use 'rm -rf %%ETCDIR%%' to delete them."
+ echo
+fi
+USER=%%MC_USER%%
+
+if pw usershow "${USER}" 2>/dev/null 1>&2; then
+ echo "To delete ${USER} user permanently, use 'rmuser ${USER}'"
+fi
+
+exit 0
+
diff --git a/games/minecraft-server/files/pkg-message.in b/games/minecraft-server/files/pkg-message.in
new file mode 100644
index 000000000000..b7a4f7507a0d
--- /dev/null
+++ b/games/minecraft-server/files/pkg-message.in
@@ -0,0 +1,40 @@
+**************************************************
+Daemon:
+ The user mcserver has been added to your system.
+
+ To run the server automativally with the system
+ add the following line to your /etc/rc.conf:
+
+ minecraft_enable="YES"
+
+ Serverfiles will be in
+ %%PREFIX%%/share/minecraft-server
+
+ Configuration can be done using the config-files
+ or as OP using the Client. Config files are in
+ %%PREFIX%%/etc/minecraft
+
+ If you have trouble starting or stopping the
+ server try to delete an unclean server.log.lck:
+
+ %%PREFIX%%/etc/rc.d/minecraft clean
+
+ If you don't like your generated world it can
+ be deleted (do generate a new one next time
+ the server starts) using:
+
+ %%PREFIX%%/etc/rc.d/minecraft killworld
+
+ You can delete the server.log (so it's not
+ getting to fat) using:
+
+ %%PREFIX%%/etc/rc.d/minecraft clearlog
+
+Unprivileged users:
+ Running a server as unprivilieged user try
+ minecraft-server{-nogui}
+
+ The serverfiles will be in
+ ~/.minecraft-server
+
+**************************************************
diff --git a/games/minecraft-server/files/server.properties.sample b/games/minecraft-server/files/server.properties.sample
new file mode 100644
index 000000000000..f0790739a85a
--- /dev/null
+++ b/games/minecraft-server/files/server.properties.sample
@@ -0,0 +1,24 @@
+#Minecraft server properties
+#Thu Dec 22 00:12:43 CET 2011
+
+#Do NOT change the Levelname or some Scripts will no longer worf for
+#you!
+level-name=world
+
+allow-nether=true
+allow-flight=false
+enable-query=false
+server-port=25565
+enable-rcon=false
+level-seed=
+server-ip=
+white-list=false
+spawn-animals=true
+online-mode=true
+pvp=true
+difficulty=1
+gamemode=0
+max-players=20
+spawn-monsters=true
+view-distance=10
+motd=A FreeBSD Minecraft Server
diff --git a/games/minecraft-server/files/white-list.txt.sample b/games/minecraft-server/files/white-list.txt.sample
new file mode 100644
index 000000000000..130fd21f3522
--- /dev/null
+++ b/games/minecraft-server/files/white-list.txt.sample
@@ -0,0 +1 @@
+# each line one name.
diff --git a/games/minecraft-server/pkg-plist b/games/minecraft-server/pkg-plist
index 90e31b6464ba..254fc71b59d3 100644
--- a/games/minecraft-server/pkg-plist
+++ b/games/minecraft-server/pkg-plist
@@ -1,5 +1,28 @@
+@stopdaemon minecraft
share/minecraft-server/minecraft_server.jar
%%X11%%share/minecraft-server/Bookshelf.png
%%X11%%bin/minecraft-server
bin/minecraft-server-nogui
-@dirrm share/minecraft-server
+@exec mkdir -p %D/etc/minecraft
+@unexec if cmp -s %D/share/minecraft-server/ops.txt.sample %D/etc/minecraft/ops.txt; then rm -f %D/etc/minecraft/ops.txt; fi
+@unexec if cmp -s %D/share/minecraft-server/banned-ips.txt.sample %D/etc/minecraft/banned-ips.txt; then rm -f %D/etc/minecraft/banned-ips.txt; fi
+@unexec if cmp -s %D/share/minecraft-server/banned-players.txt.sample %D/etc/minecraft/banned-players.txt; then rm -f %D/etc/minecraft/banned-players.txt; fi
+@unexec if cmp -s %D/share/minecraft-server/white-list.txt.sample %D/etc/minecraft/white-list.txt; then rm -f %D/etc/minecraft/white-list.txt; fi
+@unexec if cmp -s %D/share/minecraft-server/server.properties.sample %D/etc/minecraft/server.properties; then rm -f %D/etc/minecraft/server.properties; fi
+share/minecraft-server/server.properties
+share/minecraft-server/ops.txt
+share/minecraft-server/white-list.txt
+share/minecraft-server/banned-ips.txt
+share/minecraft-server/banned-players.txt
+share/minecraft-server/server.properties.sample
+@exec if [ ! -f %D/etc/minecraft/server.properties ] ; then cp -p %D/%F %B/server.properties; fi
+share/minecraft-server/ops.txt.sample
+@exec if [ ! -f %D/etc/minecraft/ops.txt ] ; then cp -p %D/%F %B/ops.txt; fi
+share/minecraft-server/white-list.txt.sample
+@exec if [ ! -f %D/etc/minecraft/white-list.txt ] ; then cp -p %D/%F %B/white-list.txt; fi
+share/minecraft-server/banned-ips.txt.sample
+@exec if [ ! -f %D/etc/minecraft/banned-ips.txt ] ; then cp -p %D/%F %B/banned-ips.txt; fi
+share/minecraft-server/banned-players.txt.sample
+@exec if [ ! -f %D/etc/minecraft/banned-players.txt ] ; then cp -p %D/%F %B/banned-players.txt; fi
+@dirrmtry share/minecraft-server
+@dirrmtry etc/minecraft