Date: Fri, 26 Jun 2015 16:22:57 +0000 (UTC) From: Bartek Rutkowski <robak@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r390648 - in head/games/minecraft-server: . files Message-ID: <201506261622.t5QGMvuM028975@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: robak Date: Fri Jun 26 16:22:56 2015 New Revision: 390648 URL: https://svnweb.freebsd.org/changeset/ports/390648 Log: games/minecraft-server: improvements to startup script PR: 200743 Submitted by: Jonathan Price <freebsd@jonathanprice.org> (maintainer) Modified: head/games/minecraft-server/Makefile head/games/minecraft-server/files/minecraft.in Modified: head/games/minecraft-server/Makefile ============================================================================== --- head/games/minecraft-server/Makefile Fri Jun 26 16:21:02 2015 (r390647) +++ head/games/minecraft-server/Makefile Fri Jun 26 16:22:56 2015 (r390648) @@ -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 Modified: head/games/minecraft-server/files/minecraft.in ============================================================================== --- head/games/minecraft-server/files/minecraft.in Fri Jun 26 16:21:02 2015 (r390647) +++ head/games/minecraft-server/files/minecraft.in Fri Jun 26 16:22:56 2015 (r390648) @@ -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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201506261622.t5QGMvuM028975>