Thursday, August 15, 2013

How to Install and Use Hamachi on Ubuntu Server 10.04 LTS

Logmein.com is a great service for anyone who wants to access their computer securely from anywhere on the internet. Logmein offers both free and paid versions of their services which include among other things, remote computer access, remote backup services and, the topic of this article, free vpn software called Hamachi. 

Hamachi is easy to use and allows you to join several computers to a virtual private network and share resources across the internet. For my purposes, I use Hamachi as a quick and easy way to enable remote sessions across my private network which spans several households, and includes a couple of linux servers and a dozen or so Windows and Mac boxes.
This walk-though will get Hamachi up and running on Linux Server 10.04 from the command line. There may be a way do do it using a gui, but since I run a headless machine, this method works well for me. 


To get things started, first download the latest linux client software which can be found here: LogMeIn Hamachi Beta Labs Site Obviously I'll be using the latest DEB package, but you may need a different flavor. Hamachi comes in both 32 and 64-bit versions, be sure to download the appropriate one for your system.


Download 32-bit version:

$ wget https://secure.logmein.com/labs/logmein-hamachi_2.0.1.15-1_i386.deb
Download 64-bit version:

$ wget https://secure.logmein.com/labs/logmein-hamachi_2.0.1.15-1_amd64.deb
Install the package. Note if you have an old version of Hamachi already installed, you should uninstall it before you move on.

Install 32-bit version
$ sudo aptitude install lsb && sudo dpkg -i logmein-hamachi_2.0.1.15-1_i386.deb
Install 64-bit version
$ sudo aptitude install lsb && sudo dpkg -i logmein-hamachi_2.0.1.15-1_amd64.deb
The above command will also install a dependency lsb, which the Lab page stated is required for Hamachi before installing the downloaded package.


Next, start the service

$ sudo service logmein-hamachi start

The easiest way to join a network is to create one on the Logmein.com website. (This requires a free Logmein account and is fairly self explanatory). You'll nee to the Network ID (not the name) prior to proceeding. To configure the client on our server, first we set a nick name for this computer on the network. The nick name will show up in "Join" requests and on peer lists.

To connect your server to the network, follow these commands:
$ sudo hamachi do-join xxx-xxx-xxx 
$ sudo hamachi set-nick [Nickname]
$ sudo hamachi login

Password:
Joining xxx-xxx-xxx .. ok, request sent, waiting for approval
You will replace “xxx-xxx-xxxx″ with your own network ID. If you use a password on your network you need to enter it when prompted. I set up my Hamachi network so that all "Join REquest" must be manually approved by the adminstrator (me), so I don't have a password and just hit enter at the prompt. 

Once you see the waiting for approval message, log into your LogMeIn account and approve access for your server.


Once approved:

$ sudo hamachi list
You should see a list of networks you are joined to, currently one, the name of the network and a list of other peers connected to it. You will see the VPN IP address also of this peer. This is always in the 5.0.0.0 network. The other peer connected to my network is 5.163.224.23. Test connectivity using ping.

$ ping 5.163.224.23
If you get ping response, your connected and ready to go!

Wednesday, March 21, 2012

Gettting WiFi to Work in Ubuntu 10.04 (Broadcom Chipset)

When I first started playing with Ubuntu on my laptop and desktop computers, one of the most annoying things to deal with was getting my WiFi to work. I know Ubuntu (and the Linux developers in general) like to stick with open source and non-restricted device drivers, but I detest the fact that my Broadcom wifi card does not work "out-of-the-box" on a standard Ubuntu installation. My ranting aside, here's how to get yours working WITHOUT depending on wrapper or other convoluted methods.

First check what chipset is in your wifi card using the lscpi command:

sudo lspci -v

This command shows information on all your pci bus hardware (at least that how I understand it). You'll be looking for a Network Controller. The output for my control is:

