Saturday, November 15, 2014

Ubuntu - Starting Minecraft Server Automagically FAILs

I run a Minecraft server for myself and some close friends. One thing that I struggled with was getting Minecraft to auto-start when the machine booted up. This is important so that if my power is ever interrupted (not on a UPS, yet.....) the computer would auto-restart via the UEFI bios setting which would then auto-start the Minecraft server due to the init script being added to the default system run levels from using sudo update-rc.d defaults. The error within /var/log/boot.log was
Cannot make directory '/var/run/screen': Permission denied

When I googled the error message I found that it's a bug, apparently screen-cleanup is running via upstart much earlier than it expects to have run, and is failing to correctly clean up the /var/run/screen directory. I'm not sure whether this is an acceptable fix or not but I found a solution after much googling and reading. Basically we're not going to rely on the screen-cleanup upstart or init script, we're going to remove that upstart job completely and within our Minecraft init script we'll create the /var/run/screen directory ourselves. I am using this minecraft init script which is right from the Minecraft wiki page and in order to get around this Ubuntu screen bug we need to make a small modification to it. Note that this modification should work for any init script you're using to auto-start your Minecraft server if you have the same screen bug in Ubuntu. The applicable section looks like the following
as_user "cd $MCPATH && screen -h $HISTORY -dmS minecraft $INVOCATION"
sleep 7

And we need to add the commands for making the /var/run/screen directory ourselves so make it look like this
if ! test -d /var/run/screen; then
mkdir /var/run/screen
chown root:utmp /var/run/screen
chmod 775 /var/run/screen
as_user "cd $MCPATH && screen -h $HISTORY -dmS minecraft $INVOCATION"
sleep 7

It's important that after you alter your Minecraft init script you run the following commands to remove it from the various run levels and then re-add it. (I don't know if remove, defaults, and enable are ALL needed but that's what I did.
sudo update-rc.d minecraft remove

sudo update-rc.d minecraft defaults

sudo update-rc.d minecraft enable

Now when the computer starts up from it being off, a screen session will get created and your Minecraft server will get auto-started from within that screen session. You can then ssh into your server as user minecraft and issue
screen -r

and it will reattach you to your Minecraft server console. Hopefully this was helpful for you as I spent many hours trying to figure out why the init script was not working to auto-start the Minecraft server when the machine was turned on. -Ubu out

Saturday, November 1, 2014

Upgrade HELL: iOS 7 (jailbroken) to iOS 8.1 upgrade trouble

I have a 16GB iPhone 5S that had iOS firmware version 7.0.6 which I had jailbroken using Evasi0n. I've been jailbreaking my iPhones since the original untethered jailbreak was released years ago. Skip to the last paragraph if you don't want any back story.

Jailbreaking your iDevice allows additional tweaks and functionality. I had previously upgraded from iOS 6 to iOS 7 using an older computer which has a 1.8Ghz Core2Duo with 2GB of memory. That process went without trouble what so ever and all was well in my world.

Recently the iOS 8.x untethered jailbreak, Pangu, was updated to include the ability to install Cydia during the jailbreak which is a great convenience. Previous to the update, Pangu would only give you root access to the iDevice and you still had to SSH into your device and manually download and install Cydia. Now that the Pangu jailbreak utility included the ability to install Cydia I was ready to upgrade my iPhone 5S to iOS 8.1.

All of the tutorials I found made it clear that before I upgrade my iPhone to iOS 8.1 that I first needed to perform a restore to the iOS firmware 8.1. Simply doing an upgrade either OTA or using iTunes was not going to work, doing it those ways lead to boot loop issues and other unforeseen issues. I connected it to my computer I choose the Restore button and soon my problems began. It was stuck at "Restoring iPhone Software" within iTunes. I let it sit for about 20 minutes and without any change in the progress bar I realized that it was stuck and not doing what it was suppose to be doing.
I jumped on the IRC channel #jailbreak_qa on freenode and they suggested the normal solutions of reinstalling iTunes and the AppleMobileDevice driver so I did those 2 things and it still was getting stuck at the exact same spot. I even attempted to put the iPhone into DFU mode and using shift+restore so that I could choose the IPSW file that I downloaded for my GSM iPhone 5S but again it was getting stuck at the same location. I even tried a different cable and that didn't work either.

The solution was to perform the restore using a better computer. Believe it or not using my main gaming rig which has Windows 7 Ultimate as the OS running an i5-4670k OC'd to 4.0Ghz and 8GB of DDRIII at 2133Mhz the restore worked immediately. I didn't need to use shift+restore either, I did however ensure the iPhone was in DFU mode before clicking the Restore button within iTunes. I can't believe that's how I solved the problem, I had spent countless hours googling and reading various forums and speaking with multiple people in the IRC channel as well. Now that the restore to 8.1 is complete, I will restore my iCloud backup so I get all my contacts and apps back onto the iPhone and once that's done, I will perform the Pangu jailbreak.Hopefully this post saves anyone else who's having an issue upgrading their iDevice to a newer firmware.

-Ubu out