superjamie / minecraft-init-script Goto Github PK
View Code? Open in Web Editor NEWAn initscript to start Minecraft or CraftBukkit on CentOS, Fedora, and Ubuntu
License: GNU General Public License v3.0
An initscript to start Minecraft or CraftBukkit on CentOS, Fedora, and Ubuntu
License: GNU General Public License v3.0
I've got a separate script that performs offsite backups to Amazon Web Services S3 on my server. Is this a feature that people want? Would a pull request be looked on favourably?
Hello.
(I'm sorry for my English, I'm french)
Thank you for this script, but it didn't start with Ubuntu. It works with a manual command ("minecraft start").
Have you an Idea ?
Hello guys !
I've got a problem, your Script can't start with my OS (Ubuntu Server 14.04) !
We can see this error in boot.log :
Cannot make directory '/var/run/screen': Permission denied
Google thinks that I use :
sudo /etc/init.d/screen-cleanup start
If I add this line in your Script, it works ! BUT : The Screen doesn't exist !!!
Why ?!?
And if I add : sleep 1, we have the same problem ?
What do you think ? Have you an Idea ?
Thanks.
The script implicitly sleeps for a set amount of time, assuming that time is enough.
A better way would be to sleep in 1-second loops with a bound on the loop, eg:
+ C=0
+ while [ $C -lt 15 ]; do
+ C=$[C+1]
+ echo -n "."
+ if server_running
+ then
+ echo
+ echo " * [OK] $SERVERNAME is now running (pid $JAVAPID)."
+ exit 0
+ else
+ sleep 1
+ fi
+ done
Thanks to Jon Stephens for this idea.
This init script works really nice, except I can't open up the console. I do "minecraft console" and I get in return "Cannot open your terminal '/dev/pts/0' - please check." Is this me or the script?
It also seems to make me type in my password so many times for any command, but that might be my fault.
I cant seem to get the settings file to work. i am running centOS 6 and i copy between the lines and paste it in a new file at /etc/default/minecraft. i run minecraft start and i get these errors:
[root@localhost ~]# minecraft start
: command not foundaft: line 2:
: command not foundaft: line 5:
: command not foundaft: line 8:
: command not foundaft: line 11:
: command not foundaft: line 14:
: command not foundaft: line 17:
: command not foundaft: line 20:
: command not foundaft: line 23:
: command not foundaft: line 26:
: command not foundaft: line 29:
: command not foundaft: line 31:
: command not foundaft: line 34:
: command not foundaft: line 38:
: command not foundaft: line 41:
: command not foundaft: line 44:
: command not foundaft: line 48:
the lines seem to be where ever there is a blank space so i removed the spaces and i get this:
[ERROR] Settings file /etc/default/minecraft is not applying. Can't run!
Check your options are uncommented and you haven't copied the <<COMMENT block.
here is my settings file
As it is mentionned in the title, it would be great to have a multi-server startup script.
Actually copying the script for each server raise the maintenance costs.
Upstream CraftBukkit now rotates and compresses its own logs into logs/latest.log
and logs/YYYY-MM-DD-#.log
so just remove all the logfile handling from the script.
If backup dir does not exist, it should be created.
I am fairly certain the error is from:
if server_running
then
echo " * [OK] $SERVERNAME is now running (pid $JAVAPID)."
else
echo " * [ERROR] Could not start $SERVERNAME.
exit 1
fi
I have gone through it several times and made sure that it is formatted correctly and as far as I can tell it is. The logic seems to be solid as well.
Help, please, if you are still paying attention to this.
Thanks!
how would i change the settings to use MCPC plus instead of craftbukkit?
on centOS 6 i the following error when i run chkconfig --add minecraft.
error reading information on service minecraft: No such device
Hi,
Whenever I use any command(e.g minecraft start) it says this
[ERROR] Settings file /etc/sysconfig/minecraft does not exist. Can't run!
I tried using both root and minecraft user(my user is called minecraft not bukkit)
Centos 6 64BIT
1GB RAM VPS
Hello! This is a fine script.
However.. I would like to find out what is stopping me from starting up the service. When I run service minecraft start I get the following:
* CraftBukkit was not already running. Starting...
* Using map named "world"...
* Checking CraftBukkit is running...
* [ERROR] Could not start CraftBukkit.
Of course that's not very helpful. I can run the .jar file from the command line without any problems, and I have replaced the invocation for a simple one as: java -Xmx1024M -jar craftbukkit.jar -o true
and still no luck :(
Is there any way to get a more verbose output and find out what's going on?
I'm running this on Ubuntu 13.10 with CraftBukkit 1.6.4-R2.
Thanks!
The current default is to keep 7 days of backups. Make this number of days a config option.
The error is Cannot open your terminal '/dev/pts/0' - please check.
I would be great to also support BungeeCord proxy.
It should not be hard, maybe using a flag to tell that you run Bungee to limit some commands.
When an Ubuntu 12.04.4 LTS server starts, the Minecraft server doesn't start automatically.
On shutdown, the following error is printed:
[error] settings file /etc/default/K20minecraft does not exit. Can't run !
Starting and stopping the service manually post-boot works.
This can be worked around by changing:
SETTINGSFILE="/etc/default/$(basename $0)"
to:
SETTINGSFILE="/etc/default/minecraft"
Add in lorenzorota's "minecraft say" support from
Super Jamie, I created a new case statement for the initscript which I thought would be pretty useful for people who are not so familiar with the MC console or just prefer not using it.
So I added this function:
## Broadcasts a message something
mc_say() {
s_string="${@:1}"
if [[ -z "$s_string" ]]
then
echo " * You need to enter your message. Usage; \"minecraft say message\""
elif server_running
then
echo " * Broadcasting \"$s_string\""
as_user "screen -p 0 -S $SCRNAME -X eval 'stuff \"say $s_string\"\015'"
else
failure && echo " * $SERVERNAME was not running!"
exit 1
fi
}
Created this case statement:
say)
mc_say ${@:2}
;;
And well... I also edited the usage display list:
echo " * Usage: minecraft {start|stop|restart|backup|update|status|info|console|say}"
My version may be rather a bit clumsy, but I just wrote it as a small script which would allow me to easily create crontab jobs with adjustable messages such as:
0 0 25 2 * /etc/init.d/minecraft say Today is Lorenzo's Birthday, Let's party and eat some cake WOO!
or even displaying the time every 10 minutes:
*/10 * * * * /etc/init.d/minecraft say The time right now is: $(date +"%r")
When i run my server and to the info command i get in the middle of the info this line:
/etc/init.d/minecraft line 444: [: : integer expression expected
Running CentOS 6.4 min.
Java JDK 1.7.0_45
I get the following errors when calling the script:
[bukkit@localhost ~]$ minecraft start
Currently when users update the script, they have to manually put all their settings in again. This is inconvenient and annoying.
A settings file in /etc/sysconfig/minecraft would be a better solution to this. The settings and script could be separate, and users could update the script without the need to change the settings.
The directory /etc/sysconfig does not exist on ubuntu (observed in 12.04.03 LTS). Maybe a better location would be /etc/minecraft/config ?
I realise this script has been retired. Just thought I'd leave a note for those who come after me and have the same problem.
On RHEL-derived systems at least (don't know about Ubuntu etc.), the init script can fail to start on system boot. The reason is the following line (110)
SETTINGSFILE="/etc/default/$(basename $0)"
On boot, this resolves to something like /etc/default/S85minecraft
, not /etc/default/minecraft
. Since this file doesn't exist, the server doesn't start.
When using multi-map backups, one "removeoldbackups" removes the backups for all maps.
For example, if the backup folder is being used for "creative" and "survival" maps, then one "removeoldbackups" removes the old files for both "createive" and "survival".
Ideally, "removeoldbackups" should just remove its own backups.
Look into how this affects removing old executables as well. We don't want to fill the hard drive with backups of craftbukkit.jar or whatever.
It seems GNU Screen has issues starting during Ubuntu's broken init implementation. Maybe using tmux could work around that just cos it's different?
Plus, screen is old and tmux is new.
I do have a concern that upstream tmux has not stabilised on their command set yet, some config variables did change between v1.6 (EPEL6) and v1.9 (Fedora 20). I assume the supported Ubuntus have similar variety of versions, so I'd need to look into all of those.
Thanks to Jon Stephens for supplying changes for this.
Get this when I do 'minecraft console'
"Cannot open your terminal '/dev/pts/0' - please check
Backup should detect The Nether and The End if they exist.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.