Let me say I've been using this script without issue for two or so months and I absolutely love it... Until yesterday night :tongue.gif:
I (attempting to be the decent novice linux user) let Ubuntu update itself, needless to say when ever I attempt to stop/start a world(s) I get numerous errors all revolving around "Screen"
USER@SYSTEM_NAME:~$ sudo /etc/init.d/minecraft_server stop
Stopping Minecraft Server: 25555write: Broken pipe
No screen session found.
Error sending command to server.
I followed your original installation guide to the letter and it worked wonderfully, I've already attempted to update the script itself from the new(er) one posted at http://goo.gl/BXwen, (wget is wonderful!).
Any assistance / advice is well appreciated!
I'm not sure what the problem is from that message, but I'm guessing that you recently made a change to your worlds.conf file and used spaces instead of a tab between the world name and the port that it is to run on. The script really should be able to support any number of spaces or a tab between the two. I'll make the appropriate changes to the script, expect an update soon.
Edit: The fix is live. Let me know if that doesn't do it for you.
I really love this script, but i also really want to use Bukkit plugins. I have been trying to figure out how to modify it to work with Bukkit on my own for a few days now but my knowledge of shell scripts is extremely limited. I noticed you stated it would be trivial to add support for it, could you do that please??
I really need a way to easily control the server and run the plugins i can only do 1 or the other at this point.
If you don't have the time or inclination at this time maybe you could point me in the right direction as to where to modify the script I thought all i would have to change would be:
SERVER_JAR="$SERVER_LOCATION/minecraft_server.jar"
to:
SERVER_JAR="$SERVER_LOCATION/craftbukkit-0.0.1-SNAPSHOT.jar"
but that doesn't seem to get the job done.
I really love this script, but i also really want to use Bukkit plugins. I have been trying to figure out how to modify it to work with Bukkit on my own for a few days now but my knowledge of shell scripts is extremely limited. I noticed you stated it would be trivial to add support for it, could you do that please??
I really need a way to easily control the server and run the plugins i can only do 1 or the other at this point.
If you don't have the time or inclination at this time maybe you could point me in the right direction as to where to modify the script I thought all i would have to change would be:
SERVER_JAR="$SERVER_LOCATION/minecraft_server.jar"
to:
SERVER_JAR="$SERVER_LOCATION/craftbukkit-0.0.1-SNAPSHOT.jar"
but that doesn't seem to get the job done.
any help at all would be appreciated.
Lee
I was holding out for Notch to introduce a modding API to the server software, but due to a recent post he made, I might just go ahead and build in support for Bukkit. I'll take a closer look at how to actually accomplish this cleanly once this semester is over (my advisor's class is kicking my ass right now).
However, if you replace the following code, it should work (untested). If it doesn't, let me know what the error is.
thanks for the replay and the code. I had basically mode those changes myself. after analyzing the code. but i changed it to exactly your code and I'm still getting a rather odd effect. bukkit runs. because i can connect on the bukkit port. and play. but, none of the bukkit plugins work. I have them all in their plugins folder as I'm supposed to. and if i launch bukkit with it's launch script they work. but if i launch then with your script they won't function. My guess is it's a linux permissions issue. but I have even went so far as to do a recursive chmod 777 to all the files and folders in the minecraft folder. and still no joy.
thanks for the replay and the code. I had basically mode those changes myself. after analyzing the code. but i changed it to exactly your code and I'm still getting a rather odd effect. bukkit runs. because i can connect on the bukkit port. and play. but, none of the bukkit plugins work. I have them all in their plugins folder as I'm supposed to. and if i launch bukkit with it's launch script they work. but if i launch then with your script they won't function. My guess is it's a linux permissions issue. but I have even went so far as to do a recursive chmod 777 to all the files and folders in the minecraft folder. and still no joy.
Any other Ideas would be greatly appreciated.
Lee
My script puts each world that you create into a separate directory (ie. /home/minecraft/worlds/alpha for a world named alpha). Because of this, I assume that each world you run will be able to have a separate set of plugins (which you can probably get around by using symlinks if you so desire). If Bukkit had no problems starting up, and if I understand the documentation correctly, there should be a plugins directory created in the world's directory. If you place your plugins there, I think they should work.
Let me know how this works for you. I'd try it out for myself if I had the time, but I'm a little short on that good stuff right now.
Thanks so much for the help I finally got it to function. I am going to attempt to learn a bit of scripting myself I would love to give the option to update both bukkit and update minecraft from this script as i understand the code the changes we made to get it to run bukkit it will now only update Bukkit. so I have a project in front of me. I'll not ask that of you since you are busy with school. My first priority is to crontab running that will check if the server is running, and if this script is running. if just the server has stopped, restart the server, if this script has stopped restart this script. and have it run every 5 minutes. I have seen a script for doing this with just the minecraft jar. I figure i should be able to figure out something from there.
Thanks so much for the help I finally got it to function. I am going to attempt to learn a bit of scripting myself I would love to give the option to update both bukkit and update minecraft from this script as i understand the code the changes we made to get it to run bukkit it will now only update Bukkit. so I have a project in front of me. I'll not ask that of you since you are busy with school. My first priority is to crontab running that will check if the server is running, and if this script is running. if just the server has stopped, restart the server, if this script has stopped restart this script. and have it run every 5 minutes. I have seen a script for doing this with just the minecraft jar. I figure i should be able to figure out something from there.
Again thanks so much for your help.
Setting it up so that both the vanilla server and Bukkit can coexist as far as the update feature is concerned should be fairly straight forward with the current code. If I was correct on how the plugins work, we would need to decide how to handle them.. One set for all worlds, or separate plugins for each, or perhaps an easy way for the user to flip a boolean at the top of the file to choose what they want. I would be happy to take a look at any patches you make and add them to the script, Bukkit support would be nice to have.
Until 1.5 was released, I have never had a server crash, let alone a crash that left the script still running. With the crashiness that was 1.5 originally, I was able to add in some crash detection to the script that seems to function very well. I can't guarantee that every crash scenario will be caught by this new code, but it's a start.
If you are set on creating a cron job to query the status of the server, you should be able to use the "status" command to see whether the script thinks that a server is running, and if not you can start it. An easier way would be just to send a "start" command to the script every once and a while.. Any world not running at that time will be started, those that are won't see anything happen.
I have just added initial Bukkit support to this script. I'll try to figure out a clean way to handle Bukkit addons in the near future, but for now you should be able to install them into the worlds directory (ie /home/minecraft/worlds/alpha/plugins for a world named alpha).
To enable Bukkit, change the following code in the script:
# Server software to use.
# mcserver - Minecraft server software.
# bukkit - Craft Bukkit server software.
SERVER_TYPE="mcserver"
to
# Server software to use.
# mcserver - Minecraft server software.
# bukkit - Craft Bukkit server software.
SERVER_TYPE="bukkit"
Firstly, thank for putting this easy to use script together. I'm a Linux newbie, but have had no difficulty getting this up-and-running.
I've been working on a web interface so that my friends can manage the server remotely. We currently use VNC to access the box, but I'd like something even more convenient and secure for the server. I've used PHP to run scripts that show the most recent server logs:
The webpage displays the server.log entries, but all chat messages have the username removed. The usernames are correctly displayed in all other parts of the log.
Something I'd like to do but haven't have success in figuring out is getting the .sh scripts to (re)start, stop, and refresh the server to be run via clicking a link in my web console.
When I run the restart script I get the following error:
WARNING: This script appears to have been started by the wrong user.
Restarting Minecraft Server: worldNo screen session found.
Error sending command to server world.
I've checked the file permissions and the webserver user account has read/write permissions, others have permission to read, and it is set to be executable. Any ideas would be appreciated.
Firstly, thank for putting this easy to use script together. I'm a Linux newbie, but have had no difficulty getting this up-and-running.
I've been working on a web interface so that my friends can manage the server remotely. We currently use VNC to access the box, but I'd like something even more convenient and secure for the server. I've used PHP to run scripts that show the most recent server logs:
The webpage displays the server.log entries, but all chat messages have the username removed. The usernames are correctly displayed in all other parts of the log.
Something I'd like to do but haven't have success in figuring out is getting the .sh scripts to (re)start, stop, and refresh the server to be run via clicking a link in my web console.
When I run the restart script I get the following error:
I've checked the file permissions and the webserver user account has read/write permissions, others have permission to read, and it is set to be executable. Any ideas would be appreciated.
I don't know what is wrong with the user names disappearing from the log file, my script is probably not the issue here. The script does parse the log file, but it doesn't make any changes to it. Since you are passing the mimetype text/plain, the browser shouldn't be trying to parse the log file as code. If I get some spare time, I'll try to replicate this issue and report back.
As far as the restart page issue, that actually has to do with some error checking code that I placed in there to report when the script is run from a different user account than that which started up the server. I can't think of an easy way for me to allow this use case in the script off the top of my head, but you can easily work around it by running the web-server and minecraft server from the same useraccount. The username for Apache is www-data, so you can either change the script to use that username, or change Apache to use your minecraft username.
The issue with usernames is that it's try to read them as HTML tags, because of the < and > on either side. I can modify the output with some PHP to compensate.
The user account running the Minecraft server is also running the Apache web server already. However, it was not set to the primary group of "www-data" as you suggested. I don't have it working right, but your suggestion has helped point me in the right direction. I'll keep you posted.
The issue with usernames is that it's try to read them as HTML tags, because of the < and > on either side. I can modify the output with some PHP to compensate.
The user account running the Minecraft server is also running the Apache web server already. However, it was not set to the primary group of "www-data" as you suggested. I don't have it working right, but your suggestion has helped point me in the right direction. I'll keep you posted.
Thanks again!
If you haven't already done so, change the line in the script that looks like:
I'd changed that to my own user account's name, "bob" for example, when I started the server. Changing it to www-data causes other issues with using the system. I'll continue trying to find a solution and working with the group as www-data.
Using a similar script to this (the basic server startup script on the minecraftwiki.net wiki) and having trouble with graceful shutdowns triggered with e.g. shutdown -h now. Has anyone tested this script or the wiki version as properly working in such a scenario?
The server.log seems truncated, without the usual save-all and disabling of plugins etc.. Tried to debug the script - the script *does* get executed when root does shutdown -h now, but the screen and java processes are already killed by the time the 'stop' code is run. Installed with update-rc.d or insserv (the latter seems to be the preferred method now with Debian 6) and the /etc/rcX.d symlinks are definitely created (as I say, the script runs, but too late).
This would imply that the the stop script is set to the incorrect runlevel, or needs to be moved to an earlier state in the shutdown process.
Using a similar script to this (the basic server startup script on the minecraftwiki.net wiki) and having trouble with graceful shutdowns triggered with e.g. shutdown -h now. Has anyone tested this script or the wiki version as properly working in such a scenario?
The server.log seems truncated, without the usual save-all and disabling of plugins etc.. Tried to debug the script - the script *does* get executed when root does shutdown -h now, but the screen and java processes are already killed by the time the 'stop' code is run. Installed with update-rc.d or insserv (the latter seems to be the preferred method now with Debian 6) and the /etc/rcX.d symlinks are definitely created (as I say, the script runs, but too late).
To be honest I am not sure what the issue is. It looks like you know what you are doing, and as far as I can tell the wiki script should work. Debian 'recently' introduced dependency based boot, and I am guessing that may be the source of your problem. If you notice at the top of my script and the wiki script there is a sequence of comments that look like:
#! /bin/sh
### BEGIN INIT INFO
# Provides: minecraft_server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Minecraft Server control script.
# Description: Minecraft Server control script.
You can try replacing that chunk of code from the wiki script with the code above, and run update-rc.d (or whatever) again.
I'm also curious as to whether or not my script is giving you the same issues (it works for me).
I created a duplicate of /etc/inti.d/minecraft_server with the username value set to www-data and name/placed it at /etc/init.d/minecraft_server_www. The scripts are stop, restart, and update. Here's an example:
Restarting Minecraft Server: worldThere are several suitable screens on:
22161.minecraft-world (06/30/11 14:37:31) (Detached)
22014.minecraft-world (06/30/11 14:37:08) (Detached)
Use -S to specify a session.
Error sending command to server world.
No Apache error recorded.
Error from stop (in browser):
Stopping Minecraft Server:
No Apache errors, but also the server is not stopped.
Error from update (in browser):
Updating the Minecraft Server software...
Stopping Minecraft Server: worldNo screen session found.
Error sending command to server world.
Apache's corresponding error:
Timeout waiting for output from CGI script /home/www/cgi-bin/UPDATE.sh, referer: http://myurl
I am confused by what exact is going on. Maybe you have some insight, but perhaps not. I couldn't find the "restart" error text in the /etc/init.d/minecraft_server file at all.
I created a duplicate of /etc/inti.d/minecraft_server with the username value set to www-data and name/placed it at /etc/init.d/minecraft_server_www. The scripts are stop, restart, and update. Here's an example:
Restarting Minecraft Server: worldThere are several suitable screens on:
22161.minecraft-world (06/30/11 14:37:31) (Detached)
22014.minecraft-world (06/30/11 14:37:08) (Detached)
Use -S to specify a session.
Error sending command to server world.
No Apache error recorded.
Error from stop (in browser):
Stopping Minecraft Server:
No Apache errors, but also the server is not stopped.
Error from update (in browser):
Updating the Minecraft Server software...
Stopping Minecraft Server: worldNo screen session found.
Error sending command to server world.
Apache's corresponding error:
Timeout waiting for output from CGI script /home/www/cgi-bin/UPDATE.sh, referer: http://myurl
I am confused by what exact is going on. Maybe you have some insight, but perhaps not. I couldn't find the "restart" error text in the /etc/init.d/minecraft_server file at all.
It looks like the script is unable to determine the process ID (PID) of the Screen session for some reason. Another oddity is that it appears that there are two Screens running for the same world (in this case, your world's name is 'world'). This second screen is definitely causing problems..
I wonder if the www-data user has some restrictions on what it can run..
Since I don't have my server up and running right now, it will be hard for me test this myself, so I'll need you to give me some more info.
First, either restart your server, or kill all screen and java processes
Next, issue a server start command:
sudo /etc/init.d/minecraft_server start
Now, lets switch users to the www-data user:
sudo su www-data
Now lets see what Screen and Java sessions are active. Post the output from these commands:
Stopped the server and I detached all of my java sockets (the two listed earlier) as suggested. I then switched to www-data and ran the commands as requested. My output is like this:
$ sudo su www-data
$ screen -ls
There are screens on:
22161.minecraft-world (06/30/2011 02:37:30 PM) (Detached)
22014.minecraft-world (06/30/2011 02:37:07 PM) (Detached)
2 Sockets in /var/run/screen/S-www-data.
$ ps -a -u www-data -o pid,ppid,comm | grep java
22016 22014 java
22165 22161 java
Stopped the server and I detached all of my java sockets (the two listed earlier) as suggested. I then switched to www-data and ran the commands as requested. My output is like this:
$ sudo su www-data
$ screen -ls
There are screens on:
22161.minecraft-world (06/30/2011 02:37:30 PM) (Detached)
22014.minecraft-world (06/30/2011 02:37:07 PM) (Detached)
2 Sockets in /var/run/screen/S-www-data.
$ ps -a -u www-data -o pid,ppid,comm | grep java
22016 22014 java
22165 22161 java
Ok. So both Screen and Java are starting, and Java knows which Screen it belongs to. This means that my script should be detecting that the server is running, and as such should not be starting multiple copies as it appears to be doing. Besides changing the USER_NAME variable, have you made any other changes to the script?
To be honest I am at a bit of a loss right now.
Can you connect to either screen and see that it is actually running a server process?
I'm not sure what the problem is from that message, but I'm guessing that you recently made a change to your worlds.conf file and used spaces instead of a tab between the world name and the port that it is to run on. The script really should be able to support any number of spaces or a tab between the two. I'll make the appropriate changes to the script, expect an update soon.
Edit: The fix is live. Let me know if that doesn't do it for you.
I really need a way to easily control the server and run the plugins i can only do 1 or the other at this point.
If you don't have the time or inclination at this time maybe you could point me in the right direction as to where to modify the script I thought all i would have to change would be:
SERVER_JAR="$SERVER_LOCATION/minecraft_server.jar"
to:
SERVER_JAR="$SERVER_LOCATION/craftbukkit-0.0.1-SNAPSHOT.jar"
but that doesn't seem to get the job done.
any help at all would be appreciated.
Lee
I was holding out for Notch to introduce a modding API to the server software, but due to a recent post he made, I might just go ahead and build in support for Bukkit. I'll take a closer look at how to actually accomplish this cleanly once this semester is over (my advisor's class is kicking my ass right now).
However, if you replace the following code, it should work (untested). If it doesn't, let me know what the error is.
Replaced with:
Any other Ideas would be greatly appreciated.
Lee
My script puts each world that you create into a separate directory (ie. /home/minecraft/worlds/alpha for a world named alpha). Because of this, I assume that each world you run will be able to have a separate set of plugins (which you can probably get around by using symlinks if you so desire). If Bukkit had no problems starting up, and if I understand the documentation correctly, there should be a plugins directory created in the world's directory. If you place your plugins there, I think they should work.
Let me know how this works for you. I'd try it out for myself if I had the time, but I'm a little short on that good stuff right now.
Again thanks so much for your help.
Setting it up so that both the vanilla server and Bukkit can coexist as far as the update feature is concerned should be fairly straight forward with the current code. If I was correct on how the plugins work, we would need to decide how to handle them.. One set for all worlds, or separate plugins for each, or perhaps an easy way for the user to flip a boolean at the top of the file to choose what they want. I would be happy to take a look at any patches you make and add them to the script, Bukkit support would be nice to have.
Until 1.5 was released, I have never had a server crash, let alone a crash that left the script still running. With the crashiness that was 1.5 originally, I was able to add in some crash detection to the script that seems to function very well. I can't guarantee that every crash scenario will be caught by this new code, but it's a start.
If you are set on creating a cron job to query the status of the server, you should be able to use the "status" command to see whether the script thinks that a server is running, and if not you can start it. An easier way would be just to send a "start" command to the script every once and a while.. Any world not running at that time will be started, those that are won't see anything happen.
To enable Bukkit, change the following code in the script:
to
I've been working on a web interface so that my friends can manage the server remotely. We currently use VNC to access the box, but I'd like something even more convenient and secure for the server. I've used PHP to run scripts that show the most recent server logs:
The webpage displays the server.log entries, but all chat messages have the username removed. The usernames are correctly displayed in all other parts of the log.
Something I'd like to do but haven't have success in figuring out is getting the .sh scripts to (re)start, stop, and refresh the server to be run via clicking a link in my web console.
When I run the restart script I get the following error:
I've checked the file permissions and the webserver user account has read/write permissions, others have permission to read, and it is set to be executable. Any ideas would be appreciated.
I don't know what is wrong with the user names disappearing from the log file, my script is probably not the issue here. The script does parse the log file, but it doesn't make any changes to it. Since you are passing the mimetype text/plain, the browser shouldn't be trying to parse the log file as code. If I get some spare time, I'll try to replicate this issue and report back.
As far as the restart page issue, that actually has to do with some error checking code that I placed in there to report when the script is run from a different user account than that which started up the server. I can't think of an easy way for me to allow this use case in the script off the top of my head, but you can easily work around it by running the web-server and minecraft server from the same useraccount. The username for Apache is www-data, so you can either change the script to use that username, or change Apache to use your minecraft username.
Let me know if that doesn't fix your problem
The user account running the Minecraft server is also running the Apache web server already. However, it was not set to the primary group of "www-data" as you suggested. I don't have it working right, but your suggestion has helped point me in the right direction. I'll keep you posted.
Thanks again!
If you haven't already done so, change the line in the script that looks like:
to
This would imply that the the stop script is set to the incorrect runlevel, or needs to be moved to an earlier state in the shutdown process.
Lulz
To be honest I am not sure what the issue is. It looks like you know what you are doing, and as far as I can tell the wiki script should work. Debian 'recently' introduced dependency based boot, and I am guessing that may be the source of your problem. If you notice at the top of my script and the wiki script there is a sequence of comments that look like:
You can try replacing that chunk of code from the wiki script with the code above, and run update-rc.d (or whatever) again.
I'm also curious as to whether or not my script is giving you the same issues (it works for me).
Error from restart (in browser):
No Apache error recorded.
Error from stop (in browser):
No Apache errors, but also the server is not stopped.
Error from update (in browser):
Apache's corresponding error:
I am confused by what exact is going on. Maybe you have some insight, but perhaps not. I couldn't find the "restart" error text in the /etc/init.d/minecraft_server file at all.
It looks like the script is unable to determine the process ID (PID) of the Screen session for some reason. Another oddity is that it appears that there are two Screens running for the same world (in this case, your world's name is 'world'). This second screen is definitely causing problems..
I wonder if the www-data user has some restrictions on what it can run..
Since I don't have my server up and running right now, it will be hard for me test this myself, so I'll need you to give me some more info.
First, either restart your server, or kill all screen and java processes
Next, issue a server start command:
Now, lets switch users to the www-data user:
Now lets see what Screen and Java sessions are active. Post the output from these commands:
You should get something like this:
Ok. So both Screen and Java are starting, and Java knows which Screen it belongs to. This means that my script should be detecting that the server is running, and as such should not be starting multiple copies as it appears to be doing. Besides changing the USER_NAME variable, have you made any other changes to the script?
To be honest I am at a bit of a loss right now.
Can you connect to either screen and see that it is actually running a server process?