08:00.0 Network controller: Broadcom Corporation BCM4311 802.11a/b/g (rev 01)
    Subsystem: Hewlett-Packard Company Broadcom 802.11a/b/g WLAN
    Flags: bus master, fast devsel, latency 0, IRQ 16
    Memory at e8000000 (32-bit, non-prefetchable) [size=16K]
    Capabilities: [40] Power Management version 2
    Capabilities: [58] MSI: Enable- Count=1/1 Maskable- 64bit-
    Capabilities: [d0] Express Legacy Endpoint, MSI 00
    Capabilities: [100] Advanced Error Reporting
    Capabilities: [13c] Virtual Channel
    Kernel driver in use: b43-pci-bridge
    Kernel modules: ssb

The important part you are looking for is Device ID. The Device ID for the wifi card on my system is "08:00.0" Using this we can now find out what hardware you have in your system by issuing the following command

sudo lscpi -nn -s 08:00.0

Obviously you'll need to replace my Device ID with the one from your system, but you get the jist. You should get an output similar to what I have here:

08:00.0 Network Controller [0928]: Broadcom Corporation BCM4311 082.11a/b/g [1434:4312] (rev 01)

The last set of brackets contains your Hardware Identifier. If yours is the same as mine, then the Ubuntu installer prbably loaded the wrong set of drivers for your card during the install process and the following commands SHOULD fix your problems:

sudo apt-get update
sudo apt-get install firmware-b43-installer
sudo apt-get remove bcmwl-kernel-source
sudo reboot

If this works for you, let me know in the comments. Happy wifi!

Many, many, many thanks to Niel Smith at nfolamd who figured this out. Here's his original post: http://nfolamp.wordpress.com/2011/10/815/ubuntu-11-10-getting-wireless-bcm4311-working/

Thursday, July 21, 2011

Install MediaTomb and Configure for Use With DirecTV DVR

If you plan on using a UPnP server to share media and you have a DirecTV DVR, MediaTomb is a great application to look into.  MediaTomb is an open source UPnP server with a basic web interface that allows you to stream digital media to any UPnP compatible device through your home network. One of the really cool aspects of MediaTomb is that it is able to transcode files on-the-fly into a format readable by your UPnP player. While, installation of MediaTomb is pretty straightforward, the configuration can be a bit tricky for those new to Ubuntu and the command line interface (like me).

If you've been following my guide from the beginning, you'll know I'm using Ubuntu Server 10.04 (Lucid Lynx). The following configuration should work on any Ubuntu system post 9.04 (Jaunty), but I've only tested 10.04. Also, since Ubuntu is Debian based, this configuration should work on Debian 6, but you may have to tweak your configuration a bit to get everything working.

First we need to get our system updates then we'll install MediaTomb and the supporting programs used by MediaTomb to transcode your media files on the fly.

sudo apt-get update
sudo apt-get install mediatomb vlc imagemagick vsftpd ffmpeg
 
At the prompt, answer "y"

As a rule of thumb, any time I change my configuration files, I make a "control" copy that I can revert back to. These control copies have been invaluable when I'm configuring a service and it completely stops working. Using them I can simply start from scratch without uninstalling/removing a program. So, let copy the original MediaTomb config file to preserver a control or backup copy.

sudo cp /etc/mediatomb/config.xml /etc/mediatomb/config.xml.original

Now we need to edit the MediaTomb config file to transcode our media files to a format compatible with our DirecTV DVR. Personally, I like the vim command line text editor. If you prefer another editor such as nano, vi, etc, simply change "vim" to the editor of your choice. Issue the following command to edit the MediaTomb config file.

sudo vim /etc/mediatomb/config.xml

This will open the config file for editing and viewing. Ass you scroll through the file you'll see loads of options your can change and customize to meet your specific needs.

The first thing we are going do is change the display name of our media server. While this doesn't change any functionality of MediaTomb, it is a quick way to ensure the correct configuration file is being used by MediaTomb. To change your MediaTomb's server name look for the line that reads:

<name>MediaTomb</name>

and change it to

<name>YourServerName</name>

Persoanlly, I used "Media Server" but you can call your server whatever your heart desires.

Next we need to add the following lines to the config file under the <extension-mimetype> group. Add the following lines under the default set under this heading.

<map from="ts" to="video/mpeg">
<map from=”vob” to=”video/mpeg”/>
<map from=”wav” to=”audio/wav”/>
<map from=”mpg” to=”video/mpeg”/>
<map from=”aac” to=audio/x-aac”/>
<map from=m4a to=audio/mp4"/>

