Editing
Tutorials/FreeBSD startup script
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Script === <pre> #!/bin/sh # # PROVIDE: minecraft # REQUIRE: LOGIN DAEMON NETWORKING mountcritlocal # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local to enable the minecraft server: # # minecraft_enable="YES" # minecraft_user="<run server as this user>" # minecraft_chdir="<run server in this directory>" # minecraft_path="<path to minecraft_server.jar>" # minecraft_flags="<set as needed>" # # For default setup, create a user named 'minecraft', set its home directory # to /srv/minecraft, and place minecraft_server.jar into /srv/minecraft # # See minecraft_server.jar for flags . /etc/rc.subr name=minecraft rcvar=minecraft_enable load_rc_config ${name} command=/usr/local/bin/screen pidfile=/var/run/minecraft.pid start_cmd="${name}_start" stop_cmd="${name}_stop" status_cmd="${name}_status" : ${minecraft_enable="NO"} : ${minecraft_session="minecraft-session"} : ${minecraft_user="minecraft"} : ${minecraft_chdir="/srv/minecraft"} : ${minecraft_path="/srv/minecraft/minecraft_server.jar"} : ${minecraft_flags="--nogui"} : ${minecraft_args="/usr/local/bin/java -Xmx1024M -Xms1024M \ -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing \ -XX:ParallelGCThreads=4 -XX:+AggressiveOpts \ -jar ${minecraft_path} ${minecraft_flags}"} minecraft_start() { unset "${rc_arg}_cmd" minecraft_flags="-d -m -S ${minecraft_session} ${minecraft_args}" if minecraft_running; then echo "minecraft already running?" else run_rc_command "start" fi } minecraft_stop() { local cmd cmd="${command} -p 0 -S ${minecraft_session} -X eval 'stuff stop\015'" if minecraft_running; then echo "Stopping minecraft." su -m ${minecraft_user} -c "${cmd}" fi } minecraft_status() { if minecraft_running; then echo "minecraft is running." else echo "minecraft is not running." fi } minecraft_running() { local check ses ses="${minecraft_session}" check=`su -m ${minecraft_user} -c "${command} -list" | grep ${ses}` if [ "$check" ]; then return 0 else return 1 fi } run_rc_command "$1" </pre> {{tutorials}} [[Category:Server]] [[zh:教程/FreeBSD启动脚本]]
Summary:
Please note that all contributions to Kiiw may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Kiiw:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information