Setup Exim4 to send emails via an outside server

Posted in computers on November 20th, 2014 by karrth

In this post, I’ll show you how to setup Exim4 to send all email through outside accounts on a Debian system. You can also use this to send emails through Gmail or any other outside service. Be sure to replace any emails/domains with your own!

This came about because I wanted to get my logwatch emails from my at-home media center on my regular email server so I could get them all in one place. I also wanted them to be encrypted in transport, and for them to be legitimate emails. My internet-hosted mail server runs postfix, and my media center had Exim4.

Configuring Exim4

  1. Run dpkg-reconfigure exim4-config
    1. General type of mail configuration: “mail sent by smarthost; received via SMTP or fetchmail” (or the no local mail option, depending on your setup)
    2. Mail name: localhost or your fqdn
    3. SMTP Listener:
    4. Other destinations for which mail is accepted: leave blank
    5. Machines to relay mail for: leave blank
    6. IP address or host name of the outgoing smarthost: (or whatever your server/port is. Note the double colons)
    7. DNS Queries: select no
    8. Delivery Method: up to you. If you don’t do a lot of mail management on this system, I’d recommend mbox
    9. Configuration file: split the files (yes)
  2. Configure the account(s)
    1. Edit /etc/exim4/passwd.client
    2. Add a line for each account you would like to use, in the format:

    3. Double check permissions on this file are 640 and root:Debian-exim
    4. Edit /etc/email-addresses and add a line for each local account who you would like to use an outside account instead in the format:

      You can assign as many or as few emails as you want. Multiple local accounts can share the same outside email address as well.

    5. If you made any changes previously to your /etc/aliases file, you may want to set them back to their deafults
    6. Update all configurations with:
      sudo update-exim4.conf
      sudo service exim4 restart
  3. Make sure your email is being received properly! Test test test!
    1. On your machine with exim4, check /var/log/exim4/mainlog
    2. If your outside server uses postfix, check /var/log/mail.log
    3. Send quick test emails with:

      echo "my test email" | mail -s "My Subject"

    4. You can view your current email queue with:

      sudo exim -bp

    5. Delete all emails in your exim4 queue (if you messed something up and have a bunch of crap lying around) with:

      sudo exim -bp | awk '/^ *[0-9]+[mhd]/{print "sudo exim -Mrm " $3}' | bash

    6. Use exim -bt -d to get a bunch of information about how exim would process an email to that domain. Very helpful if you want to see exactly what is going on.
    7. Check your postfix queue with:

      sudo postqueue -p

    8. Delete specific queued messages from postfix with:

      sudo postsuper -d [message id]

    9. Delete all deferred messages from postfix with:

      sudo postsuper -d ALL deferred

Extra Configuration Options

I wanted to have all email go out to my mail server, and I wanted it to be able to send everywhere. Extra things to check for this particular setup are:

  • On the server with exim4, edit:
    Under the “smarthost” category, change from:

    domains = ! +local_domains


    domains = *

  • On the server with postfix, make sure it will accept mail from your exim4 machine’s hostname in order to get mail intended for local users. You can do this by adding the hostname to the mydestination variable in /etc/postfix/ This works for me because all my usernames are the same on both systems.
  • On the server with postfix, make sure you have the smtpd_recipient_restrictions variable configured in /etc/postfix/ to accept SASL authenticated users. I would recommend something like:

    smtpd_recipient_restrictions =

    There are many other options for this, but setting up postfix is a discussion for another post.

I hope this was helpful! See the resources below for further reading/other configuration examples.


Tags: , , , ,

Debian boots into initramfs – cannot find disk

Posted in computers on April 16th, 2014 by karrth


I recently borked my server after upgrading Debian on my server. The events went as such:

  1. My server, a VPS, was running Debian 6 (squeeze), and I wanted to upgrade to Debian 7 (wheezy)
  2. Ran apt-get update and apt-get upgrade to update packages
  3. Edited the /etc/apt/sources.list file and changed “squeeze” to “wheezy” in all instances
  4. Ran the apt-get update/upgrade again
  5. Ran an apt-get dist-upgrade to finish the full upgrade
  6. Noticed that after a reboot, the kernel hadn’t changed from 2 up to 3, so I ran a grub-update
  7. Checked /boot/grub/menu.lst, saw that the new kernels were in fact in there and set as the default
  8. Rebooted…..

The Problem