<map from=”mkv” to=”video/x-matroska”/>
<map from=”mov” to=”video/x-quicktime”/>

Now we need to define MediaTomb's transcoding responsibilities. To configure for the DirecTV DVR, replace or comment out the original <transcoding> sections with the following configuration lines. Personally, I commented out the original section with <!– –> so I could track the changes I made. If you are commenting out the original transcoding line, look out for the line that reads:

<agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>

The double dashes in front of the "sout" command will end your commenting and give cause errors when starting MediaTomb. To overcome this error simply add a space between the double dashes.

Once the original transcoding section is commented out or removed, add the following lines to your MediaTomb configuration file.

<transcoding enabled="yes">
  <mimetype-profile-mappings>
  <transcode mimetype="audio/mpeg" using="vlcwav"/>
  <transcode mimetype="video/x-flv" using="vlcyoutube"/>
  <transcode mimetype="video/mp4" using="transvideo"/>
  <transcode mimetype="video/x-quicktime" using="transvideo"/>
  <transcode mimetype="application/ogg" using="vlcwav"/>
  <transcode mimetype="audio/x-ms-wma" using="vlcwav"/>
  <transcode mimetype="audio/x-ms-asf" using="vlcwav"/>
  <transcode mimetype="audio/x-flac" using="ffmpegwav"/>
  <transcode mimetype="audio/x-aac" using="vlcwav"/>
  <transcode mimetype="audio/mp4" using="vlcwav"/>
  <transcode mimetype="video/x-msvideo" using="transvideo"/>
  <transcode mimetype="video/x-ms-wmv" using="transvideo"/>
  <transcode mimetype="video/mpeg" using="mpeg2trans"/>
  <transcode mimetype="video/x-matroska" using="transvideo"/>
  <transcode mimetype="image/jpeg" using="rescalejpeg"/>
</mimetype-profile-mappings>
<profiles>
  <profile name="transvideo" enabled="yes" type="external">
    <mimetype>video/mpeg</mimetype>
    <accept-url>no</accept-url>
    <first-resource>yes</first-resource>
    <agent command="ffmpegvideo" arguments="%in %out 8300k 256k"/>
    <buffer size="57600000" chunk-size="128000" fill-size="10000000"/>
  </profile>
  <profile name="mpeg2trans" enabled="yes" type="external">
    <mimetype>video/mpeg</mimetype>
    <accept-url>no</accept-url>
    <first-resource>yes</first-resource>
    <hide-original-resource>yes</hide-original-resource>
    <agent command="ffmpegvideo" arguments="%in %out 8000k 256k"/>
    <buffer size="28800000" chunk-size="512000" fill-size="12000"/>
  </profile>
  <profile name="ffmpegwav" enabled="yes" type="external">
    <use-chunked-encoding>no</use-chunked-encoding>
    <mimetype>audio/wav</mimetype>
    <accept-url>no</accept-url>
    <first-resource>yes</first-resource>
    <agent command="ffmpegaudio" arguments="%in %out"/>
    <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
  </profile>
  <profile name="vlcwav" enabled="yes" type="external">
    <use-chunked-encoding>no</use-chunked-encoding>
    <mimetype>audio/wav</mimetype>
    <accept-url>yes</accept-url>
    <first-resource>yes</first-resource>
    <agent command="vlc" arguments="-I dummy %in –sout #transcode{acodec=s16l,ab=192,channels=2}:standard{access=file, mux=wav,dst=%out} vlc:quit"/>
    <buffer size="512000" chunk-size="32000" fill-size="64000"/>
  </profile>
  <profile name="rescalejpeg" enabled="yes" type="external">
    <mimetype>image/jpeg</mimetype>
    <accept-url>no</accept-url>
    <first-resource>yes</first-resource>
    <accept-ogg-theora>no</accept-ogg-theora>
    <agent command="convert" arguments="-size 1080×720 %in -auto-orient -resize 112.5%x100% +profile ‘*’ %out"/> <buffer size="50000" chunk-size="100" fill-size="100"/>
  </profile>
    <profile name="ffyoutube" enabled="no" type="external">
    <mimetype>video/mpeg</mimetype>
    <accept-url>no</accept-url>
    <first-resource>yes</first-resource>
    <accept-ogg-theora>yes</accept-ogg-theora>
    <agent command="ffmpegyoutube" arguments="%in %out"/>
    <buffer size="14400000" chunk-size="256000" fill-size="80000"/>
  </profile>
  <profile name="vlcyoutube" enabled="yes" type="external">
    <mimetype>video/mpeg</mimetype>
    <accept-url>yes</accept-url>
    <first-resource>yes</first-resource>
    <accept-ogg-theora>yes</accept-ogg-theora>
    <agent command="vlc" arguments="-I dummy %in –sout #transcode{vcodec=mp2v,vb=4096,canvas-width=448, canvas-height=252,acodec=mpga,ab=64,samplerate=44100,channels=1}:standard{access=file,mux=ts,dst=%out} vlc:quit"/>
    <buffer size="14400000" chunk-size="256000" fill-size="80000"/>
  </profile>
