警告
因為這是Wiki的一個條目,可以在任何時間內被任何人編輯,因此建議你不要完全使用這個腳本,而是將其當作編寫腳本的指導手冊看待。
安裝
- Install screen
$ pkg_add -vi screen
or
$ sudo apt-get install screen
- Install openJDK
$ pkg_add -vi jdk
or
$ sudo apt-get install openjdk-7-jre
- Add a user to your system for starting/running Minecraft (nologin user is probably best)
- Download the Minecraft server jar and place it somewhere on your system (e.g. /var/games/minecraft)
- Set the 'minecraft' user, created above, as the owner of your destination directory
$ sudo chown -R minecraft:minecraft /var/games/minecraft
Startup Script
- create a new startup script, in `/etc/rc.d` named `minecraft`
- place the following within the script, set it as executable, and ensure the permissions match the other scripts.
#!/bin/sh
minecraft_session="minecraft_session"
minecraft_args="/usr/local/jdk-1.7.0/bin/java -Xms1536M -Xmx1536M -jar /var/games/minecraft/minecraft_server.jar nogui"
daemon="/usr/local/bin/screen"
daemon_user="minecraft"
daemon_flags="-d -m -S ${minecraft_session} ${minecraft_args}"
. /etc/rc.d/rc.subr
rc_reload=NO
rc_check() {
pkill -0 -f "/usr/local/bin/SCREEN ${daemon_flags}"
}
rc_stop() {
${rcexec} "${daemon} -p 0 -S ${minecraft_session} -X eval 'stuff stop\015'"
}
rc_cmd $1
- edit `/etc/rc.conf.local` and add `minecraft` to your `pkg_scripts`
# rc.d(8) packages scripts # started in the specified order and stopped in reverse order pkg_scripts="minecraft"
At this point you should be able to start/stop, and have it auto-load on boot, minecraft.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||