After a while of no pings, I knew I was in trouble. Luckily, my VPS host provides serial console access to the machine, which saved my butt. After logging in, I see that it dumped into initramfs at boot with an error indicating that the system could not find the disk by UUID. I tried mounting the drive, but received a “cannot be found” error. Previously when I’ve encountered this issue, I’ve booted with a LiveCD, and just reinstalled GRUB. In this case, this was not an option.

The Solution

After poking around, I realized I could not mount the drive because there were no modules loaded that could handle the filesystem. You can verify this with lsmod. So I:

  1. Added the ext3 module: modprobe ext3
  2. Created a temp folder in /root/ and mounted the root drive there with mount /dev/xvda1
  3. Browsed down to /root/tmp/boot/grub/ and checked out the menu.lst file with vim
  4. Compared the UUIDs in /dev/disk/by-uuid/ with the ones in the menu, and saw they were different
  5. Fixed the UUIDs, saved the file, rebooted

And all was saved! Thanks to this blogger for the post that inspired me to think about the modules.

Tags: , , , , ,

Subsonic 4.x and SSL certificates on Debian/Ubuntu

Posted in computers, music on February 7th, 2014 by karrth

One of my favorite applications of late is Subsonic. It allows you to stream all of your media over a nice web interface, or to your mobile devices. I wanted to setup my installation with a proper SSL certificate, since I use my own subdomain for it.

EDIT: This has worked for me with Subsonic 4.8 and 4.9


  • This only worked for me when running openjdk-7-jre, not 6. You can install it with:

    sudo apt-get install openjdk-7-jre

  • You need the jar tool if you’re going to update the jar file, but this is an optional step. If you need this package, install:

    sudo apt-get install openjdk-7-jdk

    Or you can use the zip or 7z utility, since jars are zips

The Setup

  1. Stop Subsonic:

    service subsonic stop

  2. Backup your file:

    cp /usr/share/subsonic/ /usr/share/subsonic/

  3. Edit /usr/share/ and set SUBSONIC_HTTPS_PORT= to the port you want to use. 443 is the default https port, but may be blocked by your ISP if you are hosting from home. If you want to disable http, you can set the SUBSONIC_HTTP_PORT=0, but this is not necessary as it will redirect to the HTTPS port if enabled.
  4. Acquire a self generated or purchased SSL certificate. The one that comes with Subsonic is a wildcard certificate for * This works best if you utilize their DNS service and use a subdomain to reach your server. You should now have a .key and a .crt file to work with
  5. Convert your .crt file to a PKCS12 format. When prompted give the password “subsonic”:

    openssl pkcs12 -in mydomain.crt -inkey mydomain.key -export -out subsonic.pkcs12

  6. Create the keystore. When prompted, give the passwords “subsonic”:

    keytool -importkeystore -srckeystore subsonic.pkcs12 -destkeystore subsonic.keystore -srcstoretype PKCS12 -srcalias 1 -destalias subsonic

  7. Tell Subsonic to use your keystore one of two ways:
    1. Backup the jar file, overwrite the original keystore and verify the permissions:

      cp /usr/share/subsonic/subsonic-booter-jar-with-dependencies.jar /usr/share/subsonic/subsonic-booter-jar-with-dependencies.jar.backup

      jar uf /usr/share/subsonic/subsonic-booter-jar-with-dependencies.jar subsonic.keystore

      chmod 744 /usr/share/subsonic/subsonic-booter-jar-with-dependencies.jar

      If you want to use 7zip or zip, replace the jar command with:

      zip -u /usr/share/subsonic/subsonic-booter-jar-with-dependencies.jar subsonic.keystore


      7z u /usr/share/subsonic/subsonic-booter-jar-with-dependencies.jar subsonic.keystore

    2. OR instead of replacing the file:

    3. Save it to Subsonic’s home and refer to it with the configuration:
      1. Copy the keystore to Subsonic’s home and verify ownership/permissions:

        cp subsonic.keystore /var/subsonic/

        chown subsonic:root /var/subsonic/subsonic.keystore

        chmod 744 /var/subsonic/subsonic.keystore

      2. Edit /usr/share/subsonic/ and add these additional lines at line 123, after -Djava.awt.headless=true \ and before -verbose:gc \:

        -Dsubsonic.ssl.keystore=/var/subsonic/subsonic.keystore \
        -Dsubsonic.ssl.password=subsonic \

  8. Start Subsonic:

    service subsonic start

That’s it! Make sure you login to confirm it’s working, and check your certificate at the top. If something fails, restore those backups! To check for errors, watch /var/subsonic/subsonic_sh.log. It’s re-created every time Subsonic starts up.