</profiles>
</transcoding>

If you read through the script above, you’ll see the configuration calls several additional scripts which we now have to create. If you’ve been following my guide from the beginning, each of the following scripts will be placed in the /usr/bin directory; If your just jumping in to install MediaTomb, your system configuration may be slightly different and you’ll need to adjust fire to suit your system specifics. Also, once the scripts are created, we'll need to apply the proper permissions so the scripts can be run by MediaTomb.

Here are the three additional scripts we are going to create:
  •     ffmpegaudio
  •     ffmpegvideo
  •     ffmpegyoutube
Again, I’ll be using vim, but feel free to you the command line editor of your choice.

To create the ffmpegaudio script file in the /usr/bin directory issue the following command at the prompt.

sudo vim /usr/bin/ffmpegaudio

Next paste the script here copied from here.

Now we make the script executable by issuing the following command at the prompt.

sudo chmod a+x /usr/bin/ffmpegaudio

The remaining scripts are created using the same method, but you’ll need to change the respective names. The scripts for ffmpegvideo is here, and ffmpegyoutube is here.

Finally, if you read through the ffmpegvideo script, you’ll notice we also need to install Mediainfo which is not in the Ubuntu repositories. Mediainfo is a program which our script uses to gather the technical and tag information about our video files. Installation of Mediainfo is fairly straightforward and can be accomplished by issuing the commands below.

At the time of this writing, the links below were the most up-to-date versions for Ubuntu 10.04 LTS 64bit. If you are using a different version of Ubuntu, find the versions that correspond to your system at http://mediainfo.sourceforge.net/en/Download/Ubuntu and update the commands below to download/install the correct files.  

wget http://downloads.sourceforge.net/zenlib/libzen0_0.4.20-1_amd64.Ubuntu_10.04.deb

wget http://downloads.sourceforge.net/mediainfo/libmediainfo0_0.7.47-1_amd64.Ubuntu_10.04.deb

wget http://downloads.sourceforge.net/mediainfo/mediainfo_0.7.47-1_amd64.Debian_5.deb

sudo dpkg -i libzen0_0.4.20-1_amd64.Ubuntu_10.04.deb

sudo dpkg -i libmediainfo0_0.7.47-1_amd64.Ubuntu_10.04.deb

sudo dpkg -i mediainfo_0.7.47-1_amd64.Debian_5.deb

If you have followed all the directions above, MediaTomb should be ready to serve media to you DirecTV DVR, so all that is left is to restart the MediaTomb service using the following command.

sudo service mediatomb restart

Once the service restarts, open your web browser and navigate to http://YourServerIP:49152

When the page loads, you should see the MediaTomb homepage generated by your server. From here you should be able to navigate to and add in your media files to share across your network.

Hopefully you found the above useful in setting up your MediaTomb UPnP server. While I wish I could claim all the credit for the scripting listed in this post, I can't. All the scripting was pulled from teh MediaTomb site located here: http://mediatomb.cc/dokuwiki/transcoding:transcoding This site also contains a wealth of information that you can use to further customize and configure your system.