aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek Rutkowski <robak@FreeBSD.org>2015-06-26 16:22:56 +0000
committerBartek Rutkowski <robak@FreeBSD.org>2015-06-26 16:22:56 +0000
commit8b8e0eed1c8a900d32f084d03aa3215001d4083f (patch)
tree2b074f14f24b104fea9264ee07055cba19af1067
parent184b9df1598cbbd046257c7845b18f49fc1e82d9 (diff)
downloadports-8b8e0eed1c8a900d32f084d03aa3215001d4083f.tar.gz
ports-8b8e0eed1c8a900d32f084d03aa3215001d4083f.zip
Notes
-rw-r--r--games/minecraft-server/Makefile1
-rw-r--r--games/minecraft-server/files/minecraft.in51
2 files changed, 31 insertions, 21 deletions
diff --git a/games/minecraft-server/Makefile b/games/minecraft-server/Makefile
index 2c5805e3e669..07c031d5610b 100644
--- a/games/minecraft-server/Makefile
+++ b/games/minecraft-server/Makefile
@@ -2,6 +2,7 @@
PORTNAME= minecraft-server
PORTVERSION= 1.8.7
+PORTREVISION= 1
CATEGORIES= games java
MASTER_SITES= https://s3.amazonaws.com/Minecraft.Download/versions/${PORTVERSION}/
DISTNAME= minecraft_server.${PORTVERSION}.jar
diff --git a/games/minecraft-server/files/minecraft.in b/games/minecraft-server/files/minecraft.in
index 2bd7806997ea..45a873c25bbd 100644
--- a/games/minecraft-server/files/minecraft.in
+++ b/games/minecraft-server/files/minecraft.in
@@ -20,18 +20,23 @@ load_rc_config $name
minecraft_mem=${minecraft_mem:-"1024M"}
minecraft_args=${minecraft_args:-""}
-extra_commands="console status"
+extra_commands="console status kill"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
console_cmd="${name}_console"
status_cmd="${name}_status"
+kill_cmd="${name}_kill"
-minecraft_start()
+is_running()
{
pgrep -qu mcserver java
- isrunning=$?
- if [ ${isrunning} -eq 0 ]; then
- echo "${name} already running."
+ return $?
+}
+
+minecraft_start()
+{
+ if is_running; then
+ echo "${name} is already running."
else
echo "Starting ${name}."
cd %%PREFIX%%/minecraft-server
@@ -41,36 +46,32 @@ minecraft_start()
minecraft_stop()
{
- pgrep -qu mcserver java
- isrunning=$?
- if [ ${isrunning} -eq 0 ]; then
+ if is_running; then
echo "Stopping ${name}."
su mcserver -c "%%LOCALBASE%%/bin/tmux send-keys -t ${name} \"stop\" ENTER"
i=0
while [ $i -lt 10 ]; do
i=$(($i + 1))
- pgrep -qu mcserver java
- stillrunning=$?
- if [ ${stillrunning} -eq 0 ]; then
+ if is_running; then
sleep 1
else
- echo "${name} stopped."
+ echo "${name} has been stopped."
return
fi
done
- echo "ERROR: ${name} could not be stopped."
+ echo "WARN: ${name} could not be stopped or is taking longer than expected."
+ echo "WARN: To view the console, type 'service ${name} console'"
+ echo "WARN: To kill $[name}, type 'service ${name} kill'"
else
- echo "${name} not running."
+ echo "${name} is not running."
fi
}
minecraft_console()
{
- pgrep -qu mcserver java
- isrunning=$?
- if [ ${isrunning} -ne 0 ]; then
- echo "${name} not running."
+ if ! is_running; then
+ echo "${name} is not running."
else
export TERM=xterm
su mcserver -c "%%LOCALBASE%%/bin/tmux attach-session -t ${name}"
@@ -79,13 +80,21 @@ minecraft_console()
minecraft_status()
{
- pgrep -qu mcserver java
- isrunning=$?
- if [ ${isrunning} -eq 0 ]; then
+ if is_running; then
echo "${name} is running."
else
echo "${name} is not running."
fi
}
+minecraft_kill()
+{
+ if ! is_running; then
+ echo "${name} is not running."
+ else
+ pkill -KILL -u mcserver java
+ echo "${name} has been killed."
+ fi
+}
+
run_rc_command "$1"