Tags: , , , , , ,

Customizing the Kindle Fire with 6.2.1

Posted in computers on January 1st, 2012 by karrth

I was the lucky receiver of a Kindle Fire this holiday season from my kind aunt, and since it is an Android device, I made it my mission to customize it exactly to my liking. I’m working with a Kindle Fire loaded with 6.2.1. Beware that you could void your warranty.

EDIT: rooting the device will disable things like Amazon Prime Instant Streaming videos. I only found this out after rooting of course, and the kind people at Amazon were very helpful in telling me that I would have to unroot the device to get streaming back. You can still steam the Prime Instant videos through the web browser though, so don’t fret to much.


  • Root the device
  • Install a recovery/boot manager application
  • Install the Android Market and other Google Apps

I am not addressing loading Cyanogenmod 7 on here because I am going to wait until the ROM is more stable before loading it on my device.


Rooting the Kindle Fire is a fairly simple device, no matter what OS you are using. The best tutorial I found for all OSes was posted on (including pictures and videos in case you are extra confused). I will briefly go over the steps here:

  1. Go to Settings/Device, and make sure your device is on version 6.2.1
  2. In that same menu, change “Allow Installation of Applications” to “On”
  3. Download and unzip it into your working directory. I would recommend creating a new folder for this process, since you will accumulate quite the number of files
  4. If you do not already have adb setup from previous work with other Android devices, then you will have a couple extra steps, which will vary depending on your OS:
    1. Windows only: Install the driver for the Kindle, which can be found in the usb_driver folder
    2. All OSes: copy the adb_usb.ini file from the usb_driver folder to your .android folder in your user directory. For Windows, this can be found by typing %UserProfile% into your Explorer address bar. For Linux and Macs, it will be in your home directory at /home/[username]/.
  5. Now copy the KindleFireRoot.apk file from your PC to your Kindle’s internal storage. You can install it by using a variety of apps like File Expert or ES File Explorer. It is up to you. Simply browse to the folder with the apk, select it, and install.
  6. Open the app, and select the root option after acknowledging the credits (as you should, since these people put in a lot of time to make this easy for you!)
  7. Finally, open a terminal/cmd prompt and browse to your KindleFireRootNew folder so you can execute the commands below. If you do not have adb installed already and you are running Linux or Mac, replace “adb” with “adb-linux” or “adb-mac”, depending on your OS. If you are running linux, make sure you execute the commands as root (type sudo -s to enter a root environment).

    adb root
    adb remount
    adb push su /system/xbin/su
    adb shell chown 0.0 /system/xbin/su
    adb shell chmod 06755 /system/xbin/su
    adb install Superuser.apk

    And you’re done!

Install the Recovery Manager

Installing a recovery manager will allow you to make full system backups and flash ROMs like Cyanogenmod, if you wish. For most Android devices, I would highly recommend Clockworkmod, but for the Kindle Fire, the TeamWin Recovery Project 2 (hereafter refered to as TWRP) is a much better choice, since it uses the touch screen instead of hardware buttons (which the Fire does not have) to navigate the menus.

Installing TWRP is not necessary for installing the Android Marketplace or other apps, but having it installed is a good idea if you plan on messing around with your system’s innards much. This way, you can restore a full system backup in case you drastically mess something up. I followed the steps found on

Be aware that this process can be a little buggy (at least, it was for me) and might require you to open up your device’s hardware. Please read through the steps and the troubleshooting section that follows before continuing with this section.

  1. Open up a terminal/cmd prompt and type the following, replacing “adb” for the appropriate command, similar to the rooting process, as necessary:

    adb shell
    idme bootmode 4002

    Your Kindle should hang on the Kindle Fire logo after this. According to the guide, Windows users will have to reload the driver, as explained in the rooting process. Since I use Linux, I did not do this and cannot verify it for you.
  2. Type the following into your terminal/cmd prompt, replacing “fastboot” with “fastbook-linux” or “fastbook-mac” as appropriate:

    fastboot -i 0x1949 boot twrp-blaze-2.0.0RC0.img

    This installs TWRP on your Kindle Fire. When it finishes, select the “reboot” option
  3. After it reboots, type the following, again replacing “fastboot” for the command appropriate to your OS:

    fastboot -i 0x1949 oem idme bootmode 4000
    fastboot reboot

    This will reset the boot mode for your Kindle so that it will boot normally. If your device does not reboot properly, see the troubleshooting section.
  4. And you’re done! To enter TWRP, follow the instruction at the bottom of the screen with the hazard logo, which tells you to hold the power button (wait until the power button turns orange, then release). I would recommend entering TWRP and creating a full backup right away, just so that you have a clean copy to recover to in case anything happens at a later time.

