Wednesday, December 29, 2010

How to get mpg321 working with Fedora Core 14

mpg321 is a very popular command-line mp3 player for Linux platform. I use mpg321 for mp3 audio clips playback with Granule.

Needless to say, mpg321 has been a reliable piece of a very useful software for ages and it took me by surprise when all of the sudden, it began to crash left and right under my recently installed Fedora Core 14 that I run as VirtualBox's guest OS.

At first, I naturally assumed that VirtualBox was a culprit to my woes. However, a quick test with Rhythmbox ruled out that hypothesis of mine.

To make a long story short, mpg321 relies on a cross-platform audio library, libao, to play mp3 files. Recently, some internal data structure of libao changed when its latest release was let out in the wild, and mpg321 has not been updated to reflect the change (if you are interested, is a matter of backward compatibility issue entangled with  using uninitialized memory -- learn more from Bug #580062).

The workaround is to uninstall the official mpg321 release, and then download and compile the source code yourself:
  • Uninstall official mpg321,
    sudo rpm -e mpg321
    
  • Download latest source code for mpg321 from its Source Forge download page.
  • Unpack the source code:
    tar xvfz mpg321-0.2.21-1.tar.gz  
  • Install dependency development packages:
     sudo yum -y install libmad-devel libid3tag-devel
    
  • Configure, compile, and install mpg321
    cd mpg321-0.2.21-1
    configure
    make
    sudo make install
    
  • You should have now problem now playing your mp3 files:
    mpg321 music.mp3

Monday, December 20, 2010

RedHat Linux VNC server setup with GDM

Preamble

This blog will guide you to setup your Linux headless remote desktop with VNC sessions of different screen resolutions.

VNC stands for Virtual Network Computing. Connecting to remote headless Linux server implies running a remote Linux desktop session, namely, GNOME desktop.

I had great success with TightVNC client (available for Windows, MacOS, and Linux) over a number of years.

Install Software Packages

$ sudo yum install xinetd
$ sudo yum groupinstall "GNOME Desktop Environment"
$ sudo yum install tigervnc-server

The last package installs following executables:

/usr/bin/Xvnc
/usr/bin/vncconfig
/usr/bin/vncpasswd
/usr/bin/vncserver
/usr/bin/x0vncserver


vncserver is the daemon. Each connection to a remote desktop client is served by Xvnc instance.

Configure GDM

GDM is the GNOME Display Manager -- a graphical login greeter. This configuration runs GDM in the background on a headless (no X-Server) Linux host. This kind of configuration would be useful for a data server hidden away in your basement.

In order to setup remote GDM invocation, we need to enable XDMCP protocol. XDMCP protocol stands for X Display Manager Protocol. It is used by the X servers to communicate among each other in the UNIX world.
  • Edit /etc/gdm/custom.conf
    • Within the file find [xdmcp] section and set Enable to 'true'
      • Enable=true
    • Fix the RemoteGreeter bug. Somehow, GDM cannot pick up the path to greeter. In [greeter] section add simple-greeter location:
      • [greeter]
      • RemoteGreeter=/usr/lib64/gdm/simple-greeter
    • To turn off the X Windows session, find [servers] section and comment out the following line
      • #0=Standard
Setup xinetd Service

Linux xinetd service is a secure internet service daemon -- a sort of a service gateway to your Linux server. You bind a specific service to a specific port number (address) and when connection request comes in, xinetd starts that service on your behalf.

In our case, a VNC client (TightVNC) knows how to communicate with VNC server over XDMCP protocol. All we need for TightVNC to work is to add port number binding to the VNC server instantiation via xinted. Each binding offers a remote desktop service with different screen resolution.
  • Under /etc/xinted.d/ directory, create vnc1920 file:
service vnc1920
{
 disable     = no
 socket_type = stream
 protocol    = tcp
 group       = tty
 wait        = no
 user        = nobody
 server      = /usr/bin/Xvnc
 server_args = -inetd -broadcast -query localhost -geometry 1920x1200 -depth 16 -once -fp unix/:7100 -securitytypes=none
}
  • Note here that the color depth can be set to 8, 16, 24, and 32 bits. You might want to create different service entries with different color depths to learn which one is best for you.
  • Create similar service files for other screen resolutions
 vnc1024 for 1024x768       
 vnc1280 for 1280x1024     
 vnc1680 for 1680x1050     
    • Edit /etc/services file and bind service files you have created above with the port numbers
    vnc1024 5900/tcp
    vnc1280 5901/tcp
    vnc1680 5902/tcp
    vnc1920 5903/tcp

    The port number resolution is HOST-IP:0 for 5900, HOST-IP:1 for 5901 and so on.

    Restart xinetd service
    • sudo /sbin/service xinetd restart
    Start Remote Desktop Session

    From your desktop, start TightVNC client and try to connect to HOST-IP:0 or HOST-IP:1.

    Sometimes, you would need to restart your server in order for all services to bounce nicely.

    End Remote Desktop Session

    One thing to remember is to never end your GNOME remote desktop session with Actions->Log out. Instead, close the session down by clicking on [x] windows adornment button in the left top corner.

    References

    Other VNC tutorials you might find useful: