I was appending the time of backup creation to the filename, which the script you linked does not do. I removed the time from the filename in my script, and added a counter do deal with the multiple backups in the same day issue. Let me know if this fix doesn't work for you.
This is a great shell script, it literally has everything one could need. I only wish i found it before i had shell scripts for about half of things listed already made :tongue.gif:
Is there anyway you could create or separate existing parts of the shell script and just make a shell script that basically stops the server and then restarts it? Then one could easily crontab the shell script to execute every X hours and your server would stop and restart every X hours.
I tried making the above from your script to no success. I've only recently started using Ubuntu and learning about shell scripts so your help would be greatly appreciated.
Rollback Post to RevisionRollBack
More than two and a half years of experience running minecraft servers. Check us out at cnation.net and cnation.net/pvp.
This is a great shell script, it literally has everything one could need. I only wish i found it before i had shell scripts for about half of things listed already made :tongue.gif:
Is there anyway you could create or separate existing parts of the shell script and just make a shell script that basically stops the server and then restarts it? Then one could easily crontab the shell script to execute every X hours and your server would stop and restart every X hours.
I tried making the above from your script to no success. I've only recently started using Ubuntu and learning about shell scripts so your help would be greatly appreciated.
I'd rather not break the functionality of this script into multiple scripts, each part is somewhat dependent on other parts. You could easily just tell cron to execute the script as is with the 'restart' option every X hours to restart the MC server. Or, if you have the script installed as suggested, you could just have cron execute a
'shutdown -r now'. Either way should work fine.
Thanks for the update.
Very useful. :smile.gif:
I have been tearing my hair out wondering why Dropbox was not synching my backups to my other server - It must have been because the other server has an ntfs file system. Doh!
A slight issue, really no biggie at all - if you already have tail running when you first start the script it will throw a PID error. Just a headsup. Easily sorted by temporarily stopping the running tail and then re-starting it after running the mcserver script.
Thanks again.
dM
I'm not sure what is going on with tail, as far as I know that shouldn't be happening. I'll look into this, but I might need more info to figure out what is going on.
Running an almost minimal Slackware 13.1 with xfce.
I can' perfectly duplicate the situation without re-starting my currently running server, but to give you more complete information:
I have a few terminals open monitoring the server - one with top, one with iptraf, and a terminal running:
watch tail server.log
It was this process that needed to be stopped before I could run the new script without throwing a PID error when running the script.
Once I stop that watch tail job, then run the script then after that I can re-start my watch tail server.log and I never get the PID error again.
Ahh, that makes a bit more sense. I had assumed that it was a tail process started by the script that was interfering with tail. Let me look into this, I should be able to reproduce this with the info you provided.
Quote from deMangler »
Just as an aside (sorry but this needs to be said) - it is a joy to work with good code. A real relief (I come across a lot of bad code I have to work with) Your script is a breath of fresh air.
I'm really happy that you like it. I personally abhor code that is hard to read, and as such is hard to maintain (old Fortran 66 code with GOTO lines everywhere is a scary project to be handed). If there is any part of the script that you feel needs to be better documented or simplified, I am up to suggestions. I want this script to be simple to use and maintain.
Played with multiple worlds today and ran into a fringe use-case that I wasn't sure how to handle. Is there a way to comment out worlds in the worlds.conf file? It didn't appear that there was....
Played with multiple worlds today and ran into a fringe use-case that I wasn't sure how to handle. Is there a way to comment out worlds in the worlds.conf file? It didn't appear that there was....
I've added some very simple logic to allow comments in the worlds.conf file. Basically, if the line includes a pound symbol (#), that line will get ignored. This logic could probably be smarter and require the pound symbol to be the first non-space character on the line or ignore anything after a pound symbol on a line, but whats there will do the trick.
However I suggest that the output during the update sequence would be improved by adding a printf message saying "Backing up world" or somesuch.
As it stands backing up the world can take a long time and the "Stopping Minecraft Server:" seems to hang there for ages while all this is going on.
Fixed. I'm not sure why I didn't announce the backup in this case.
Quote from deMangler »
I have a suggestion for a feature I would find very useful.
Now that the script detects user logins how about getting it to tell a welcome message to the user just logged in?
I find that the first thing most new users do when they log in is ask the same questions and try the same non-functioning commands, so It would be great to just be able to inform them of the websites FAQ page as soon as they log in.
Just an idea anyway.
Good idea! Done. Add your MOTD to /home/minecraft/motd.txt, and it will get whispered to users as they login.
youre a braver man than I to script in Bash. I made one myself, then found myself losing inordinate amounts of time trying to get anything accomplished that might have been even rudimentary. Bash is tough stuff, cheers!
Running an almost minimal Slackware 13.1 with xfce.
I can' perfectly duplicate the situation without re-starting my currently running server, but to give you more complete information:
I have a few terminals open monitoring the server - one with top, one with iptraf, and a terminal running:
watch tail server.log
It was this process that needed to be stopped before I could run the new script without throwing a PID error when running the script.
Once I stop that watch tail job, then run the script then after that I can re-start my watch tail server.log and I never get the PID error again.
Maybe it was just a one-off for some reason. I will try to duplicate it at the next opportunity and let you know.
Just as an aside (sorry but this needs to be said) - it is a joy to work with good code. A real relief (I come across a lot of bad code I have to work with) Your script is a breath of fresh air.
dM
<edit>
Easy to reproduce - just issue the start or restart script commands with a watch tail job running and I get a tail: : invalid PID error.
<edit>
Sorry I haven't gotten to this yet. What exactly are you watching the server.log file for? I checked out the man pages for tail, and I was unable to find a way to deal with this PID error cleanly. I can hack around this if necessary by having the script track tail's PID rather than having tail track the server's PID. However, if I expand the log processing of the script we might be able to work around this problem instead, by allowing you to watch a different file generated by the script. Separating user chat and command usage into different files should be a minor change to the current code.
ps: Don't consider me an authority by any means with shell scripting. Besides a few five-or-so-liners over the past few years, this is my first real script. I taught myself the language by using the dash manpage, and hitting Google up for any questions. The problem with asking Google is that the majority of the advice out there uses bashisms, something that I have wanted to avoid with this script. The dash manpage has really been the answer to the majority of my questions, and is succinct enough to make finding the answers easy.
Is anyone successfully using the libnotify switch? I've got it set to 1 but haven't seen any popups, and there's nothing in the notify-osd log....
The logged in users are getting written to the .users files, so the parsing isn't the problem. Is anyone else having an issue?
I have not tested that code, so I'm not surprised that you are having problems with it. When I added the MOTD the other day, I noticed that libnotify was probably getting garbled input so I fixed it. I don't suppose you are running the latest version are you? My server actually has a desktop environment installed, so I can test this code. If I get the time tonight I'll take my laptop into the server room and see if I can't get this working correctly.
I'm using the Feb 1st update, and it has the MOTD part in it for sure.
You can check ~/.cache/notify-osd.log for testing without needing to actually see if the popup fires (hopefully saving you a trip?). Please don't hassle yourself to fix this...it's totally non-critical.
I tried to think of a way to debug this myself, but couldn't come up with anything productive.
I get the libnotify popups fine. I am using xfce under slackware 13.1.
On occasion libnotify will crash. This is unrelated to this script I think - but it may be why you are not getting popups.
dM
Hmm. That's interesting. I'm also running xfce (xubuntu, but I compiled 4.8 recently), and I get popups from other apps consistently (sometimes during the time I should be getting them from the server log). I can't think of a time I've missed a popup from another program, and I definitely haven't ever gotten one from the server, so I don't think that's the issue. I guess it's helpful to know it's something on my system, though. I'll try to dig further....
Hmm. That's interesting. I'm also running xfce (xubuntu, but I compiled 4.8 recently), and I get popups from other apps consistently (sometimes during the time I should be getting them from the server log). I can't think of a time I've missed a popup from another program, and I definitely haven't ever gotten one from the server, so I don't think that's the issue. I guess it's helpful to know it's something on my system, though. I'll try to dig further....
I think I found and fixed the problem. Since the script runs as a daemon, it needs to know a little bit about the user environment to send messages to it: the user name and display. I added these variables to the top of the script so that you can easily change them to match your system.
Let me know if this works for you. It worked for me on one of my two test systems (the other one is misconfigured I think).
I think I found and fixed the problem. Since the script runs as a daemon, it needs to know a little bit about the user environment to send messages to it: the user name and display. I added these variables to the top of the script so that you can easily change them to match your system.
Let me know if this works for you. It worked for me on one of my two test systems (the other one is misconfigured I think).
I hard-coded my username into that setting and it works! Will confirm later if the display part was the larger issue by seeing if the "minecraft" user will also let it display...
How would I set up default plugins, users, and world properties?
The intent is to set up several worlds for the same users using identical world properties (except for world specifics).
Thanks for the script that this noob home lan server admin is using.
The only "plugin" that the script currently supports is c10t, a mapping program, and it will be downloaded and installed by default if you try to run it through the script (/etc/init.d/minecraft_server c10t). It would be relatively trivial to add in support for Bukkit and its array of plugins, but I run a plain server so I haven't felt the need to go there yet.
The default server currently has no support for either a user whitelist or a blacklist, although according to a recent post by Notch, we should be getting a whitelist soon. If it makes sense to include support in the script for this new feature I will. I guess what I'm trying to say is that there isn't much you can do to modify the user config currently.
The way this script handles running multiple worlds is by keeping them in separate directories in /home/minecraft/worlds. To configure which worlds are managed by the script, I have added an extra configuration file in /home/minecraft/worlds.conf. If you add the world name and the port that the world will run on into that file, the script will create the necessary configuration for you. To modify the server.properties file (or any other world specific config file), you can find it in /home/minecraft/worlds/<world name>.
I hope I answered your questions. If you get stuck anywhere, let me know and I can try to help.
ps: All directory and filenames mentioned are assuming you are using an unmodified script, and that you followed the installation instructions in the first post.
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!).
I was appending the time of backup creation to the filename, which the script you linked does not do. I removed the time from the filename in my script, and added a counter do deal with the multiple backups in the same day issue. Let me know if this fix doesn't work for you.
Well done. And thank you so much for taking the time to edit it for me.
Cheers Dude!
d.
Is there anyway you could create or separate existing parts of the shell script and just make a shell script that basically stops the server and then restarts it? Then one could easily crontab the shell script to execute every X hours and your server would stop and restart every X hours.
I tried making the above from your script to no success. I've only recently started using Ubuntu and learning about shell scripts so your help would be greatly appreciated.
I'd rather not break the functionality of this script into multiple scripts, each part is somewhat dependent on other parts. You could easily just tell cron to execute the script as is with the 'restart' option every X hours to restart the MC server. Or, if you have the script installed as suggested, you could just have cron execute a
'shutdown -r now'. Either way should work fine.
I'm not sure what is going on with tail, as far as I know that shouldn't be happening. I'll look into this, but I might need more info to figure out what is going on.
Ahh, that makes a bit more sense. I had assumed that it was a tail process started by the script that was interfering with tail. Let me look into this, I should be able to reproduce this with the info you provided.
I'm really happy that you like it. I personally abhor code that is hard to read, and as such is hard to maintain (old Fortran 66 code with GOTO lines everywhere is a scary project to be handed). If there is any part of the script that you feel needs to be better documented or simplified, I am up to suggestions. I want this script to be simple to use and maintain.
I've added some very simple logic to allow comments in the worlds.conf file. Basically, if the line includes a pound symbol (#), that line will get ignored. This logic could probably be smarter and require the pound symbol to be the first non-space character on the line or ignore anything after a pound symbol on a line, but whats there will do the trick.
Fixed. I'm not sure why I didn't announce the backup in this case.
Good idea! Done. Add your MOTD to /home/minecraft/motd.txt, and it will get whispered to users as they login.
Sorry I haven't gotten to this yet. What exactly are you watching the server.log file for? I checked out the man pages for tail, and I was unable to find a way to deal with this PID error cleanly. I can hack around this if necessary by having the script track tail's PID rather than having tail track the server's PID. However, if I expand the log processing of the script we might be able to work around this problem instead, by allowing you to watch a different file generated by the script. Separating user chat and command usage into different files should be a minor change to the current code.
ps: Don't consider me an authority by any means with shell scripting. Besides a few five-or-so-liners over the past few years, this is my first real script. I taught myself the language by using the dash manpage, and hitting Google up for any questions. The problem with asking Google is that the majority of the advice out there uses bashisms, something that I have wanted to avoid with this script. The dash manpage has really been the answer to the majority of my questions, and is succinct enough to make finding the answers easy.
The logged in users are getting written to the .users files, so the parsing isn't the problem. Is anyone else having an issue?
I have not tested that code, so I'm not surprised that you are having problems with it. When I added the MOTD the other day, I noticed that libnotify was probably getting garbled input so I fixed it. I don't suppose you are running the latest version are you? My server actually has a desktop environment installed, so I can test this code. If I get the time tonight I'll take my laptop into the server room and see if I can't get this working correctly.
You can check ~/.cache/notify-osd.log for testing without needing to actually see if the popup fires (hopefully saving you a trip?). Please don't hassle yourself to fix this...it's totally non-critical.
I tried to think of a way to debug this myself, but couldn't come up with anything productive.
Hmm. That's interesting. I'm also running xfce (xubuntu, but I compiled 4.8 recently), and I get popups from other apps consistently (sometimes during the time I should be getting them from the server log). I can't think of a time I've missed a popup from another program, and I definitely haven't ever gotten one from the server, so I don't think that's the issue. I guess it's helpful to know it's something on my system, though. I'll try to dig further....
I think I found and fixed the problem. Since the script runs as a daemon, it needs to know a little bit about the user environment to send messages to it: the user name and display. I added these variables to the top of the script so that you can easily change them to match your system.
Let me know if this works for you. It worked for me on one of my two test systems (the other one is misconfigured I think).
I hard-coded my username into that setting and it works! Will confirm later if the display part was the larger issue by seeing if the "minecraft" user will also let it display...
Thanks again!
The intent is to set up several worlds for the same users using identical world properties (except for world specifics).
Thanks for the script that this noob home lan server admin is using.
The only "plugin" that the script currently supports is c10t, a mapping program, and it will be downloaded and installed by default if you try to run it through the script (/etc/init.d/minecraft_server c10t). It would be relatively trivial to add in support for Bukkit and its array of plugins, but I run a plain server so I haven't felt the need to go there yet.
The default server currently has no support for either a user whitelist or a blacklist, although according to a recent post by Notch, we should be getting a whitelist soon. If it makes sense to include support in the script for this new feature I will. I guess what I'm trying to say is that there isn't much you can do to modify the user config currently.
The way this script handles running multiple worlds is by keeping them in separate directories in /home/minecraft/worlds. To configure which worlds are managed by the script, I have added an extra configuration file in /home/minecraft/worlds.conf. If you add the world name and the port that the world will run on into that file, the script will create the necessary configuration for you. To modify the server.properties file (or any other world specific config file), you can find it in /home/minecraft/worlds/<world name>.
I hope I answered your questions. If you get stuck anywhere, let me know and I can try to help.
ps: All directory and filenames mentioned are assuming you are using an unmodified script, and that you followed the installation instructions in the first post.
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"
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!