Troubleshooting TWRP

I ran into an issue when installing TWRP, where it would hang on the hazard logo, and was undetectable by my computer. I was unable to boot into TWRP, or the Kindle’s original OS. If this happens to you, don’t worry! Your device is not bricked, it will just take some extra effort to get it back. I found this process on the blog. I would highly recommend looking over the pictures that he posted under the section “Opening the case of your Fire”.

NOTE: Unfortunately, this process is only possible through Linux. If you do not have a Linux machine and are unfamiliar with the OS, I would highly recommend getting a copy of an Ubuntu LiveCD. This will allow you to boot into a Linux environment without installing it onto your machine.

  1. Download the file, which can be found at the bottom of this forum post.
  2. Unzip to your working directory, and download a copy of TWRP into this folder. You could copy the one you have from your file, but my problem was fixed when I downloaded a fresh copy from their website instead of using the one I already had. This was quite possibly the reason I ran into this issue in the first place, as the download might have been oh-so-slightly corrupted.
  3. Next type the following into your terminal/cmd prompt while in your working directory as root. You can enter a root environment by typing sudo -s:

    ./usbboot aboot.bin u-boot.bin; ./fastboot boot twrp-blaze-2.0.0RC0.img

    It should say something about “waiting for the device” at this point.

  4. Remove the back plate from your Kindle. I found this process to work best by prying away the back with a butter knife, or something similarly dull and sturdy, and then carefully running an id card/gift card/some semi-sturdy plastic item down the side to pop out the clips. Be very careful, as you can easily break the clips or the pieces they snap into. I managed to only break one at the very end, since i started to remove the whole back before unsnapping the last one.
  5. While it is not included on the evilsoapbox blog instructions, I removed the battery cable from the circuit board so that the Kindle had to be powered over USB. Without doing this, my computer never picked up the Kindle. Be very careful when removing the power cable, as it is a very tight space, and the plastic female end on the board is fairly weak.
  6. Short the pin on your Kindle, as marked in the following picture, by putting one end of a paperclip on the pin, and the other on the silver box surrounding the nearby area (notice the two arrows). By following picture, I mean the picture that is not yet posted. I didn’t take a picture when my Kindle was open, and I’d rather not reopen it just for a picture. You can see a good picture here. I’ve emailed the blog author about posting it here, and will post a copy if/when he gives me permission
  7. While holding the paperclip in place, plug in the usb cable to your Kindle Fire. The program you executed earlier should pick up the device and re-install TWRP. Once it is done installing, you can remove the paperclip. Be very careful in picking up the device, and power it off.
  8. Reattach the battery cable, and make sure your Kindle boots. When it is, type the following commands, which are found in your KindleFireRootNew folder:

    fastboot -i 0x1949 oem idme bootmode 4000
    fastboot reboot
  9. Finally, reassemble the back of your Kindle. Be careful you do not catch the red/white/blue twisted cable in the side. Again, I would highly recommend entering TWRP and making a full backup at this point.
  10. Final Note: After my first full reboot without being plugged into an external power source, my Kindle refused to boot, and only the backlight would momentarily turn on. This fixed itself after leaving it plugged into the wall for a while. I’m not sure if this was a low battery problem, or if a second reboot was simply needed after this whole problem. I have not had the problem since, and I have done full reboots multiple times since, both with and without external power. Unfortunately, this is part of the risk of these kind of activities.

Installing the Android Market and Other Apps

It is fairly frustrating to have an Android device that cannot access the Android Marketplace, especially if you have other Android devices that you have already purchased apps for. You have two options to install apps from the Android Marketplace on your rooted Kindle Fire:

  1. Make a backup of the apps you desire on your other Android device using something like ES File Explorer, and then transfer the apk to your Kindle over usb, dropbox, or some other method.
  2. Install the Android Marketplace and install applications directly to the device through the Market app.

While the second method is much easier (once you have the market app installed, that is), some apps will not show up in the Market for your Kindle, as they might be deemed incompatible. I found most of the steps needed at this forum post and in this PC World article.

