Talk:Tutorials/Server startup script

Is the server updater working for anyone? I remember trying it a couple of times and it not working. Nosrepa 08:20, 19 May 2011 (UTC) ~

Confirmed, it doesn't work "as is".

I made the following tweaks : mc_update { if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null then echo "$SERVICE is running! Will not start update." else MC_SERVER_URL=http://www.minecraft.net/download/minecraft_server.jar as_user "cd $MCPATH && wget -q -O $MCPATH/minecraft_server.jar.update $MC_SERVER_URL --no-check-certificate" if [ -f $MCPATH/minecraft_server.jar.update ] then if `diff $MCPATH/$SERVICE $MCPATH/minecraft_server.jar.update >/dev/null` then echo "You are already running the latest version of $SERVICE." else as_user "cp $MCPATH/minecraft_server.jar.update $MCPATH/$SERVICE" echo "Minecraft successfully updated." fi   else echo "Minecraft update could not be downloaded." fi   as_user "rm $MCPATH/minecraft_server.jar.update" fi } Modifications : SeigneurAo 13:09, 6 September 2011 (UTC)
 * deletion of the "v=" attribute in the URL, which is basically useless
 * addition of the -no-check-certificate switch for wget, since some servers (mine, for instance) don't handle Amazon's SSL certificate
 * removal of minecraft_server.jar.update afterwards, whatever the update did

Anyone have any experience setting this script up? I'm having trouble getting it to work on a Linode running Ubuntu 10.4.

The problem seems to be sending a command to screen. Even if I create the screen first, then detach it, I can't send a command to it. The only way to start the server is to attach to the screen and run the command from there, then detach to get back to my main session.

I can still send commands to the screen after the server is running, though. It's really odd. Any input on this would be great, and I can provide any additional info as well.

Thanks

You're encountering this bug: http://savannah.gnu.org/bugs/?25813 If you compile a version of screen from head it should work. Riff Zifnab 21:16, 28 May 2011 (UTC)

Works fine for me. Only problem is that it only takes 6 backups total per day and then stops working. --Barely 22:33, 26 April 2011 (UTC)

Untested, but it appears the reason why it only allows 6 backups is becasue of for i in 1 2 3 4 5 6 When the code sees the "world_YYYYMMDD-#"backup with the same date and a trailing 6, it continues through the for loop. Since the for loop only goes up to 6, the for loop is over at that point, so nothing is done.

A better (not the best) way to do this is to figure out how many backups you plan on running in a day ( every 30 minutes would be 24 per day). Replace the above text with... for i in $(seq 24) There are two occurrences in the script. Again, this is untested, so backup your script! --Ischwarz3 20:17, 27 April 2011 (UTC)

---

Thanks for the reply. I looked into the script myself without checking here, and figured I would take about 50 backups per day. I actually changed that line to this:

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

It works fine now. It doesn't stop at 6 backups a day like before, and I'm in the 20s already so it seems to work. It doesn't backup the jar though, but I could care less about the .jar. I could live with taking just one a day, in my opinion the jar backup isn't needed.

I'm sure there's a better way to do that :P However I don't really know too much about bash, let alone unix coding. Also, backups every 30 minutes would be 48 backups, not 24. ;)

I'm going to setup a cronjob to tar all of the backups for the day into one file. This will make archiving easier, because each backup is ~20 MBs. The only problem is deleting the old, untarred backups. I'd probably run the script at midnight. (well, 2 minutes after. Backups are on the hour, every hour now.)

Thanks!

--Barely 02:51, 28 April 2011 (UTC)

---

I've been working on my modified backup script. It uses rsync and an efficient method rotation. I will explain how it works if you are interested.

mc_backup { echo "Backing up minecraft world" date=`date "+%Y-%m-%dT%H:%M:%S"` as_user "rsync -aP --link-dest=$BACKUPPATH/current $MCPATH $BACKUPPATH/back-$date" as_user "rm -f $BACKUPPATH/current" as_user "ln -s $BACKUPPATH/back-$date $BACKUPPATH/current" echo "Backup complete"

#backup rotation toKeep=200 everyN=4 toDelete=$(($toKeep/10)) if (( `ls -1 $BACKUPPATH | wc -l` > $toKeep)); then let count=0 for folder in `ls $BACKUPPATH` ; do     let count=$count+1 if (( $count < $((toDelete*everyN)) )) ; then let modulus=$count%$everyN if [ $modulus -eq 2 ] ; then rm -r $BACKUPPATH/$folder echo $folder fi     fi    done fi }

--Chrisbay90 10:38, 4 July 2011 (UTC)

Graceful shutdown
Has anyone tested this script in an external shutdown situation, where gracefully stopping the minecraft server is crucial?

In my testing, the script appears to run on e.g. 'shutdown -h now', but by the time that happens, the screen and java processes have already been killed. Using Debian 6 so installed it with 'insserv minecraft' which seems to be the preferred method now, as opposed to update-rc.d. In /etc/rc0.d for example, there's a K01minecraft symlink, which comes before K02sendsigs, so all seems right?

Really nifty script works perfectly for me. One thing that bothers me is that when I try to send commands to the screen session the same way this script does I get a permission denied. I've turned on correct settings in .screenrc. addacl www-data multiuser on I can -r into the session as the www-data user but sending commands seems to be another story. Googling on the subject gives some results on people asking the same question as me. So I was thinking maybe someone from the source of the script might be interfacing with minecraft from the webserver. --Husse 08:59, 20 June 2011 (UTC)


 * Sorry - I know it comes late, but I'm working on that too (atm). Try this tutorial (works for almost everything you can do to the machine, with slightly changes): -- M3tal_Warrior -- 20:12, 15 January 2012 (UTC)

Licensing of this script?
In reviewing Marco Ceppi's Minecraft server charm here:

https://bugs.launchpad.net/charm/+bug/857654

It struck me that it is quite unclear what the copyright status or the license for using this script is.

If one goes only by the information one can find on this page, I believe the script's copyright is still in the hands of the original submitter User:Hount, but that Curse has unlimited use of it:

http://www.curse.com/legacycontent/curse-network-terms-of-service

States that *Curse* is granted a license to use it for basically whatever they want. But it would seem that the copyrights still remain in the hands of the original submitter. Since the submitter did not grant anyone else a license, its unclear what the license of the script is for anyone who is not Curse. There is the standard boiler plate CC-BY-NC-SA license attached to all wiki pages, but thats just Curse stating what the license is. The terms of service isn't clear if they have the right to re-license the user submissions, they just have rights to:

"use, reproduce, distribute, display, perform, make derivative works of (except with regard to Submitted Projects), transmit or otherwise utilize such User Submissions on Curse Websites (or its successors and affiliates)."

So I don't believe they actually have been granted the right to assign the CC-BY-NC-SA license to Hount's submission.

So, it would seem to me that this script needs a clear attribution of Copyright, and License, added to its header. Until then, at the very least, I would be wary about using this script for any commercial purposes.


 * I don't think there are copyright problems with such a script, since it's not really a hard-to-get. If you like I'll replace it with my initscript, it changed the original almost in every respect (and added quite a few features), and I don't care about copyright... -- M3tal_Warrior -- 20:15, 15 January 2012 (UTC)
 * Update: See User:M3tal_Warrior/Server_Startup_Script for my script. There is (though it is mentioned in the disclaimer) almost nothing left of the original script, just the head. -- M3tal_Warrior -- 23:06, 19 January 2012 (UTC)

Even though there's not much left of the original script you've could at least get my name correctly. Hount, not Hound. I don't know how licencing works, and do I even have control to this anymore as no licenses were present at my first submission. If it's up to me (and if I can make such statement at this point) then my original submission is licenced with Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0.html. Hount 08:30, 2 October 2012 (UTC)
 * Update from the original author: