Getting a headless connection to a server

I just learnt how to get a headless connection to a server before it has even booted. This gives access to LUKS and LVM, giving the oppurtunity to decrypt an encrypted hard drive. The solution was in this blog post. I also found a post about this on Stack Exchange, which I decided to contribute to. For my own later reference, I’ll repost the walkthrough here.

—-

I have summarized what you need to do in the following. For more details, have a look at the post above:

  1. Install BusyBox and Dropbear on your server
    sudo apt-get install dropbear busybox 
  2. Update your initramfs on the server
    sudo update-initramfs -u 
  3. Copy the private key generated by dropbear to your client machine. You may have to copy this to a new dir and change ownership to do this. On your server do the following:
    sudo cp /etc/initramfs-tools/root/.ssh/id_rsa ~/. sudo chown user:user ~/id_rsa 

    Remember to replace user with your username. Password logins don’t seem to work.

  4. Now you may transfer the private key with scp by calling the following on your client:
    scp user@remote.server:~/id_rsa ~/.ssh/id_rsa_dropbear 
  5. Set up your client‘s ~/.ssh/config file for easy login. Open it up with a text editor and add the following:
    Host myremoteserver
    HostName my.remote.server
    User root
    UserKnownHostsFile ~/.ssh/known_hosts.initramfs
    IdentityFile ~/.ssh/id_rsa_dropbear

    Change the Host to whatever you like and HostName to the name of your server. Let the user be root. It appears to be the only accepted user in Dropbear. Save and close the file.

  6. Restart your server and wait for the passphrase prompt. Give Dropbear a few seconds to detect and set up its internet connection. Connect to your server with the following command on your client:
    ssh myremoteserver # or any name you chose 
  7. When logged in, issue the following command on your server. See the blog post for details:
    pid=`ps | grep "/scripts/local-top/cryptroot" | cut -d " " -f 3`;
    kill -9 $pid; sleep 35; /scripts/local-top/cryptroot;
    pid=`ps | grep "/bin/sh" | cut -d " " -f 3`;
    kill -9 $pid;

    It will take some time (30 seconds) before you get to type your passphrase. Type it in when prompted.

  8. Close the connection by typing
    exit 
  9. Your server should now have unlocked its encrypted hard drive and boot as normal.

(A huge thanks to the original author of the blog post!)

—-

Posted in Ubuntu | Tagged , , , , , , , | 1 Comment

Thunderbird with Lightning on Ubuntu

I’m trying out Thunderbird with Lightning as my calendar application, but for some reason Lightning did not show up under Add-ons in Thunderbird. Instead I installed it by using the xul-ext-lightning package. However, this ended up with all options in Lightning grayed out. To fix this I had to install the libstdc++5 package as well, as reported in this forum thread.

This is strange, since it worked fine on a laptop i tried to install Lighting on just a few days ago. But in any case, it works now, so if you want Thunderbird with Lightning on Ubuntu and are having trouble installing it, you might want to try this command in a terminal:

sudo apt-get install thunderbird xul-ext-lightning libstdc++5

That should do the trick.

Posted in Ubuntu | Tagged , , , , , , , , | Leave a comment

Nanoparticles available for Android and Mac OS X


As mentioned in the post about Nanoparticles for Android being just around the corner, I have been able to port Nanoparticles by using the Qt port for Android enabled by the Necessitas project.

That’s why you can download Nanoparticles from Android market right now:

Download Nanoparticles from Android Market

In addition, I have been working on a Mac OS X port. This is still somewhat in an early stage, but should work on most machines. You can download the Mac OS X port for free here.

Both these version include the new party mode with new particles and new game rules. This should give you many more hours of fun particle-based gameplay.

Posted in C++, Games, Programming, Qt | 4 Comments

Deploy Qt applications for Mac OS X

This turned out to be really simple. I was trying to create a Mac OS X version of my game, Nanoparticles, and was having trouble with some flicker when running a QGraphicsView with OpenGL. The solution turned out to simply be to disable some style sheet settings that I didn’t need.

After this I wanted to create a nice .dmg file for easy deployment on Mac OS X. Thankfully, this process is not hard either. I found this through the Qt Documentation, but it is actually simpler than it seems thanks to the macdeployqt tool. This is mentioned on the page, but I decided to give a more thorough walk through on how to use the tool here:

  1. Build your application
  2. In the build directory, run
    macdeployqt yourappname.app -dmg

    macdeployqt is found in the ~/Library/QtSDK/Desktop/Qt/474/gcc/bin folder (if that is where you installed Qt)

  3. You should now have a nice yourappname.dmg file in the build directory. Open this up and check that your application runs from there.
  4. If everything is working fine, you can do some prettifying of your .dmg file by opening it up using the Disk Utility and converting it to a Read/Write disk image.
  5. Open your Read/Write disk image and create a shortcut to your Applications folder. This could either be done by dragging the Applications folder while holding the command key or by creating a symbolic link in terminal:
    ln -s /Applications ./Applications
  6. Edit the icon size, background image, etc. by clicking Command + J to open the View Options. Also, use View -> Hide Toolbar and Hide Sidebar to hide the excessive toolbars from the disk image.
  7. Close the image and use Disk Utility to convert it back to a compressed disk image.
  8. Distribute your .dmg file.

If you need more details about the process and how deployment is performed, have a look in the Qt Docs.

Posted in Programming, Qt | Tagged , , , , , , | Leave a comment

Nanoparticles for Android is just around the corner

Thanks to the great work of Bogdan Vatra and the Qt Developers working on Lighthouse, I have finally been able to create a running version of Nanoparticles on Android. Their efforts have led to the Necessitas project, a very user friendly and working port of Qt to Android.

I’ve only had a HTC Magic with no OpenGL capabilities available for testing, but still the game is running pretty good. This is giving me perhaps too high hopes about how it will perform on a stronger device, such as a Samsung Galaxy SII. I’ll try to get hold of a device like that soon.

In addition I’ve moved almost all the UI code in Nanoparticles over to QML. This finally makes the menus and game logic separated and also has made it a lot easier to add some transitions and user feedback to the UI elements.

I’ve only got a early alpha version ready at the moment, but I’ll probably need a lot of help testing how the game runs on different devices and setups. I will post back here as soon as I’ve got something for you to play with. Maybe I’ll even push it to Android Market in a not so distant future for early testing.

Posted in C++, Games, Programming, Qt | Leave a comment

Bookmarks in terminal

Today I found a great tool to ease the navigation in terminal, called apparix. It lets you bookmark a folder so that you easily can navigate to it just by typing

to nameofbookmark

To install apparix in Ubuntu, type

sudo apt-get install apparix

in a terminal window.

After installation you need to set up the aliases “bm” for bookmarking and “to” for going to a bookmark by adding a few functions to your .bashrc file in your home folder (if you don’t have this file, you can create it yourself).

You’ll find the functions you need to add by issuing the command

apparix --shell-examples

in a terminal window. Copy everything below “Bash-style functions” except the “CSH-style aliases”. Paste this into your .bashrc file.

Open up a new terminal, cd to your directory of choice and type

bm mybookmark

to bookmark the folder. Afterwards you can go to any folder and type

to mybookmark

to go to your bookmark.

This tool is of course available for other Linux distributions too.

Posted in Ubuntu | Tagged , , , | 1 Comment

RewriteRule in .htaccess not working for cURL

For some strange reason I have experienced on one server that the RewriteRule in .htaccess is not working for cURL via the command line. The fix has been to add a User-Agent line to the header of the cURL command, like this:

curl --head --header "User-Agent: blablabla" http://dragly.org/

I have no idea why this happens, but I was pointed to this solution in a forum which I forgot to bookmark. I hope this might help you out if you should run into the same problem.

Posted in Programming | Leave a comment

Fixing the volume treshold and intervals in Ubuntu on Dell XPS M1330

So the new Ubuntu version is finally out and as with every other time I’ve been upgrading from one version of Ubuntu to a new one, I keep forgetting how to fix the sound issue on the Dell XPS M1330. It is no big issue, really. It is simply that the lowest volume threshold is a bit high with headphones plugged in and that the volume intervals are a bit too large.

Fixing this is thankfully simple even though I keep forgetting. I guess this has to do with the fact that I’m only doing this once every six months.

If you’re having the same issue, open up a terminal and open the file “/etc/pulse/default.pa” in your favorite editor:

gksudo gedit /etc/pulse/default.pa

Change the line that says

load-module module-udev-detect

into

load-module module-udev-detect ignore_dB=1

Save and close the file.

Now, let’s restart pulseaudio and open alsamixer in terminal

pulseaudio -k
alsamixer

Use the arrow keys on your keyboard to bring down the PCM volume to about 50 % (or whatever suits your ears). Close alsamixer with ESC.

Now you should be able to enjoy your listening without blowing out your ears. Just note that whenever you are using your speakers and need them back at full volume, you might have to open up alsamixer again and bring the PCM volume back up.

Editing the default.pa file just makes pulseaudio respect your PCM setting. Otherwise it would set it to 100 % whenever you change the volume.

Posted in Ubuntu | 1 Comment

Nanoparticles available for Nokia N9

Finally the N9 is here. And so is Nanoparticles for the Nokia N9. You can over to Nokia Store to get a copy right now:

Download Nanoparticles

You can read more about Nanoparticles and download it for other platforms on this page.

Posted in Programming | Tagged , , , , | Leave a comment

How to get things done with todo.txt

The simple answer to how you get things done is to actually do them. However, to do things in an organized manner is more easily said than done. Why? Because it is way too easy to drift away with less important stuff when you’re supposed to do anything you have to.

What solved my problem: Todo.txt. Why?

The solution for me has always been to have a todo list that I can look up whenever I’m wondering about what to do next. It is way too hard to stay focused on a task if I have to remind myself about what’s next all the time. Leaving later tasks in an organized list makes it possible for me to avoid these constant reminders and let me focus peacefully on one task at a time, knowing that I won’t forget the next important task.

However, keeping such a list can introduce another problem to solve: How can I store the list in an easily accessible place that makes it easy to review it, cross things off it, list only one project at a time and maybe only the top priorities?

The best option for availability is to have the list on a whiteboard next to my computer, but that reveals several problems. The whiteboard will be way too small no matter how large a whiteboard I buy, and it will not be easily synchronized. In other words, I will most likely need something that runs on my computer.

Several applications are available for this purpose, but I have yet to find one that works well on all my systems with synchronization. I’ve tried to set up manual synchronization of folders using services like Dropbox, Ubuntu One and SpiderOak, but after Getting Things Gnome on my laptop wrote over all my changes from my desktop and Tasque failed on me while syncing via Remember The Milk, I decided to go back to the good old “todo.txt” file in a folder on my computer.

This works fine, but it lacks some options to sort tasks after priority or project. However, there is a beautiful script application that has come to the rescue for me. Visit todo.txt to see what I’m talking about.

It’s basically a simple script that lets you keep your todo-list in a file for compatibility and availability between systems, while giving you the options to view, add and delete tasks via the command line.

This solves all problems with syncing and availability. Now I can leave the syncing to a system such as Ubuntu One without worrying about compatibility between my phone and my computer, and even be able to view, add and delete tasks without ever leaving the terminal.

And should I ever be on a system without the todo.txt script, I can always open the file in vim or view it with cat.

Task lists from code comments

What about task lists from code comments? I often leave comments in LaTeX-files, code files and Python scripts like this:

// TODO: Make a cup of coffee

Well, as I said, I’ve often got a terminal open when working on anything, so the best solution for me would be never to leave the terminal:

cat <<anyfileyoulike>> | grep TODO

This simply lists all the TODO-comments in my code or text file, so that I can easily review the ones that are not yet done. Simple as that.

Posted in Efficiency, Programming | Leave a comment