To install the Android Market onto your rooted Kindle Fire, go through the following steps:

  1. Download this gapps.rar file to your Kindle. It contains the Marketplace, along with many other Google apps, such as Maps, G+, Gmail, Talk, Youtube, etc. You can install these through your file browser
  2. Using File Expert, ES File Explorer, or whatever file browser you’re using, install the GoogleServiceFramework.apk
  3. Download (or preferably, buy) Root Explorer. I did this buy purchasing the app on my Android phone, backing up and copying the apk over to my Kindle. You can find links to the apk online various places, but I’m not going to link to them here.
  4. Using Root Explorer, copy the com.amarket.apk file from your gapps folder to the /system/app folder on your Kindle. Before hitting paste, you’ll have to hit “Mount R/W” at the top of the screen. The websites I link to reference using the Vending.apk file, but this is for the old Marketplace, and will not work
  5. Long press on com.amarket.apk and select Permissions. Check Read for Owner, Group, and Others, and Write for Owner. The permissions should match those of the other apks in the /system/app folder.
  6. Grab a copy of the Market Opener app and install it, since the Marketplace will not show up in the Kindle’s App menu after the first reboot.
  7. Do a full reboot. If you encounter errors when accessing the Marketplace, do another reboot, and they should go away.

The only app that I have installed manually so far that is in the Android Marketplace normally, but is not listed for the Kindle was GTA3. It installs fine, but there is no sound ingame, and there is no way to exit the program without force-closing it through the Settings/Applications menu. Otherwise, it runs/plays/saves great!

Enjoy, and good luck!



Tags: , , ,

Sudoku solving

Posted in computers on November 11th, 2011 by karrth

One of our projects for my into to artificial intelligence class this semester was to create a sudoku solver using a MRV (minimum remaining values) heuristic and backtracking. It finds all possibilities for each square, then tries all possibilities for one of the squares with the lowest number of possible values. Here’s an example of it’s use (X6800 cpu):

$ time ./ puzzle.hard.txt
- - 8 7 4 - - - -
- 2 - - - 5 - - 4
- - 3 - - 2 1 - -
0 - - - - 1 2 - -
- 5 - 0 - - 4 - -
7 - - - - - - 0 1
- - - 8 1 - - - 0
- - - - - 0 5 - -
- - - 2 - - - 6 8


5 1 8 7 4 3 0 2 6
6 2 7 1 0 5 8 3 4
4 0 3 6 8 2 1 7 5
0 8 6 4 7 1 2 5 3
3 5 1 0 2 6 4 8 7
7 4 2 5 3 8 6 0 1
2 6 5 8 1 7 3 4 0
8 7 4 3 6 0 5 1 2
1 3 0 2 5 4 7 6 8

real 0m0.170s
user 0m0.167s
sys 0m0.000s

While it is not the most efficient, it will solve any hard-level sudoku puzzle of any size. It takes the puzzle file as an argument, or it will prompt you for the file path if you don’t include it. It will take puzzles with values that range from 0-9 and A-Z after that.

