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.

Downloads

Sources

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 0.6.8.9 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: , , , ,

Tethering Your Android to Linux (without rooting your phone)

Posted in computers on March 2nd, 2010 by karrth

EDIT: Since tethering is now built in to phones with 2.2 and up, this is not really needed. I would recommend rooting to avoid extra service charges though.

If you’re stuck in an area with no internet connection except your Android phone, you can use your phone as a proxy for your laptop’s internet connection.

Setup on AndroidProxoid barcode for Android

First, you need to enable USB Debugging by going to Settings/Applications/Development/ and clicking the checkbox.  Be sure to plug your Android device into your computer with the USB cable.

Next, you need to install Proxoid.  You can do this by searching the market on your phone, or scanning the barcode to the right.

The final step is to open up the application, and check the “Start/Stop Proxoid” box.

Tethering the Phone

The first thing you need is the Android SDK.  Download it and extract the contents into /opt/android/

As root, create the file /etc/udev/rules.d/90-android.rules
with these contents:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"

Now as root, create the file /usr/sbin/tether
with these contents (or download it here):

#!/bin/bash
/opt/android/tools/adb kill-server
/opt/android/tools/adb start-server
/opt/android/tools/adb devices
/opt/android/tools/adb forward tcp:8080 tcp:8080

Make sure you make the file executable:
chmod 744 /usr/sbin/tether

Finally, run the program tether as root.

If you’re having issues, try running each command in the tether file individually so you can see any error messages.

If you don’t setup the “Run as a service” section below, type

killall adb

as root to disconnect your tether.

Setting up the proxy in Firefox

Go to Edit/Preferences/Advanced/Network/Settings…

Under the HTTP Proxy, type “localhost”, and under Port type “8080″ so it looks like the screenshot below:

Firefox Proxoid Proxy SettingsHit “Ok” twice to get out of your Preferences window, and you should be good to go!

Optional: Make it a service in Arch Linux

You can do this in other Linux distros as well, but for Arch you can download this file to /etc/rc.d/tetherd.

As root, chmod it as such to make it executable:

chmod 744 /etc/rc.d/tetherd

Now you can start tether automatically as a service by putting it in your rc.conf file, or manually by typing:

/etc/rc.d/tetherd { start | stop | restart }

Enjoy!

Further Reading

Tags: , , ,

Busting Out of Your Firewall with SOCKS

Posted in computers on February 25th, 2010 by karrth

Most people find themselves accessing the internet from somewhere besides their home, and often times there are restrictions on the network that disable some protocols, or maybe block some websites you’d like to see.  An easy way to get around this is to forward your web session over an ssh session.  This can be done in any OS… the only requirement being that you have an ssh server setup outside of the network you are currently on.  The port I’ve chosen (8080) is arbitrary – you can choose anything above 1024.

Windows

Download putty, and type the name of your ssh server in the Host Name field.  Now select (Under “Category:”) Connection/SSH/Tunnels.

Putty SSH port forwardingUnder source port, enter “8080″ and select “Dynamic” under that.  Next, hit “Add”, which should add “D8080″ under “Forwarded Ports”.  Now hit open, and login to your machine.

Finally, you need to setup Firefox to go through your proxy.  Go to: Tools/Options/Advanced/Network/Settings…

Firefox network settingsEnter “localhost” under the SOCKS Host and “8080″ under the Port.  Make sure that SOCKS v5 is selected under that.

Hit “Ok” a couple times to get out of your configuration windows, and you’re good to go!

Linux/Mac

Now things are a little simpler under Linux/Mac.  All you need is ssh.  Simply type in terminal:
ssh -D8080 username@host.com

And set your browser’s proxy settings like we did above for Windows.

Further Reading

Tags: , , ,

Linux CLI programs to replace your GUI

Posted in computers on January 21st, 2010 by karrth

While many people enjoy using their GUI, sometimes it is just not efficient to do so.  Or maybe you don’ t have the resources to load an X-Window manager… So  I present to you some very useful programs that don’t need X.

System Tools

  • htop – like top (processes monitor), but with colors and an improved interface
  • iftop - instead of monitoring processes, it monitors your ethernet devices and displays connection speeds and average transfer rates
  • mkisofs and cdrecord - make an ISO and then burn it to disc!
  • screen – a terminal multiplexer that allows you to manage virtual terminal sessions within your one session.  Think of it as multiple desktops for the terminal.
  • smbstatus – if you run a Samba server/share on your machine, you can see here who’s connecting to it and what files they have open
  • wireless-tools – gives you a couple programs including iwconfig and iwlist that make it easy to connect to a wireless AP through terminal
  • wpa_supplicant – needed if you want to connect to a WPA encrypted AP with the wireless-tools.  Here’s a quick tutorial.

Internet

  • finch – chat with your friends (or enemies) with this terminal version of Pidgin
  • irssi - an amazing slick little IRC chat client
  • lynx and elinks – both are text based web browsers so you can cruise the web without those pesky graphics
  • mutt – read your Gmail (or other mail) from the terminal.  Mutt supports IMAP, POP3, and SSL Certificates, among other things.
  • rtorrent - this torrent client is great for sending to the background with screen, and even watches folder for new torrent files.  Check out this user guide for help.

Media

  • mplayer/mencoder- did you know that it was not only a media player, but that you could convert video, audio, or even rip dvds?  Doh!
  • moc - gives you a nice ncurses interface for playing music on your terminal
  • ushare – share your media with your Xbox 360 or PS3.  There’s also a web and telnet interface you can use once you’ve started the program.

Be sure to check the man pages for all the features these programs offer!  And don’t forget to explore the programs that are already on your machine – you’d be surprised and what’s there already.

Further reading:

Tags: , ,