I’ve included in the tarball 2 harder puzzles that my program does not solve in anything close reasonable time (as in… it didn’t solve either one after running for 24 hours) if you’d like to try and improve the code yourself :). There are many ways you could improve the program, as talked about here (not my school/class). This is the website for the book we use in class – I’d highly recommend it for anybody interested in AI programming. Enjoy!

  • Sudoku Solver and example problems
  • Tags: , ,

    Adventures with the Droid 3

    Posted in computers on November 1st, 2011 by karrth

    I was finally able to renew my contract and upgrade to a Droid 3 from my OG Droid (may it rest in peace). After lots of tweaking (which will never be done), I’ve decided to post what I’ve done, as it may help others.


    Of course the first thing to do is to root that beauty, right? Right? You can find instructions on how to do so using Windows, Mac, or Linux in this post at the forums.


    One of the first complaints many people have about smartphones these days is the amount of bloatware that they come with. It’s almost as bad as buying a desktop computer a couple years ago (or a laptop today, for that matter)… The two things I found to be most useful in reducing bloat are:

    1. Doing a factory reset as soon as you get your phone (no reason to configure things twice…). If you want to backup your settings, make sure you do it to an external SD card, not the internal storage, as this will be wiped with a factory reset.
    2. If you rooted your phone (which you did, right? After doing the factory reset that is…), grab a copy of TitaniumBackup. You can use this to backup all of your data as well (make sure it’s to an SD card!!!) if you waited to do a factory reset.

    After installing TitaniumBackup, the real fun begins. While it’s tempting to straight up uninstall unwanted apps, this can cause system instability, and since the bootloader is still locked, it is not possible to do a fresh reset if you mess something up. I found some great lists of apps you can safely freeze in this thread at the AndroidCentral forums. This post in particular is pretty comprehensive.

    Removing the wrong apps can cause a boot-loop, and even leaving some frozen when doing a factory reset can cause a loop issue. I’ve seen it noted by some forum users that freezing the Backup Assistant app can cause a factory reset to go awry (probably because it is brought up during the setup process), so be sure to unfreeze it before a reset.

    Here’s a list of apps I have frozen:

    • Apps (Verizon Apps Store)
    • Backup Assistant
    • Backup Assistant Client
    • Desk Home
    • Email
    • Email Authenticator
    • Email Engine – freezing this causes the Calendar to crash when adding a new event
    • Gallery (see next section for further explanation)
    • Help Center
    • Messaging
    • Motorola Dock Service
    • News
    • Smart Dock
    • Social Location
    • Social Messaging
    • Social Networking
    • Social Sharing
    • Social Status

    These are only the ones I have frozen for now. I suspect that there are other things that can be frozen, such as the MOTOBLUR Indexing Service, but I have not tested these yet. You might not want to freeze some of these items if you use them, such as the Universal Inbox (Email) and the various Social applications. More on that later.

    The Gallery

    Personally, the Gallery app that comes with this phone is horrid. Makes me want to puke. Luckily, there’s an easy way to get the old Gallery back, as found here at the xda-developers forum. It worked beautifully for me.

    Motorola Terms of Service

    I’m not sure how many people actually read these things (I’m told not many do…), but this is one that needs to be read. When adding more accounts to your phone, such as Facebook, LinkedIn, Flickr and Yahoo!Mail through the built in “My Accounts”, the Gallery (the one that came with the phone), or the various built in Social apps, you are presented with two documents. I have not agreed to these documents because they describe, in great detail, how they will then collect all (ok, not all, but most) of your personal information, such as your:

    • purchase history
    • calendar
    • social networking credentials
    • SIM card ID
    • location (via GPS, WiFi, or cell tower triangulation)

    …among other things. It then says lower down that they will be using this information to provide you with information about things you might be interested in, and that it will be sharing it with third parties. And that your information will be subject to those party’s individual privacy policies. You can even check the second box (done for you already) so that you can share even more! Like your browsing history and demographics information from your social networks.

    All in all, I do not like what these documents are saying. If you don’t believe me, read it yourself. If you don’t care about your personal information, then have fun! It saddens me greatly that Motorola would build in such a system to their phones, and is part of why I froze all of the built in Social apps, Universal Inbox, and the default Gallery, and the News app, since they are all integrated into this system.

    Some Apps

    As a quick aside, here are some of my favorite apps:

    • LauncherPro homescreen replacement
    • Subsonic music streamer and it’s accompanying server software.
    • DroidWall is an Android iptables implementation. Root required.
    • ConnectBot ssh client
    • TitaniumBackup is a great backup tool, especially if you have root.
    • Wifi Analyzer wifi scanning tool
    • SetCPU is a great under/overclocking tool that I use to underclock and save battery. Unfortunatly, it has caused some system instability for me, so I wouldn’t recommend using it unless you want to fiddle around with it to find stable settings. I’ll update if I do find settings that work for me.

    Have a good day!

    Tags: ,

    Minecraft server init script with CraftBukkit plus updating

    Posted in computers on June 14th, 2011 by karrth

    So I forked a project on github for a Minecraft linux server init script. The original is also a fork from a script that can be found in the Minecraft Wiki.

    The biggest change in my version was the reintegration of the update function from the original script, along with expanding it to check for CraftBukkit updates. Using this script to run my Minecraft server in RAM has been really nice, and it has made scheduling regular backups a breeze with cron jobs.

    Tags: , ,

    Creating a Custom Arch Linux LiveCD/LiveUSB

    Posted in computers on May 11th, 2011 by karrth

    Since I’m a huge fan of Arch Linux, it was my distro of choice for creating a LiveCD (for me, a USB key). It’s pretty easy with Arch, using a wonderful tool called archiso. ISOs built with this tool will also have the ability to be either burned to a CD, OR put onto a USB key. Below, you can find a copy of the ISO I built and a tarball of the files needed to build it so you can use it as a template for your own build. Have fun!

    Creating your live image

    I followed the Arch Wiki page for archiso to build all of this. Be sure to read the wiki page for all of the details for each file – I’m only going to provide templates for your own build and my own finished files. For a basic setup, none of the template files need to be modified.

    1. Create a working directory – mine is called “archlive”
    2. Create a file called “Makefile”. Here’s a template. If you don’t modify anything, this file will build your ISO with the name “myarch[date].iso”
    3. Create a file called “mkinitcpio.conf”. Here’s a template.
    4. Create a file called “packages.list”. Here’s a template. This is where you specify which packages will be included in your live image. The template has a basic set that will get you started, but you can expand on this as much as you want.
    5. Create a file called “isomounts”. Here’s a template.
    6. Setup syslinux (your boot manager) by creating the folderboot-files/syslinux/ and then creating the file boot-files/syslinux/syslinux.cfg. Here’s a template for syslinux.cfg.
    7. Create a folder called “overlay”. This will contain any files that you want to be copied into the root directory of your live image. When the ISO is created, any permissions/attributes will be copied as well, so make sure they are all owned by root, and any executables are set as such (chmod +x [file]).
    8. Inside of the overlay folder, create an “etc” folder, and inside of that create your “fstab” file. Here’s a template.
    9. Inside of the “overlay/etc” folder, create a file called “rc.conf”. If you don’t know what it does, check out the template.
    10. Inside of the “overlay/etc” folder, create a file called “inittab”. If you don’t know what it does, here’s the Arch Wiki inittab page. Here’s a template.
    11. Inside of the “overlay/etc” folder, create a file called “hosts”. Here’s a template.
    12. Finally, once you have all of your files setup in your working directory, it’s time to compile the ISO. From your working directory (the one with your Makefile in it), type make all. If you encounter an error, or have to stop half-way through, type make clean before doing a make all again.
    13. After a while (10-20 minutes even if you have a slow machine), your image will be generated inside of your folder. You can either burn this to a CD, or put it on a USB stick with this command:
      dd if=my-image.iso of=/dev/some-usb-drive bs=8M

    And you’re done! There are maany changes you can make to this setup, which really is the point of making a custom LiveCD… So mess around with it, see what you can change!

    My personal changes

    • I added a second, regular user through the file overlay/etc/rc.d/setup, which also does some other boot time configs, such as checking permissions and copying the user’s files from the overlay/skel
    • I added some personal scripts, aurget, and the Archiso PXE server program into overlay/usr/bin/
    • I moved the Arch Linux install script from overlay/arch/ to overlay/usr/sbin.
    • I added some config files, such as ones for vim, iptables, pacman, and aurget into overlay/etc/

    Again, there is a lot you can do with this – so don’t be afraid to just try something. Once you get it working, it’s a good idea to make a copy of your working directory before making other changes if you are unsure what you are doing. Otherwise, you might end up having to start all over if you forget excatly what change broke your build. And just because the ISO is created without a hitch, doesn’t mean that it will boot without a problem as well. If you’re unsure with your changes, it’s a good idea to compile the ISO and test your builds regularly.

    Be sure to check out Archiso’s example! Going through a working set of files is the best way to learn in my opinion. Also be aware that your Live image will be read only – while you can make changes to the system while booted, it will be reset when you reboot. I’ve included a link to a page on how to create a second writeable partition on your USB key if you want to have some storage on the same device.



    Tags: , ,

    Using an iPod Classic 160GB with Linux

    Posted in computers, music on April 29th, 2011 by karrth

    So I recently decided that I needed to buckle down and get an mp3 player that would hold a large portion of my library. I went with an Apple iPod Classic 160gb, because of the historical ability to sync iPods with media managers like Banshee and Amarok on linux. Unfortunately, this is not the case with this model. So after many hours of trial and tribulation, here is my final solution. Scroll down further if you’d like to see all of the methods I tried.

    My Setup

    • iPod Classic 160gb, Model: A1238, fresh out of the box
    • 64bit Arch Linux

    The Process

    1. Plug your iPod into your computer with the USB cable
    2. Install VirtualBox. If you are also running Arch, I’d highly recommend checking out the wiki page.
    3. Setup a Windows machine in VirtualBox. Personally, I already had a WindowsXP virtual machine (VM) setup, so that is what I used. If you are unfamiliar with this process, check out this tutorial.
    4. After you have Windows setup in VirtualBox, you need to enable the USB and add a filter for your iPod. First, make sure your VM is powered off so that you can change the settings. Then right click on the machine in the manager, and hit Settings. Under settings, click on the USB category on the left. You should have a screen that looks like this:
      On the right hand side, click on the button with the green plus.  It says “Add Filter From Device” when you mouse over it.  From there, select your iPod – it will say something like “Apple Inc. iPod [0001]”.  If you have USB 2.0, you’ll want to check the “Enable USB 2.0 Controller” box above the filter list.  Your screen should look like this now (I have USB 2.0, so I checked the box):
    5. Now boot your VM. Once it is booted, you’ll want to install foobar2000, which is an amazing music player if you are a Windows user. But we’re just going to use it since it’s much faster than iTunes. If you’re unfamiliar with this process, check out this tutorial, which also includes the steps of getting foobar2000 to sync with your iPod
    6. WARNING: If you have a fresh-out-of-the-box iPod, you’ll have to install iTunes first so that you can go through the License Agreements and such, otherwise you can’t do anything with your iPod.
    7. After installing foobar2000, you’ll also need to download the iPod plugin (I used the most recent stable, which was as of this writing) and the Nero ACC Codec if you want to have foobar2000 automatically convert songs that are not iPod compatible.
    8. To install the iPod plugin, simply unzip the file you downloaded and place the “foo_dop.dll” file in the plugin folder (default is C:\Program Files\foobar2000\components\)
    9. To install the Nero ACC Codec, unzip the file and place the win32\neroAccEnc.exe file in the foobar2000 install folder. If you put the exe here, foobar2000 will automatically pick it up. If it didn’t, or you want to keep the exe somewhere else, go to Preference/iPod Manager/Conversion in foobar2000 and locate the exe for it
    10. Now to share your library with your VM – at the top of your VM, you should have the VirtualBox menus (They include Machine, Devices, and Help). Click on Devices/Shared Folders. Then click the folder with the green plus on the right hand side, and browse to your music. Make sure you check the “Auto-mount” and “Make Permanent” options so that your folder will always be connected whenever you boot your VM. Once that is complete, you can find your shared folder under \\VBOXSVR on your VM. For convenience’s sake, right click on your music folder and hit “Map Network Drive” and then “Finish”. Your shared music should now show up as a network drive under My Computer.
    11. Now to add your library to foobar2000 – in foobar2000, hit Library/Configure. Then click Add, click on the drive we just mapped in My Computer, then click OK.
    12. foobar2000 will now start processing your library. When it’s done (or even while it’s still processing), you can then right click on an artist, album, or individual song, go to iPod/Send to iPod. You can also have it sync a playlist with your iPod under File/iPod (among many other options).
    13. BAM! You’re done! :)

    Things I tried that didn’t work

    • gtkpod, Banshee, and Amarok on my linux install
    • iTunes (kept freezing on processing artwork and the gapless crap), yamipod, froddlepod and poddox in my WindowsXP VM

    Back when I was a Windows user oh-so-long-ago and had an iPod (the 60gb photo when it first came out), I was a big fan of YamiPod, but it didn’t like this 160gb model.

    Good luck!

    Tags: , , , ,

    Amazing Pictures of Space

    Posted in ramblings on June 17th, 2010 by karrth

    Almost everybody at some point has looked up at the stars in amazement.  Don’t you wish you could see them better?  Here’s a list of sites where you can find some new amazing ways to look at the stars from your own computer…

    • – of course NASA would have great pictures :)  They also have video available.
    • NASA’s Picture of the Day – a wide variety of both space and science related videos and pictures that include a detailed description with many reference links for each piece of media.  They just celebrated their 15th anniversary on June 16th!
    • – fantastic page that lets you zoom in on composite pictures of our galaxy.
    • – photos specifically taken by the Hubble telescope
    • HiRISE – Courtesy of the University of Arizona, they specialize in very high resolution pictures of anywhere but earth
    • – images specifically from the Spitzer telescope at California Institute of Technology
    • Mars Rover @ – Images from both Spirit and Opportunity on Mars (be sure to click on “Raw Images” on the left)
    • – has a wide variety of space related pictures setup in multiple galleries
    • – pictures from the European Space Agency
    • Reddit’s bmgoau compilations – This user posted some great links to both very high res pictures and a clip from the epic IMAX film, Cosmic Voyage.
    • – Tired of looking at these on your computer?  Want to see them on your wall?  You can buy posters of many quality space pictures here, many of which can be found at NASA’s Pic of the Day.
    • NASA Earth Image of the Day – and finally an inverse of the first link: images of earth, from space!

    I’m sure there’s more out there – feel free to post your links in the comments!

    EDIT: The Gateway to Astronaut Photography of Earth is worth checking out as well!

    Tags: , , ,